summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-01-03 10:29:08 -0800
committerJunio C Hamano <gitster@pobox.com>2013-01-03 10:29:09 -0800
commitfbe8aa792b703e53785aaeb6bd9feac340e32ef2 (patch)
tree55d40007db26e8d645f9b3fcf2314741758aff5d /pretty.c
parentd5b95853c292254f4461148fe78afc244382676b (diff)
parentec008076dbe6acde42ce9ff796f72ca7c3edd5bf (diff)
downloadgit-fbe8aa792b703e53785aaeb6bd9feac340e32ef2.tar.gz
Merge branch 'jc/same-encoding'
Finishing touches to the series to unify "Do we need to reencode between these two encodings?" logic. * jc/same-encoding: format_commit_message(): simplify calls to logmsg_reencode()
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/pretty.c b/pretty.c
index 5bdc2e70bc..91bb2d3ef6 100644
--- a/pretty.c
+++ b/pretty.c
@@ -567,7 +567,7 @@ char *logmsg_reencode(const struct commit *commit,
char *encoding;
char *out;
- if (!*output_encoding)
+ if (!output_encoding || !*output_encoding)
return NULL;
encoding = get_header(commit, "encoding");
use_encoding = encoding ? encoding : utf8;
@@ -1250,23 +1250,15 @@ void format_commit_message(const struct commit *commit,
const struct pretty_print_context *pretty_ctx)
{
struct format_commit_context context;
- static const char utf8[] = "UTF-8";
const char *output_enc = pretty_ctx->output_encoding;
memset(&context, 0, sizeof(context));
context.commit = commit;
context.pretty_ctx = pretty_ctx;
context.wrap_start = sb->len;
- context.message = commit->buffer;
- if (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);
- }
+ context.message = logmsg_reencode(commit, output_enc);
+ if (!context.message)
+ context.message = commit->buffer;
strbuf_expand(sb, format, format_commit_item, &context);
rewrap_message_tail(sb, &context, 0, 0, 0);