diff options
Diffstat (limited to 'pretty.c')
-rw-r--r-- | pretty.c | 35 |
1 files changed, 31 insertions, 4 deletions
@@ -882,6 +882,23 @@ static void parse_commit_signature(struct format_commit_context *ctx) } +static int format_reflog_person(struct strbuf *sb, + char part, + struct reflog_walk_info *log, + enum date_mode dmode) +{ + const char *ident; + + if (!log) + return 2; + + ident = get_reflog_ident(log); + if (!ident) + return 2; + + return format_person_part(sb, part, ident, strlen(ident), dmode); +} + static size_t format_commit_one(struct strbuf *sb, const char *placeholder, void *context) { @@ -1023,6 +1040,14 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder, if (c->pretty_ctx->reflog_info) get_reflog_message(sb, c->pretty_ctx->reflog_info); return 2; + case 'n': + case 'N': + case 'e': + case 'E': + return format_reflog_person(sb, + placeholder[1], + c->pretty_ctx->reflog_info, + c->pretty_ctx->date_mode); } return 0; /* unknown %g placeholder */ case 'N': @@ -1178,7 +1203,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)); @@ -1187,10 +1211,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); |