]>
Commit | Line | Data |
---|---|---|
ddafa7e9 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='Same rename detection as t4003 but testing diff-raw -z. | |
7 | ||
8 | ' | |
16d4bd4f ÆAB |
9 | |
10 | TEST_PASSES_SANITIZE_LEAK=true | |
ddafa7e9 | 11 | . ./test-lib.sh |
ebd73f50 | 12 | . "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash |
ddafa7e9 JH |
13 | |
14 | test_expect_success \ | |
15 | 'prepare reference tree' \ | |
15b808da | 16 | 'COPYING_test_data >COPYING && |
ddafa7e9 | 17 | echo frotz >rezrov && |
5be60078 | 18 | git update-index --add COPYING rezrov && |
0c37c41d | 19 | orig=$(git hash-object COPYING) && |
5be60078 | 20 | tree=$(git write-tree) && |
ddafa7e9 JH |
21 | echo $tree' |
22 | ||
23 | test_expect_success \ | |
24 | 'prepare work tree' \ | |
25 | 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && | |
26 | sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && | |
27 | rm -f COPYING && | |
0c37c41d | 28 | c1=$(git hash-object COPYING.1) && |
29 | c2=$(git hash-object COPYING.2) && | |
5be60078 | 30 | git update-index --add --remove COPYING COPYING.?' |
ddafa7e9 JH |
31 | |
32 | # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, | |
33 | # both are slightly edited, and unchanged rezrov. We say COPYING.1 | |
34 | # and COPYING.2 are based on COPYING, and do not say anything about | |
35 | # rezrov. | |
36 | ||
0940e5f2 | 37 | git diff-index -z -C $tree >current |
ddafa7e9 | 38 | |
0c37c41d | 39 | cat >expected <<EOF |
40 | :100644 100644 $orig $c1 C1234 | |
ddafa7e9 JH |
41 | COPYING |
42 | COPYING.1 | |
0c37c41d | 43 | :100644 100644 $orig $c2 R1234 |
ddafa7e9 JH |
44 | COPYING |
45 | COPYING.2 | |
46 | EOF | |
47 | ||
48 | test_expect_success \ | |
49 | 'validate output from rename/copy detection (#1)' \ | |
edb0c724 | 50 | 'compare_diff_raw_z current expected' |
ddafa7e9 | 51 | |
ddafa7e9 JH |
52 | ################################################################ |
53 | ||
54 | test_expect_success \ | |
55 | 'prepare work tree again' \ | |
56 | 'mv COPYING.2 COPYING && | |
5be60078 | 57 | git update-index --add --remove COPYING COPYING.1 COPYING.2' |
ddafa7e9 JH |
58 | |
59 | # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, | |
60 | # both are slightly edited, and unchanged rezrov. We say COPYING.1 | |
61 | # is based on COPYING and COPYING is still there, and do not say anything | |
62 | # about rezrov. | |
63 | ||
5be60078 | 64 | git diff-index -z -C $tree >current |
0c37c41d | 65 | cat >expected <<EOF |
66 | :100644 100644 $orig $c2 M | |
ddafa7e9 | 67 | COPYING |
0c37c41d | 68 | :100644 100644 $orig $c1 C1234 |
ddafa7e9 JH |
69 | COPYING |
70 | COPYING.1 | |
71 | EOF | |
72 | ||
73 | test_expect_success \ | |
74 | 'validate output from rename/copy detection (#2)' \ | |
edb0c724 | 75 | 'compare_diff_raw_z current expected' |
ddafa7e9 | 76 | |
ddafa7e9 JH |
77 | ################################################################ |
78 | ||
79 | # tree has COPYING and rezrov. work tree has the same COPYING and | |
80 | # copy-edited COPYING.1, and unchanged rezrov. We should not say | |
235e8d59 | 81 | # anything about rezrov or COPYING, since the revised again diff-raw |
ddafa7e9 JH |
82 | # nows how to say Copy. |
83 | ||
84 | test_expect_success \ | |
85 | 'prepare work tree once again' \ | |
15b808da | 86 | 'COPYING_test_data >COPYING && |
5be60078 | 87 | git update-index --add --remove COPYING COPYING.1' |
ddafa7e9 | 88 | |
5be60078 | 89 | git diff-index -z -C --find-copies-harder $tree >current |
0c37c41d | 90 | cat >expected <<EOF |
91 | :100644 100644 $orig $c1 C1234 | |
ddafa7e9 JH |
92 | COPYING |
93 | COPYING.1 | |
94 | EOF | |
95 | ||
96 | test_expect_success \ | |
97 | 'validate output from rename/copy detection (#3)' \ | |
edb0c724 | 98 | 'compare_diff_raw_z current expected' |
ddafa7e9 | 99 | |
ddafa7e9 | 100 | test_done |