merge-ort: implement format_commit()
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>
Elijah Newren committed
Jan 1, 2021 at 02:34 UTC
70f19c7fced2ec49fd9bca827370835d84d782c7
1 file changed
+13
-1
merge-ort.c
+13
-1
@@ -328,7 +328,19 @@ static void format_commit(struct strbuf *sb,
328
int indent,
329
struct commit *commit)
330
{
331
- die("Not yet implemented.");
331
+ struct merge_remote_desc *desc;
332
+ struct pretty_print_context ctx = {0};
333
+ ctx.abbrev = DEFAULT_ABBREV;
334
+
335
+ strbuf_addchars(sb, ' ', indent);
336
+ desc = merge_remote_util(commit);
337
+ if (desc) {
338
+ strbuf_addf(sb, "virtual %s\n", desc->name);
339
+ return;
340
+ }
341
+
342
+ format_commit_message(commit, "%h %s", sb, &ctx);
343
+ strbuf_addch(sb, '\n');
344
}
345
346
__attribute__((format (printf, 4, 5)))