{"thread":{"id":"32308","subject":"[PATCH] format_commit_message(): simplify calls to logmsg_reencode()","startedAt":"2012-12-10T20:57:16Z","lastAt":"2012-12-10T20:57:16Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"204665","messageId":"7vboe1aamr.fsf@alter.siamese.dyndns.org","threadId":"32308","inReplyTo":null,"subject":"[PATCH] format_commit_message(): simplify calls to logmsg_reencode()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-10T20:57:16Z","receivedAt":"2012-12-10T20:57:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"All the other callers of logmsg_reencode() pass return value of\nget_commit_output_encoding() or get_log_output_encoding().  Teach\nthe function to optionally take NULL as a synonym to \"\" aka \"no\nconversion requested\" so that we can simplify the only remaining\ncalling site.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n pretty.c | 16 ++++------------\n 1 file changed, 4 insertions(+), 12 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex e87fe9f..732e2a2 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -500,7 +500,7 @@ char *logmsg_reencode(const struct commit *commit,\n \tchar *encoding;\n \tchar *out;\n \n-\tif (!*output_encoding)\n+\tif (!output_encoding || !*output_encoding)\n \t\treturn NULL;\n \tencoding = get_header(commit, \"encoding\");\n \tuse_encoding = encoding ? encoding : utf8;\n@@ -1184,23 +1184,15 @@ void format_commit_message(const struct commit *commit,\n \t\t\t   const struct pretty_print_context *pretty_ctx)\n {\n \tstruct format_commit_context context;\n-\tstatic const char utf8[] = \"UTF-8\";\n \tconst char *output_enc = pretty_ctx->output_encoding;\n \n \tmemset(&context, 0, sizeof(context));\n \tcontext.commit = commit;\n \tcontext.pretty_ctx = pretty_ctx;\n \tcontext.wrap_start = sb->len;\n-\tcontext.message = commit->buffer;\n-\tif (output_enc) {\n-\t\tchar *enc = get_header(commit, \"encoding\");\n-\t\tif (strcmp(enc ? enc : utf8, output_enc)) {\n-\t\t\tcontext.message = logmsg_reencode(commit, output_enc);\n-\t\t\tif (!context.message)\n-\t\t\t\tcontext.message = commit->buffer;\n-\t\t}\n-\t\tfree(enc);\n-\t}\n+\tcontext.message = logmsg_reencode(commit, output_enc);\n+\tif (!context.message)\n+\t\tcontext.message = commit->buffer;\n \n \tstrbuf_expand(sb, format, format_commit_item, &context);\n \trewrap_message_tail(sb, &context, 0, 0, 0);\n-- \n1.8.1.rc1.123.gf61cb86\n"}]}