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.
15 # help avoid typing and reading long strings of similar lines
29 test_expect_success
'setup split file case' '
30 # use lines long enough to trigger content detection
31 test_seq 1000 1010 >one &&
32 test_seq 2000 2010 >two &&
36 sed "6s/^/modified /" <one >one.tmp &&
38 sed "6s/^/modified /" <two >two.tmp &&
41 test_commit modified &&
43 cat one two >combined &&
49 test_expect_success
'setup simulated porcelain' '
50 # This just reads porcelain-ish output and tries
51 # to output the value of a given field for each line (either by
52 # reading the field that accompanies this line, or referencing
53 # the information found last time the commit was mentioned).
54 cat >read-porcelain.pl <<-\EOF
57 if (/^[0-9a-f]{40,} /) {
60 } elsif (/^$field (.*)/) {
67 return unless defined $hash;
68 if (defined $cache{$hash}) {
69 print "$cache{$hash}\n";
77 for output
in porcelain line-porcelain
79 test_expect_success
"generate --$output output" '
80 git blame --root -C --$output combined >output
83 test_expect_success
"$output output finds correct commits" '
84 generate_expect >expect <<-\EOF &&
91 perl read-porcelain.pl summary <output >actual &&
92 test_cmp expect actual
95 test_expect_success
"$output output shows correct filenames" '
96 generate_expect >expect <<-\EOF &&
100 perl read-porcelain.pl filename <output >actual &&
101 test_cmp expect actual
104 test_expect_success
"$output output shows correct previous pointer" '
105 generate_expect >expect <<-EOF &&
107 1 $(git rev-parse modified^) one
109 1 $(git rev-parse modified^) two
112 perl read-porcelain.pl previous <output >actual &&
113 test_cmp expect actual