git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/6] pretty_print_commit(): do not append notes message

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 18, 2012, 05:45 UTC
Message-ID
<1350539128-21577-5-git-send-email-gitster@pobox.com>
In-Reply-To
<1350539128-21577-1-git-send-email-gitster@pobox.com>

The only case pretty_print_commit() appends notes message to the log message taken from the commit is when show_log() calls it with the notes_message field set, and the output format is not the userformat (i.e. when substituting "%N"). No other users of this function sets this field in the pretty_print_context, as can be easily verified in the previous step.

Hoist the code to append the notes message to the caller.
Up to this point, no functionality change is intended.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 log-tree.c | 3 +++
 pretty.c   | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 84e9f5b..e7e08f4 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -672,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);
diff --git a/pretty.c b/pretty.c
index a53eb53..1925e9c 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1417,9 +1417,6 @@ void pretty_print_commit(const struct pretty_print_context *pp,
 	if (pp->fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body)
 		strbuf_addch(sb, '\n');
 
-	if (pp->notes_message && *pp->notes_message)
-		strbuf_addstr(sb, pp->notes_message);
-
 	free(reencoded);
 }
 
-- 
1.8.0.rc3.112.gdb88a5e
Previous: Jeff KingNext: Junio C Hamano
Message 9 of 19 in “Bring "format-patch --notes" closer to a real feature”
  1. 0/6 Bring "format-patch --notes" closer to a real featureJunio C Hamano, Oct 18, 2012
  2. 1/6 pretty: remove reencode_commit_message()Junio C Hamano, Oct 18, 2012
  3. 2/6 format_note(): simplify APIJunio C Hamano, Oct 18, 2012
  4. 3/6 pretty: prepare notes message at a centralized placeJunio C Hamano, Oct 18, 2012
  5. Jeff KingOct 18, 2012
  6. Junio C HamanoOct 18, 2012
  7. Jeff KingOct 18, 2012
  8. strbuf: always return a non-NULL value from strbuf_detachJeff King, Oct 18, 2012
  9. 4/6 pretty_print_commit(): do not append notes messageJunio C Hamano, Oct 18, 2012
  10. 5/6 format-patch: append --signature after notesJunio C Hamano, Oct 18, 2012
  11. 6/6 format-patch --notes: show notes after three-dashesJunio C Hamano, Oct 18, 2012
  12. Philip OakleyOct 18, 2012
  13. Junio C HamanoOct 18, 2012
  14. Junio C HamanoOct 19, 2012
  15. Philip OakleyOct 21, 2012
  16. Jeff KingOct 18, 2012
  17. Nguyen Thai Ngoc DuyOct 18, 2012
  18. Michael J GruberOct 18, 2012
  19. Junio C HamanoOct 18, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.