Commit 3fe1abad43f057903efb7980e29ce93af766891e

Stefan Sperling 2018-06-11T00:36:59

make 'got log' always show parents of merge commits

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/got/got.c b/got/got.c
index 0402e69..2d95db6 100644
--- a/got/got.c
+++ b/got/got.c
@@ -321,13 +321,14 @@ print_commit(struct got_commit_object *commit, struct got_object_id *id,
 	printf("author: %s\n", commit->author);
 	if (strcmp(commit->author, commit->committer) != 0)
 		printf("committer: %s\n", commit->committer);
-	if (verbose) {
+	if (commit->nparents > 1) {
 		struct got_parent_id *pid;
+		int n = 1;
 		SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) {
 			err = got_object_id_str(&id_str, pid->id);
 			if (err)
 				return err;
-			printf("parent commit: %s\n", id_str);
+			printf("parent %d: %s\n", n++, id_str);
 			free(id_str);
 		}
 	}