]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t8003: check output of coalesced blame
authorJeff King <peff@peff.net>
Thu, 13 Aug 2020 05:23:05 +0000 (01:23 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Aug 2020 17:08:10 +0000 (10:08 -0700)
Commit f0cbe742f4 (blame: add a test to cover blame_coalesce(),
2019-06-20) added a test case where blame can usefully coalesce two
groups of lines. But since it relies on the normal blame output, it only
exercises the code and can't tell whether the lines were actually
joined into a single group.

However, by using --porcelain output, we can see how git-blame considers
the groupings (and likewise how the coalescing might have a real
user-visible impact for a tool that uses the porcelain-output
groupings). This lets us confirm that we are indeed coalescing correctly
(and the fact that this test case requires coalescing can be verified by
dropping the call to blame_coalesce(), causing the test to fail).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t8003-blame-corner-cases.sh

index 9130b887d2cc45db769e1e5cbb0ddb1c32cf4b39..7f0d4f7a9678d186bc4a39ab39b2d6272f81d3c9 100755 (executable)
@@ -274,10 +274,6 @@ test_expect_success 'blame file with CRLF core.autocrlf=true' '
        grep "A U Thor" actual
 '
 
-# Tests the splitting and merging of blame entries in blame_coalesce().
-# The output of blame is the same, regardless of whether blame_coalesce() runs
-# or not, so we'd likely only notice a problem if blame crashes or assigned
-# blame to the "splitting" commit ('SPLIT' below).
 test_expect_success 'blame coalesce' '
        cat >giraffe <<-\EOF &&
        ABC
@@ -303,10 +299,11 @@ test_expect_success 'blame coalesce' '
        git commit -m "same contents as original" &&
 
        cat >expect <<-EOF &&
-       $oid 1) ABC
-       $oid 2) DEF
+       $oid 1 1 2
+       $oid 2 2
        EOF
-       git -c core.abbrev=40 blame -s giraffe >actual &&
+       git blame --porcelain giraffe >actual.raw &&
+       grep "^$oid" actual.raw >actual &&
        test_cmp expect actual
 '