]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-ort: implement format_commit()
authorElijah Newren <newren@gmail.com>
Fri, 1 Jan 2021 02:34:46 +0000 (02:34 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 4 Jan 2021 18:40:45 +0000 (10:40 -0800)
This implementation is based on a mixture of print_commit() and
output_commit_title() from merge-recursive.c so that it can be used to
take over both functions.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-ort.c

index 2dfab1858fc165f3e556323f1f706f3fd52d942b..bf704bcd34d3bb87cc3ea39cd0e2b2fa0b280dec 100644 (file)
@@ -328,7 +328,19 @@ static void format_commit(struct strbuf *sb,
                          int indent,
                          struct commit *commit)
 {
-       die("Not yet implemented.");
+       struct merge_remote_desc *desc;
+       struct pretty_print_context ctx = {0};
+       ctx.abbrev = DEFAULT_ABBREV;
+
+       strbuf_addchars(sb, ' ', indent);
+       desc = merge_remote_util(commit);
+       if (desc) {
+               strbuf_addf(sb, "virtual %s\n", desc->name);
+               return;
+       }
+
+       format_commit_message(commit, "%h %s", sb, &ctx);
+       strbuf_addch(sb, '\n');
 }
 
 __attribute__((format (printf, 4, 5)))