summaryrefslogtreecommitdiff
path: root/trailer.c
diff options
context:
space:
mode:
authorAnders Waldenborg <anders@0x63.nu>2019-01-28 22:33:34 +0100
committerJunio C Hamano <gitster@pobox.com>2019-01-29 10:03:32 -0800
commit250bea0c1652ad546cd0455852bd734e4820ec46 (patch)
tree63046899319a3db38cb320d7faddf6d3cc91e63e /trailer.c
parent3e3f34781964c225ca199ac50527f3ce6feddb84 (diff)
downloadgit-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.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/trailer.c b/trailer.c
index 0796f326b3..d6da555cd7 100644
--- a/trailer.c
+++ b/trailer.c
@@ -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);