"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
show from/via on consecutive lines in commit log
To:
gameoftrees@openbsd.org
Date:
Sat, 7 Jan 2023 16:48:23 +0100

Download raw body.

Thread
Both 'got log' and 'tog log' currently display the commit date
between the from: and via: lines. This patch tweaks the display
such that from: and via: appear on consecutive lines. I believe
this looks nicer, especially in case where commits were created
with the -A flag.

The date is always the committer's timestamp, and it is now always
displayed below the name of the committer.

Amazingly, there is no test fallout at all because the tests which
look at from/via lines all use grep to filter out the date.

ok?


diff /home/stsp/src/got
commit - d651dcfa6fe871c93d967b1b741d2ad4bbb9e2c2
path + /home/stsp/src/got
blob - f3bab984d4721436391e5b71e5cb14178af9a6ff
file + got/got.c
--- got/got.c
+++ got/got.c
@@ -4202,14 +4202,14 @@ print_commit(struct got_commit_object *commit, struct 
 	free(refs_str);
 	refs_str = NULL;
 	printf("from: %s\n", got_object_commit_get_author(commit));
-	committer_time = got_object_commit_get_committer_time(commit);
-	datestr = get_datestr(&committer_time, datebuf);
-	if (datestr)
-		printf("date: %s UTC\n", datestr);
 	author = got_object_commit_get_author(commit);
 	committer = got_object_commit_get_committer(commit);
 	if (strcmp(author, committer) != 0)
 		printf("via: %s\n", committer);
+	committer_time = got_object_commit_get_committer_time(commit);
+	datestr = get_datestr(&committer_time, datebuf);
+	if (datestr)
+		printf("date: %s UTC\n", datestr);
 	if (got_object_commit_get_nparents(commit) > 1) {
 		const struct got_object_id_queue *parent_ids;
 		struct got_object_qid *qid;
blob - c032241608751301e7be7c2f440255dec505fecb
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -4618,20 +4618,6 @@ write_commit_info(struct got_diff_line **lines, size_t
 	if (err)
 		goto done;
 
-	committer_time = got_object_commit_get_committer_time(commit);
-	datestr = get_datestr(&committer_time, datebuf);
-	if (datestr) {
-		n = fprintf(outfile, "date: %s UTC\n", datestr);
-		if (n < 0) {
-			err = got_error_from_errno("fprintf");
-			goto done;
-		}
-		outoff += n;
-		err = add_line_metadata(lines, nlines, outoff,
-		    GOT_DIFF_LINE_DATE);
-		if (err)
-			goto done;
-	}
 	author = got_object_commit_get_author(commit);
 	committer = got_object_commit_get_committer(commit);
 	if (strcmp(author, committer) != 0) {
@@ -4646,6 +4632,20 @@ write_commit_info(struct got_diff_line **lines, size_t
 		if (err)
 			goto done;
 	}
+	committer_time = got_object_commit_get_committer_time(commit);
+	datestr = get_datestr(&committer_time, datebuf);
+	if (datestr) {
+		n = fprintf(outfile, "date: %s UTC\n", datestr);
+		if (n < 0) {
+			err = got_error_from_errno("fprintf");
+			goto done;
+		}
+		outoff += n;
+		err = add_line_metadata(lines, nlines, outoff,
+		    GOT_DIFF_LINE_DATE);
+		if (err)
+			goto done;
+	}
 	if (got_object_commit_get_nparents(commit) > 1) {
 		const struct got_object_id_queue *parent_ids;
 		struct got_object_qid *qid;