"Hariom Verma via GitGitGadget" [off-list ref] writes:
quoted hunk
+test_trailer_option() {
+ title="$1"
+ option="$2"
+ expect="$3"
+ test_expect_success "$title" '
+ printf "$expect\n" >expect &&
+ git for-each-ref --format="%($option)" refs/heads/main >actual &&
+ test_cmp expect actual &&
+ git for-each-ref --format="%(contents:$option)" refs/heads/main >actual &&
+ test_cmp expect actual
+ '
+}
+
+test_trailer_option '%(trailers:key=foo) shows that trailer' \
+ 'trailers:key=Signed-off-by' 'Signed-off-by: A U Thor <author@example.com>\n'
This is *not* an issue about the test script and its helper
function, but I just noticed that --format="%(trailers:key=<key>)"
is expected to write the matching trailers *AND* an empty line, and
I wonder if that is a sensible thing to expect.
The "--pretty" side does not give such an extra blank line after the
output, though.
$ git show -s --pretty=format:"%(trailers:key=Signed-off-by:)" \
js/range-diff-wo-dotdot
Signed-off-by: Johannes Schindelin [off-list ref]
Signed-off-by: Junio C Hamano [off-list ref]
$ git show -s --pretty=format:"%(trailers:key=None:)" \
js/range-diff-wo-dotdot
$ exit
Unlike the above, when there is no matching trailer lines, the
"for-each-ref" in this series shows zero lines, and when there is
one matching trailer line, it gives that single line plus an empty
line, two lines in total. The inconsistency is a bit disturbing.
Is the extra blank line given on purpose? I don't see why we would
want it. Or is it a bug we did not catch during the previous two
rounds of reviews?
Thanks.