]>
Commit | Line | Data |
---|---|---|
f7c1512a JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
68241cb9 | 6 | test_description='Same rename detection as t4003 but testing diff-raw.' |
f7c1512a | 7 | |
f7c1512a | 8 | . ./test-lib.sh |
bfdbee98 | 9 | . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash |
b6d8f309 | 10 | |
68241cb9 SB |
11 | test_expect_success 'setup reference tree' ' |
12 | cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING && | |
13 | echo frotz >rezrov && | |
14 | git update-index --add COPYING rezrov && | |
15 | tree=$(git write-tree) && | |
16 | echo $tree && | |
c76b84a1 MÅ |
17 | sed -e "s/HOWEVER/However/" <COPYING >COPYING.1 && |
18 | sed -e "s/GPL/G.P.L/g" <COPYING >COPYING.2 && | |
68241cb9 SB |
19 | origoid=$(git hash-object COPYING) && |
20 | oid1=$(git hash-object COPYING.1) && | |
21 | oid2=$(git hash-object COPYING.2) | |
22 | ' | |
f7c1512a | 23 | |
68241cb9 | 24 | ################################################################ |
f7c1512a JH |
25 | # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, |
26 | # both are slightly edited, and unchanged rezrov. We say COPYING.1 | |
27 | # and COPYING.2 are based on COPYING, and do not say anything about | |
28 | # rezrov. | |
29 | ||
68241cb9 SB |
30 | test_expect_success 'validate output from rename/copy detection (#1)' ' |
31 | rm -f COPYING && | |
32 | git update-index --add --remove COPYING COPYING.? && | |
f7c1512a | 33 | |
68241cb9 SB |
34 | cat <<-EOF >expected && |
35 | :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1 | |
36 | :100644 100644 $origoid $oid2 R1234 COPYING COPYING.2 | |
37 | EOF | |
38 | git diff-index -C $tree >current && | |
39 | compare_diff_raw expected current | |
40 | ' | |
b6d8f309 | 41 | |
b6d8f309 | 42 | ################################################################ |
f7c1512a JH |
43 | # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, |
44 | # both are slightly edited, and unchanged rezrov. We say COPYING.1 | |
45 | # is based on COPYING and COPYING is still there, and do not say anything | |
46 | # about rezrov. | |
47 | ||
68241cb9 SB |
48 | test_expect_success 'validate output from rename/copy detection (#2)' ' |
49 | mv COPYING.2 COPYING && | |
50 | git update-index --add --remove COPYING COPYING.1 COPYING.2 && | |
f7c1512a | 51 | |
68241cb9 SB |
52 | cat <<-EOF >expected && |
53 | :100644 100644 $origoid $oid2 M COPYING | |
54 | :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1 | |
55 | EOF | |
56 | git diff-index -C $tree >current && | |
57 | compare_diff_raw current expected | |
58 | ' | |
f7c1512a | 59 | |
b6d8f309 | 60 | ################################################################ |
f7c1512a | 61 | # tree has COPYING and rezrov. work tree has the same COPYING and |
bceafe75 | 62 | # copy-edited COPYING.1, and unchanged rezrov. We should not say |
235e8d59 | 63 | # anything about rezrov or COPYING, since the revised again diff-raw |
bceafe75 | 64 | # nows how to say Copy. |
f7c1512a | 65 | |
68241cb9 SB |
66 | test_expect_success 'validate output from rename/copy detection (#3)' ' |
67 | cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING && | |
68 | git update-index --add --remove COPYING COPYING.1 && | |
b6d8f309 | 69 | |
68241cb9 SB |
70 | cat <<-EOF >expected && |
71 | :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1 | |
72 | EOF | |
73 | git diff-index -C --find-copies-harder $tree >current && | |
74 | compare_diff_raw current expected | |
75 | ' | |
b6d8f309 | 76 | |
f7c1512a | 77 | test_done |