Update SubmittingPatches.
[git/gitweb.git] / t / t4009-diff-rename-4.sh
blob6229a5bf1a9b82a2e64510d3ec9f9817d0dd0e0e
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Same rename detection as t4003 but testing diff-raw -z.
9 . ./test-lib.sh
10 . ../diff-lib.sh ;# test-lib chdir's into trash
12 test_expect_success \
13 'prepare reference tree' \
14 'cat ../../COPYING >COPYING &&
15 echo frotz >rezrov &&
16 git-update-cache --add COPYING rezrov &&
17 tree=$(git-write-tree) &&
18 echo $tree'
20 test_expect_success \
21 'prepare work tree' \
22 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
23 sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
24 rm -f COPYING &&
25 git-update-cache --add --remove COPYING COPYING.?'
27 # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
28 # both are slightly edited, and unchanged rezrov. We say COPYING.1
29 # and COPYING.2 are based on COPYING, and do not say anything about
30 # rezrov.
32 git-diff-cache -z -M $tree >current
34 cat >expected <<\EOF
35 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
36 COPYING
37 COPYING.1
38 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234
39 COPYING
40 COPYING.2
41 EOF
43 test_expect_success \
44 'validate output from rename/copy detection (#1)' \
45 'compare_diff_raw_z current expected'
47 # make sure diff-helper can grok it.
48 mv current diff-raw
49 GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
50 cat >expected <<\EOF
51 diff --git a/COPYING b/COPYING.1
52 copy from COPYING
53 copy to COPYING.1
54 --- a/COPYING
55 +++ b/COPYING.1
56 @@ -6 +6 @@
57 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
58 + However, in order to allow a migration to GPLv3 if that seems like
59 diff --git a/COPYING b/COPYING.2
60 rename from COPYING
61 rename to COPYING.2
62 --- a/COPYING
63 +++ b/COPYING.2
64 @@ -2 +2 @@
65 - Note that the only valid version of the GPL as far as this project
66 + Note that the only valid version of the G.P.L as far as this project
67 @@ -6 +6 @@
68 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
69 + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
70 @@ -12 +12 @@
71 - This file is licensed under the GPL v2, or a later version
72 + This file is licensed under the G.P.L v2, or a later version
73 EOF
75 test_expect_success \
76 'validate output from diff-helper (#1)' \
77 'compare_diff_patch current expected'
79 ################################################################
81 test_expect_success \
82 'prepare work tree again' \
83 'mv COPYING.2 COPYING &&
84 git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
86 # tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
87 # both are slightly edited, and unchanged rezrov. We say COPYING.1
88 # is based on COPYING and COPYING is still there, and do not say anything
89 # about rezrov.
91 git-diff-cache -z -C $tree >current
92 cat >expected <<\EOF
93 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M
94 COPYING
95 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
96 COPYING
97 COPYING.1
98 EOF
100 test_expect_success \
101 'validate output from rename/copy detection (#2)' \
102 'compare_diff_raw_z current expected'
104 # make sure diff-helper can grok it.
105 mv current diff-raw
106 GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
107 cat >expected <<\EOF
108 diff --git a/COPYING b/COPYING
109 --- a/COPYING
110 +++ b/COPYING
111 @@ -2 +2 @@
112 - Note that the only valid version of the GPL as far as this project
113 + Note that the only valid version of the G.P.L as far as this project
114 @@ -6 +6 @@
115 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
116 + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
117 @@ -12 +12 @@
118 - This file is licensed under the GPL v2, or a later version
119 + This file is licensed under the G.P.L v2, or a later version
120 diff --git a/COPYING b/COPYING.1
121 copy from COPYING
122 copy to COPYING.1
123 --- a/COPYING
124 +++ b/COPYING.1
125 @@ -6 +6 @@
126 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
127 + However, in order to allow a migration to GPLv3 if that seems like
130 test_expect_success \
131 'validate output from diff-helper (#2)' \
132 'compare_diff_patch current expected'
134 ################################################################
136 # tree has COPYING and rezrov. work tree has the same COPYING and
137 # copy-edited COPYING.1, and unchanged rezrov. We should not say
138 # anything about rezrov nor COPYING, since the revised again diff-raw
139 # nows how to say Copy.
141 test_expect_success \
142 'prepare work tree once again' \
143 'cat ../../COPYING >COPYING &&
144 git-update-cache --add --remove COPYING COPYING.1'
146 git-diff-cache -z -C --find-copies-harder $tree >current
147 cat >expected <<\EOF
148 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
149 COPYING
150 COPYING.1
153 test_expect_success \
154 'validate output from rename/copy detection (#3)' \
155 'compare_diff_raw_z current expected'
157 # make sure diff-helper can grok it.
158 mv current diff-raw
159 GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
160 cat >expected <<\EOF
161 diff --git a/COPYING b/COPYING.1
162 copy from COPYING
163 copy to COPYING.1
164 --- a/COPYING
165 +++ b/COPYING.1
166 @@ -6 +6 @@
167 - HOWEVER, in order to allow a migration to GPLv3 if that seems like
168 + However, in order to allow a migration to GPLv3 if that seems like
171 test_expect_success \
172 'validate output from diff-helper (#3)' \
173 'compare_diff_patch current expected'
175 test_done