mailmap tests: get rid of overly complex blame fuzzing

Change a test that used a custom fuzzing function since
bfdfa3d414 (t4203 (mailmap): stop hardcoding commit ids and dates,
2010-10-15) to just use the "blame --porcelain" output instead.

We could use the same pattern as 0ba9c9a0fb (t8008: rely on
rev-parse'd HEAD instead of sha1 value, 2017-07-26) does to do this,
but there wouldn't be any point. We're not trying to test "blame"
output here in general, just that "blame" pays attention to the
mailmap.

So it's sufficient to get the blamed line(s) and authors from the
output, which is much easier with the "--porcelain" option.

It would still be possible for there to be a bug in "blame" such that
it uses the mailmap for its "--porcelain" output, but not the regular
output. Let's test for that simply by checking if specifying the
mailmap changes the output.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2021-01-12 21:17:54 +01:00
committed by Junio C Hamano
parent 400d160e39
commit c1fe7fd7e3

View File

@ -4,14 +4,6 @@ test_description='.mailmap configurations'
. ./test-lib.sh . ./test-lib.sh
fuzz_blame () {
sed "
s/$_x05[0-9a-f][0-9a-f][0-9a-f]/OBJID/g
s/$_x05[0-9a-f][0-9a-f]/OBJI/g
s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
" "$@"
}
test_expect_success 'setup commits and contacts file' ' test_expect_success 'setup commits and contacts file' '
echo one >one && echo one >one &&
git add one && git add one &&
@ -630,24 +622,42 @@ test_expect_success 'Only grep replaced author with --use-mailmap' '
test_must_be_empty actual test_must_be_empty actual
' '
test_expect_success 'Blame output (complex mapping)' ' test_expect_success 'Blame --porcelain output (complex mapping)' '
test_config mailmap.file complex.map && test_config mailmap.file complex.map &&
cat >expect <<-EOF && cat >expect <<-EOF &&
^OBJI ($GIT_AUTHOR_NAME DATE 1) one 1 1 1
OBJID (Some Dude DATE 2) two A U Thor
OBJID (Other Author DATE 3) three 2 2 1
OBJID (Other Author DATE 4) four Some Dude
OBJID (Santa Claus DATE 5) five 3 3 1
OBJID (Santa Claus DATE 6) six Other Author
OBJID (CTO DATE 7) seven 4 4 1
Other Author
5 5 1
Santa Claus
6 6 1
Santa Claus
7 7 1
CTO
EOF EOF
git blame one >actual && git blame --porcelain one >actual.blame &&
fuzz_blame actual >actual.fuzz && grep -E \
-e "[0-9]+ [0-9]+ [0-9]+$" \
-e "^author .*$" \
actual.blame >actual.grep &&
cut -d " " -f2-4 <actual.grep >actual.fuzz &&
test_cmp expect actual.fuzz test_cmp expect actual.fuzz
' '
test_expect_success 'Blame output (complex mapping)' '
git -c mailmap.file=complex.map blame one >a &&
git blame one >b &&
test_file_not_empty a &&
! cmp a b
'
test_expect_success 'commit --author honors mailmap' ' test_expect_success 'commit --author honors mailmap' '
test_config mailmap.file complex.map && test_config mailmap.file complex.map &&