3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Same rename detection as t4003 but testing diff-raw -z.
11 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
12 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
13 sanitize_diff_raw='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/'
15 # When heuristics are improved, the score numbers would change.
16 # Ignore them while comparing.
17 # Also we do not check SHA1 hash generation in this test, which
18 # is a job for t0000-basic.sh
20 tr '\0' '\012' <"$1" | sed -e "$sanitize_diff_raw" >.tmp-1
21 tr '\0' '\012' <"$2" | sed -e "$sanitize_diff_raw" >.tmp-2
22 diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
25 compare_diff_patch () {
26 # When heuristics are improved, the score numbers would change.
27 # Ignore them while comparing.
28 sed -e '/^similarity index [0-9]*%$/d' <"$1" >.tmp-1
29 sed -e '/^similarity index [0-9]*%$/d' <"$2" >.tmp-2
30 diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
34 'prepare reference tree' \
35 'cat ../../COPYING >COPYING &&
37 git-update-cache --add COPYING rezrov &&
38 tree=$(git-write-tree) &&
43 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
44 sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
46 git-update-cache --add --remove COPYING COPYING.?'
48 # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
49 # both are slightly edited, and unchanged rezrov. We say COPYING.1
50 # and COPYING.2 are based on COPYING, and do not say anything about
53 git-diff-cache -z -M $tree >current
56 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
59 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234
65 'validate output from rename/copy detection (#1)' \
66 'compare_diff_raw current expected'
68 # make sure diff-helper can grok it.
70 GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
72 diff --git a/COPYING b/COPYING.1
78 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
79 + However, in order to allow a migration to GPLv3 if that seems like
80 diff --git a/COPYING b/COPYING.2
86 - Note that the only valid version of the GPL as far as this project
87 + Note that the only valid version of the G.P.L as far as this project
89 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
90 + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
92 - This file is licensed under the GPL v2, or a later version
93 + This file is licensed under the G.P.L v2, or a later version
97 'validate output from diff-helper (#1)' \
98 'compare_diff_patch current expected'
100 ################################################################
102 test_expect_success \
103 'prepare work tree again' \
104 'mv COPYING.2 COPYING &&
105 git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
107 # tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
108 # both are slightly edited, and unchanged rezrov. We say COPYING.1
109 # is based on COPYING and COPYING is still there, and do not say anything
112 git-diff-cache -z -C $tree >current
114 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M
116 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
121 test_expect_success \
122 'validate output from rename/copy detection (#2)' \
123 'compare_diff_raw current expected'
125 # make sure diff-helper can grok it.
127 GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
129 diff --git a/COPYING b/COPYING
133 - Note that the only valid version of the GPL as far as this project
134 + Note that the only valid version of the G.P.L as far as this project
136 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
137 + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
139 - This file is licensed under the GPL v2, or a later version
140 + This file is licensed under the G.P.L v2, or a later version
141 diff --git a/COPYING b/COPYING.1
147 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
148 + However, in order to allow a migration to GPLv3 if that seems like
151 test_expect_success \
152 'validate output from diff-helper (#2)' \
153 'compare_diff_patch current expected'
155 ################################################################
157 # tree has COPYING and rezrov. work tree has the same COPYING and
158 # copy-edited COPYING.1, and unchanged rezrov. We should not say
159 # anything about rezrov nor COPYING, since the revised again diff-raw
160 # nows how to say Copy.
162 test_expect_success \
163 'prepare work tree once again' \
164 'cat ../../COPYING >COPYING &&
165 git-update-cache --add --remove COPYING COPYING.1'
167 git-diff-cache -z -C $tree >current
169 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
174 test_expect_success \
175 'validate output from rename/copy detection (#3)' \
176 'compare_diff_raw current expected'
178 # make sure diff-helper can grok it.
180 GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
182 diff --git a/COPYING b/COPYING.1
188 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
189 + However, in order to allow a migration to GPLv3 if that seems like
192 test_expect_success \
193 'validate output from diff-helper (#3)' \
194 'compare_diff_patch current expected'