summaryrefslogtreecommitdiff
path: root/t/t4205-log-pretty-formats.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-08-15 10:25:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-08-15 18:13:58 (GMT)
commit58311c66fd316dff8f2c68a634ca0cf968227870 (patch)
tree64097b270164843eab9b680239a74f83a0586e45 /t/t4205-log-pretty-formats.sh
parentcc1735c4a3cf3377289640ce1af6b4c4523bee11 (diff)
downloadgit-58311c66fd316dff8f2c68a634ca0cf968227870.zip
git-58311c66fd316dff8f2c68a634ca0cf968227870.tar.gz
git-58311c66fd316dff8f2c68a634ca0cf968227870.tar.bz2
pretty: support normalization options for %(trailers)
The interpret-trailers command recently learned some options to make its output easier to parse (for a caller whose only interested in picking out the trailer values). But it's not very efficient for asking for the trailers of many commits in a single invocation. We already have "%(trailers)" to do that, but it doesn't know about unfolding or omitting non-trailers. Let's plumb those options through, so you can have the best of both. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4205-log-pretty-formats.sh')
-rwxr-xr-xt/t4205-log-pretty-formats.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 83ea85e..ec5f530 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -543,6 +543,10 @@ Signed-off-by: A U Thor
<author@example.com>
EOF
+unfold () {
+ perl -0pe 's/\n\s+/ /'
+}
+
test_expect_success 'set up trailer tests' '
echo "Some contents" >trailerfile &&
git add trailerfile &&
@@ -565,4 +569,33 @@ test_expect_success 'pretty format %(trailers) shows trailers' '
test_cmp expect actual
'
+test_expect_success '%(trailers:only) shows only "key: value" trailers' '
+ git log --no-walk --pretty="%(trailers:only)" >actual &&
+ {
+ grep -v patch.description <trailers &&
+ echo
+ } >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '%(trailers:unfold) unfolds trailers' '
+ git log --no-walk --pretty="%(trailers:unfold)" >actual &&
+ {
+ unfold <trailers &&
+ echo
+ } >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success ':only and :unfold work together' '
+ git log --no-walk --pretty="%(trailers:only:unfold)" >actual &&
+ git log --no-walk --pretty="%(trailers:unfold:only)" >reverse &&
+ test_cmp actual reverse &&
+ {
+ grep -v patch.description <trailers | unfold &&
+ echo
+ } >expect &&
+ test_cmp expect actual
+'
+
test_done