3 # Copyright (c) 2005 Junio C Hamano
6 test_description
='Same rename detection as t4003 but testing diff-raw -z.
10 TEST_PASSES_SANITIZE_LEAK
=true
12 .
"$TEST_DIRECTORY"/lib-diff.sh
;# test-lib chdir's into trash
15 'prepare reference tree' \
16 'COPYING_test_data >COPYING &&
18 git update-index --add COPYING rezrov &&
19 orig=$(git hash-object COPYING) &&
20 tree=$(git write-tree) &&
25 'sed -e 's
/HOWEVER
/However
/' <COPYING >COPYING.1 &&
26 sed -e 's
/GPL
/G.P.L
/g
' <COPYING >COPYING.2 &&
28 c1=$(git hash-object COPYING.1) &&
29 c2=$(git hash-object COPYING.2) &&
30 git update-index --add --remove COPYING COPYING.?'
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
37 git diff-index
-z -C $tree >current
40 :100644 100644 $orig $c1 C1234
43 :100644 100644 $orig $c2 R1234
49 'validate output from rename/copy detection (#1)' \
50 'compare_diff_raw_z current expected'
52 ################################################################
55 'prepare work tree again' \
56 'mv COPYING.2 COPYING &&
57 git update-index --add --remove COPYING COPYING.1 COPYING.2'
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
64 git diff-index
-z -C $tree >current
66 :100644 100644 $orig $c2 M
68 :100644 100644 $orig $c1 C1234
74 'validate output from rename/copy detection (#2)' \
75 'compare_diff_raw_z current expected'
77 ################################################################
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
81 # anything about rezrov or COPYING, since the revised again diff-raw
82 # nows how to say Copy.
85 'prepare work tree once again' \
86 'COPYING_test_data >COPYING &&
87 git update-index --add --remove COPYING COPYING.1'
89 git diff-index
-z -C --find-copies-harder $tree >current
91 :100644 100644 $orig $c1 C1234
97 'validate output from rename/copy detection (#3)' \
98 'compare_diff_raw_z current expected'