summaryrefslogtreecommitdiff
path: root/t/t6300-for-each-ref.sh
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2017-10-02 05:25:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-02 12:15:30 (GMT)
commit67a20a0010224255bbd5bb9fa4f95595c3e1ba7c (patch)
tree54015139e20f0cb39eba25ee2d9011aaa07f5356 /t/t6300-for-each-ref.sh
parent624b44d3763bd10e51fdcf66a205535140ca8539 (diff)
downloadgit-67a20a0010224255bbd5bb9fa4f95595c3e1ba7c.zip
git-67a20a0010224255bbd5bb9fa4f95595c3e1ba7c.tar.gz
git-67a20a0010224255bbd5bb9fa4f95595c3e1ba7c.tar.bz2
ref-filter.c: use trailer_opts to format trailers
Fill trailer_opts with "unfold" and "only" to match the sub-arguments given to the "%(trailers)" atom. Then, let's use the filled trailer_opts instance with 'format_trailers_from_commit' in order to format trailers in the desired manner. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6300-for-each-ref.sh')
-rwxr-xr-xt/t6300-for-each-ref.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 3943190..64a0d9e 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -610,6 +610,9 @@ Acked-by: A U Thor
<author@example.com>
EOF
+unfold () {
+ perl -0pe 's/\n\s+/ /g'
+}
test_expect_success 'set up trailers for next test' '
echo "Some contents" > two &&
@@ -623,6 +626,44 @@ test_expect_success 'set up trailers for next test' '
EOF
'
+test_expect_success '%(trailers:unfold) unfolds trailers' '
+ git for-each-ref --format="%(trailers:unfold)" refs/heads/master >actual &&
+ {
+ unfold <trailers
+ echo
+ } >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '%(trailers:only) shows only "key: value" trailers' '
+ git for-each-ref --format="%(trailers:only)" refs/heads/master >actual &&
+ {
+ grep -v patch.description <trailers &&
+ echo
+ } >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '%(trailers:only) and %(trailers:unfold) work together' '
+ git for-each-ref --format="%(trailers:only,unfold)" refs/heads/master >actual &&
+ git for-each-ref --format="%(trailers:unfold,only)" refs/heads/master >reverse &&
+ test_cmp actual reverse &&
+ {
+ grep -v patch.description <trailers | unfold &&
+ echo
+ } >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '%(trailers) rejects unknown trailers arguments' '
+ # error message cannot be checked under i18n
+ cat >expect <<-EOF &&
+ fatal: unknown %(trailers) argument: unsupported
+ EOF
+ test_must_fail git for-each-ref --format="%(trailers:unsupported)" 2>actual &&
+ test_i18ncmp expect actual
+'
+
test_expect_success 'basic atom: head contents:trailers' '
git for-each-ref --format="%(contents:trailers)" refs/heads/master >actual &&
sanitize_pgp <actual >actual.clean &&