pretty_print_commit(): do not append notes message
[gitweb.git] / log-tree.c
index c894930c1863bfcf33a01b2d98c48478aa874186..e7e08f42ebc5b19c1c6e315d96a121940544caa6 100644 (file)
@@ -540,7 +540,6 @@ void show_log(struct rev_info *opt)
        struct pretty_print_context ctx = {0};
 
        opt->loginfo = NULL;
-       ctx.show_notes = opt->show_notes;
        if (!opt->verbose_header) {
                graph_show_commit(opt->graph);
 
@@ -648,6 +647,18 @@ void show_log(struct rev_info *opt)
        if (!commit->buffer)
                return;
 
+       if (opt->show_notes) {
+               int raw;
+               struct strbuf notebuf = STRBUF_INIT;
+
+               raw = (opt->commit_format == CMIT_FMT_USERFORMAT);
+               format_display_notes(commit->object.sha1, &notebuf,
+                                    get_log_output_encoding(), raw);
+               ctx.notes_message = notebuf.len
+                       ? strbuf_detach(&notebuf, NULL)
+                       : xcalloc(1, 1);
+       }
+
        /*
         * And then the pretty-printed message itself
         */
@@ -661,6 +672,9 @@ void show_log(struct rev_info *opt)
        ctx.reflog_info = opt->reflog_info;
        ctx.fmt = opt->commit_format;
        pretty_print_commit(&ctx, commit, &msgbuf);
+       if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
+           ctx.notes_message && *ctx.notes_message)
+               strbuf_addstr(&msgbuf, ctx.notes_message);
 
        if (opt->add_signoff)
                append_signoff(&msgbuf, opt->add_signoff);
@@ -689,6 +703,7 @@ void show_log(struct rev_info *opt)
        }
 
        strbuf_release(&msgbuf);
+       free(ctx.notes_message);
 }
 
 int log_tree_diff_flush(struct rev_info *opt)