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