4 The general idea is that we have a single file whose lines come from
5 multiple other files, and those individual files were modified in the same
6 commits. That means that we will see the same commit in multiple contexts,
7 and each one should be attributed to the correct file.
9 Note that we need to use "blame -C" to find the commit for all lines. We will
10 not bother testing that the non-C case fails to find it. That is how blame
11 behaves now, but it is not a property we want to make sure is retained.
14 TEST_PASSES_SANITIZE_LEAK
=true
17 # help avoid typing and reading long strings of similar lines
31 test_expect_success
'setup split file case' '
32 # use lines long enough to trigger content detection
33 test_seq 1000 1010 >one &&
34 test_seq 2000 2010 >two &&
38 sed "6s/^/modified /" <one >one.tmp &&
40 sed "6s/^/modified /" <two >two.tmp &&
43 test_commit modified &&
45 cat one two >combined &&
51 test_expect_success
'setup simulated porcelain' '
52 # This just reads porcelain-ish output and tries
53 # to output the value of a given field for each line (either by
54 # reading the field that accompanies this line, or referencing
55 # the information found last time the commit was mentioned).
56 cat >read-porcelain.pl <<-\EOF
59 if (/^[0-9a-f]{40,} /) {
62 } elsif (/^$field (.*)/) {
69 return unless defined $hash;
70 if (defined $cache{$hash}) {
71 print "$cache{$hash}\n";
79 for output
in porcelain line-porcelain
81 test_expect_success
"generate --$output output" '
82 git blame --root -C --$output combined >output
85 test_expect_success
"$output output finds correct commits" '
86 generate_expect >expect <<-\EOF &&
93 perl read-porcelain.pl summary <output >actual &&
94 test_cmp expect actual
97 test_expect_success
"$output output shows correct filenames" '
98 generate_expect >expect <<-\EOF &&
102 perl read-porcelain.pl filename <output >actual &&
103 test_cmp expect actual
106 test_expect_success
"$output output shows correct previous pointer" '
107 generate_expect >expect <<-EOF &&
109 1 $(git rev-parse modified^) one
111 1 $(git rev-parse modified^) two
114 perl read-porcelain.pl previous <output >actual &&
115 test_cmp expect actual