mirror of
https://github.com/git/git
synced 2024-09-29 21:27:13 +00:00
shortlog: add test for de-duplicating folded trailers
The shortlog builtin was taught to use the trailer iterator interface in47beb37bc6
(shortlog: match commit trailers with --group, 2020-09-27). The iterator always unfolds values and this has always been the case since the time the iterator was first introduced inf0939a0eb1
(trailer: add interface for iterating over commit trailers, 2020-09-27). Add a comment line to remind readers of this behavior. The fact that the iterator always unfolds values is important (at least for shortlog) because unfolding allows it to recognize both folded and unfolded versions of the same trailer for de-duplication. Capture the existing behavior in a new test case to guard against regressions in this area. This test case is based off of the existing "shortlog de-duplicates trailers in a single commit" just above it. Now if we were to remove the call to unfold_value(&iter->val); inside the iterator, this new test case will break. Signed-off-by: Linus Arver <linusa@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
0f3a461d4e
commit
a082e28938
|
@ -312,6 +312,38 @@ test_expect_success 'shortlog de-duplicates trailers in a single commit' '
|
|||
test_cmp expect actual
|
||||
'
|
||||
|
||||
# Trailers that have unfolded (single line) and folded (multiline) values which
|
||||
# are otherwise identical are treated as the same trailer for de-duplication.
|
||||
test_expect_success 'shortlog de-duplicates trailers in a single commit (folded/unfolded values)' '
|
||||
git commit --allow-empty -F - <<-\EOF &&
|
||||
subject one
|
||||
|
||||
this message has two distinct values, plus a repeat (folded)
|
||||
|
||||
Repeated-trailer: Foo foo foo
|
||||
Repeated-trailer: Bar
|
||||
Repeated-trailer: Foo
|
||||
foo foo
|
||||
EOF
|
||||
|
||||
git commit --allow-empty -F - <<-\EOF &&
|
||||
subject two
|
||||
|
||||
similar to the previous, but without the second distinct value
|
||||
|
||||
Repeated-trailer: Foo foo foo
|
||||
Repeated-trailer: Foo
|
||||
foo foo
|
||||
EOF
|
||||
|
||||
cat >expect <<-\EOF &&
|
||||
2 Foo foo foo
|
||||
1 Bar
|
||||
EOF
|
||||
git shortlog -ns --group=trailer:repeated-trailer -2 HEAD >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'shortlog can match multiple groups' '
|
||||
git commit --allow-empty -F - <<-\EOF &&
|
||||
subject one
|
||||
|
|
Loading…
Reference in a new issue