From d9b936db5226ed4b87d42a2c91324adc50c768b6 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Mon, 28 Jan 2019 22:33:35 +0100 Subject: pretty: add support for "valueonly" option in %(trailers) With the new "key=" option to %(trailers) it often makes little sense to show the key, as it by definition already is knows which trailer is printed there. This new "valueonly" option makes it omit the key when printing trailers. E.g.: $ git show -s --pretty='%s%n%(trailers:key=Signed-off-by,valueonly)' aaaa88182 will show: > upload-pack: fix broken if/else chain in config callback > Jeff King > Junio C Hamano Signed-off-by: Anders Waldenborg Signed-off-by: Junio C Hamano --- trailer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'trailer.c') diff --git a/trailer.c b/trailer.c index d6da555cd7..d0d9e91631 100644 --- a/trailer.c +++ b/trailer.c @@ -1150,8 +1150,10 @@ static void format_trailer_info(struct strbuf *out, 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); + if (!opts->value_only) + strbuf_addf(out, "%s: ", tok.buf); + strbuf_addbuf(out, &val); + strbuf_addch(out, '\n'); } strbuf_release(&tok); strbuf_release(&val); -- cgit v1.2.3