diff options
author | Anders Waldenborg <anders@0x63.nu> | 2019-01-28 22:33:34 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-01-29 10:03:32 -0800 |
commit | 250bea0c1652ad546cd0455852bd734e4820ec46 (patch) | |
tree | 63046899319a3db38cb320d7faddf6d3cc91e63e /trailer.c | |
parent | 3e3f34781964c225ca199ac50527f3ce6feddb84 (diff) | |
download | git-250bea0c1652ad546cd0455852bd734e4820ec46.tar.gz |
pretty: allow showing specific trailers
Adds a new "key=X" option to "%(trailers)" which will cause it to only
print trailer lines which match any of the specified keys.
Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trailer.c')
-rw-r--r-- | trailer.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1132,7 +1132,7 @@ static void format_trailer_info(struct strbuf *out, size_t i; /* If we want the whole block untouched, we can take the fast path. */ - if (!opts->only_trailers && !opts->unfold) { + if (!opts->only_trailers && !opts->unfold && !opts->filter) { strbuf_add(out, info->trailer_start, info->trailer_end - info->trailer_start); return; @@ -1147,10 +1147,12 @@ static void format_trailer_info(struct strbuf *out, struct strbuf val = STRBUF_INIT; parse_trailer(&tok, &val, NULL, trailer, separator_pos); - if (opts->unfold) - unfold_value(&val); + if (!opts->filter || opts->filter(&tok, opts->filter_data)) { + if (opts->unfold) + unfold_value(&val); - strbuf_addf(out, "%s: %s\n", tok.buf, val.buf); + strbuf_addf(out, "%s: %s\n", tok.buf, val.buf); + } strbuf_release(&tok); strbuf_release(&val); |