summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-11-01 15:20:03 -0700
committerJunio C Hamano <gitster@pobox.com>2011-11-01 15:20:03 -0700
commitc17f1a9117916499a2153c7386ad3124e0b14ed0 (patch)
treeeff7f76ca9230419f5325a91221f5570b672de67 /pretty.c
parent0e7e30f5606b48a4c6d34bc99c6d680bb76d3fbc (diff)
parent1d5bd615c0d8dadfa9dee0511b3ba3feaf838877 (diff)
downloadgit-c17f1a9117916499a2153c7386ad3124e0b14ed0.tar.gz
Merge branch 'nd/pretty-commit-log-message'
* nd/pretty-commit-log-message: pretty.c: use original commit message if reencoding fails pretty.c: free get_header() return value
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/pretty.c b/pretty.c
index f45eb54e4c..230fe1cc82 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1094,7 +1094,6 @@ void format_commit_message(const struct commit *commit,
{
struct format_commit_context context;
static const char utf8[] = "UTF-8";
- const char *enc;
const char *output_enc = pretty_ctx->output_encoding;
memset(&context, 0, sizeof(context));
@@ -1103,10 +1102,13 @@ void format_commit_message(const struct commit *commit,
context.wrap_start = sb->len;
context.message = commit->buffer;
if (output_enc) {
- enc = get_header(commit, "encoding");
- enc = enc ? enc : utf8;
- if (strcmp(enc, output_enc))
+ char *enc = get_header(commit, "encoding");
+ if (strcmp(enc ? enc : utf8, output_enc)) {
context.message = logmsg_reencode(commit, output_enc);
+ if (!context.message)
+ context.message = commit->buffer;
+ }
+ free(enc);
}
strbuf_expand(sb, format, format_commit_item, &context);