X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=pretty.c;h=8688b8f2d45a493aa8b51b29f7d46b2abff7f30e;hb=3fc242f5ab8222745892047d4e481e71540425cd;hp=392d6565955febf10a5f03863d71a976ca3fe8dc;hpb=9d3d78435f2735b74afc74e9c5a735c27c026d33;p=git.git diff --git a/pretty.c b/pretty.c index 392d65659..8688b8f2d 100644 --- a/pretty.c +++ b/pretty.c @@ -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);