mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
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()
This commit is contained in:
commit
fbe8aa792b
16
pretty.c
16
pretty.c
|
@ -567,7 +567,7 @@ char *logmsg_reencode(const struct commit *commit,
|
||||||
char *encoding;
|
char *encoding;
|
||||||
char *out;
|
char *out;
|
||||||
|
|
||||||
if (!*output_encoding)
|
if (!output_encoding || !*output_encoding)
|
||||||
return NULL;
|
return NULL;
|
||||||
encoding = get_header(commit, "encoding");
|
encoding = get_header(commit, "encoding");
|
||||||
use_encoding = encoding ? encoding : utf8;
|
use_encoding = encoding ? encoding : utf8;
|
||||||
|
@ -1250,23 +1250,15 @@ void format_commit_message(const struct commit *commit,
|
||||||
const struct pretty_print_context *pretty_ctx)
|
const struct pretty_print_context *pretty_ctx)
|
||||||
{
|
{
|
||||||
struct format_commit_context context;
|
struct format_commit_context context;
|
||||||
static const char utf8[] = "UTF-8";
|
|
||||||
const char *output_enc = pretty_ctx->output_encoding;
|
const char *output_enc = pretty_ctx->output_encoding;
|
||||||
|
|
||||||
memset(&context, 0, sizeof(context));
|
memset(&context, 0, sizeof(context));
|
||||||
context.commit = commit;
|
context.commit = commit;
|
||||||
context.pretty_ctx = pretty_ctx;
|
context.pretty_ctx = pretty_ctx;
|
||||||
context.wrap_start = sb->len;
|
context.wrap_start = sb->len;
|
||||||
context.message = commit->buffer;
|
context.message = logmsg_reencode(commit, output_enc);
|
||||||
if (output_enc) {
|
if (!context.message)
|
||||||
char *enc = get_header(commit, "encoding");
|
context.message = commit->buffer;
|
||||||
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);
|
strbuf_expand(sb, format, format_commit_item, &context);
|
||||||
rewrap_message_tail(sb, &context, 0, 0, 0);
|
rewrap_message_tail(sb, &context, 0, 0, 0);
|
||||||
|
|
Loading…
Reference in a new issue