Skip to content

Commit

Permalink
Merge branch 'nd/pretty-commit-log-message'
Browse files Browse the repository at this point in the history
* nd/pretty-commit-log-message:
  pretty.c: use original commit message if reencoding fails
  pretty.c: free get_header() return value
  • Loading branch information
Junio C Hamano committed Nov 1, 2011
2 parents 0e7e30f + 1d5bd61 commit c17f1a9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
Expand Down

0 comments on commit c17f1a9

Please sign in to comment.