From e297cf5aff0264c16b6c325c0beab71bc04cd496 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 17:12:55 -0700 Subject: pretty: remove reencode_commit_message() This function has only two callsites, and is a thin wrapper whose usefulness is dubious. When the caller needs to learn the log output encoding, it should be able to do so by directly calling get_log_output_encoding() and calling the underlying logmsg_reencode() with it. Signed-off-by: Junio C Hamano --- pretty.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'pretty.c') diff --git a/pretty.c b/pretty.c index 8b1ea9ffad..c311a68fc4 100644 --- a/pretty.c +++ b/pretty.c @@ -1341,16 +1341,6 @@ void pp_remainder(const struct pretty_print_context *pp, } } -char *reencode_commit_message(const struct commit *commit, const char **encoding_p) -{ - const char *encoding; - - encoding = get_log_output_encoding(); - if (encoding_p) - *encoding_p = encoding; - return logmsg_reencode(commit, encoding); -} - void pretty_print_commit(const struct pretty_print_context *pp, const struct commit *commit, struct strbuf *sb) @@ -1367,7 +1357,8 @@ void pretty_print_commit(const struct pretty_print_context *pp, return; } - reencoded = reencode_commit_message(commit, &encoding); + encoding = get_log_output_encoding(); + reencoded = logmsg_reencode(commit, encoding); if (reencoded) { msg = reencoded; } -- cgit v1.2.1 From 76141e2e6280101362c3c5ddb22699b6f0458100 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 21:41:54 -0700 Subject: format_note(): simplify API We either stuff the notes message without modification for %N userformat, or format it for human consumption. Using two bits is an overkill that does not benefit anybody. Signed-off-by: Junio C Hamano --- pretty.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'pretty.c') diff --git a/pretty.c b/pretty.c index c311a68fc4..735cf0fec3 100644 --- a/pretty.c +++ b/pretty.c @@ -1035,7 +1035,7 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder, case 'N': if (c->pretty_ctx->show_notes) { format_display_notes(commit->object.sha1, sb, - get_log_output_encoding(), 0); + get_log_output_encoding(), 1); return 1; } return 0; @@ -1419,8 +1419,7 @@ void pretty_print_commit(const struct pretty_print_context *pp, strbuf_addch(sb, '\n'); if (pp->show_notes) - format_display_notes(commit->object.sha1, sb, encoding, - NOTES_SHOW_HEADER | NOTES_INDENT); + format_display_notes(commit->object.sha1, sb, encoding, 0); free(reencoded); } -- cgit v1.2.1 From ddf333f66cb8b8647a40e5d39731eaf63ee9fd44 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 18:51:47 -0700 Subject: pretty: prepare notes message at a centralized place Instead of passing a boolean show_notes around, pass an optional string that is to be inserted after the log message proper is shown. Signed-off-by: Junio C Hamano --- pretty.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'pretty.c') diff --git a/pretty.c b/pretty.c index 735cf0fec3..a53eb532aa 100644 --- a/pretty.c +++ b/pretty.c @@ -1033,9 +1033,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder, } return 0; /* unknown %g placeholder */ case 'N': - if (c->pretty_ctx->show_notes) { - format_display_notes(commit->object.sha1, sb, - get_log_output_encoding(), 1); + if (c->pretty_ctx->notes_message) { + strbuf_addstr(sb, c->pretty_ctx->notes_message); return 1; } return 0; @@ -1418,8 +1417,8 @@ 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->show_notes) - format_display_notes(commit->object.sha1, sb, encoding, 0); + if (pp->notes_message && *pp->notes_message) + strbuf_addstr(sb, pp->notes_message); free(reencoded); } -- cgit v1.2.1 From 5a664cf2c76ed83166f5f3ce7385e3cb058e8834 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Oct 2012 19:02:46 -0700 Subject: pretty_print_commit(): do not append notes message 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 --- pretty.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'pretty.c') diff --git a/pretty.c b/pretty.c index a53eb532aa..1925e9c3e4 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); } -- cgit v1.2.1