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>

Ævar Arnfjörð Bjarmason committed Jan 12, 2021 at 21:17 UTC c1fe7fd7e343517f743c3dc0d905f9f3083f66e7
1 file changed +30 -20
t/t4203-mailmap.sh
+30 -20
@@ -4,14 +4,6 @@ test_description='.mailmap configurations'
4
5 . ./test-lib.sh
6
7 -fuzz_blame () {
8 - sed "
9 - s/$_x05[0-9a-f][0-9a-f][0-9a-f]/OBJID/g
10 - s/$_x05[0-9a-f][0-9a-f]/OBJI/g
11 - s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
12 - " "$@"
13 -}
14 -
7 test_expect_success 'setup commits and contacts file' '
8 echo one >one &&
9 git add one &&
@@ -630,24 +622,42 @@ test_expect_success 'Only grep replaced author with --use-mailmap' '
622 test_must_be_empty actual
623 '
624
633 -test_expect_success 'Blame output (complex mapping)' '
625 +test_expect_success 'Blame --porcelain output (complex mapping)' '
626 test_config mailmap.file complex.map &&
627
628 cat >expect <<-EOF &&
637 - ^OBJI ($GIT_AUTHOR_NAME DATE 1) one
638 - OBJID (Some Dude DATE 2) two
639 - OBJID (Other Author DATE 3) three
640 - OBJID (Other Author DATE 4) four
641 - OBJID (Santa Claus DATE 5) five
642 - OBJID (Santa Claus DATE 6) six
643 - OBJID (CTO DATE 7) seven
644 - EOF
645 -
646 - git blame one >actual &&
647 - fuzz_blame actual >actual.fuzz &&
629 + 1 1 1
630 + A U Thor
631 + 2 2 1
632 + Some Dude
633 + 3 3 1
634 + Other Author
635 + 4 4 1
636 + Other Author
637 + 5 5 1
638 + Santa Claus
639 + 6 6 1
640 + Santa Claus
641 + 7 7 1
642 + CTO
643 + EOF
644 +
645 + git blame --porcelain one >actual.blame &&
646 + grep -E \
647 + -e "[0-9]+ [0-9]+ [0-9]+$" \
648 + -e "^author .*$" \
649 + actual.blame >actual.grep &&
650 + cut -d " " -f2-4 <actual.grep >actual.fuzz &&
651 test_cmp expect actual.fuzz
652 '
653
654 +test_expect_success 'Blame output (complex mapping)' '
655 + git -c mailmap.file=complex.map blame one >a &&
656 + git blame one >b &&
657 + test_file_not_empty a &&
658 + ! cmp a b
659 +'
660 +
661 test_expect_success 'commit --author honors mailmap' '
662 test_config mailmap.file complex.map &&
663