diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-12-19 14:45:34 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-12-19 14:45:34 -0800 |
commit | f008159fc2dec7b98e74736751d3e6ad8d9c060f (patch) | |
tree | 4db5028a52251c217533bdec9a6a09c9c4be041a /pretty.c | |
parent | Merge branch 'ak/commit-only-allow-empty' (diff) | |
parent | ref-filter: add support to display trailers as part of contents (diff) | |
download | tgif-f008159fc2dec7b98e74736751d3e6ad8d9c060f.tar.xz |
Merge branch 'jk/trailers-placeholder-in-pretty'
In addition to %(subject), %(body), "log --pretty=format:..."
learned a new placeholder %(trailers).
* jk/trailers-placeholder-in-pretty:
ref-filter: add support to display trailers as part of contents
pretty: add %(trailers) format for displaying trailers of a commit message
Diffstat (limited to 'pretty.c')
-rw-r--r-- | pretty.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -10,6 +10,7 @@ #include "color.h" #include "reflog-walk.h" #include "gpg-interface.h" +#include "trailer.h" static char *user_format; static struct cmt_fmt_map { @@ -889,6 +890,16 @@ const char *format_subject(struct strbuf *sb, const char *msg, return msg; } +static void format_trailers(struct strbuf *sb, const char *msg) +{ + struct trailer_info info; + + trailer_info_get(&info, msg); + strbuf_add(sb, info.trailer_start, + info.trailer_end - info.trailer_start); + trailer_info_release(&info); +} + static void parse_commit_message(struct format_commit_context *c) { const char *msg = c->message + c->message_off; @@ -1292,6 +1303,12 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ strbuf_addstr(sb, msg + c->body_off); return 1; } + + if (starts_with(placeholder, "(trailers)")) { + format_trailers(sb, msg + c->subject_off); + return strlen("(trailers)"); + } + return 0; /* unknown placeholder */ } |