]>
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 | ' | |
9 | . ./test-lib.sh | |
edb0c724 | 10 | . ../diff-lib.sh ;# test-lib chdir's into trash |
ddafa7e9 JH |
11 | |
12 | test_expect_success \ | |
13 | 'prepare reference tree' \ | |
14 | 'cat ../../COPYING >COPYING && | |
15 | echo frotz >rezrov && | |
215a7ad1 | 16 | git-update-index --add COPYING rezrov && |
ddafa7e9 JH |
17 | tree=$(git-write-tree) && |
18 | echo $tree' | |
19 | ||
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 && | |
215a7ad1 | 25 | git-update-index --add --remove COPYING COPYING.?' |
ddafa7e9 JH |
26 | |
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. | |
31 | ||
215a7ad1 | 32 | git-diff-index -z -M $tree >current |
ddafa7e9 JH |
33 | |
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 | |
42 | ||
43 | test_expect_success \ | |
44 | 'validate output from rename/copy detection (#1)' \ | |
edb0c724 | 45 | 'compare_diff_raw_z current expected' |
ddafa7e9 JH |
46 | |
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 | |
dc938417 LT |
60 | rename from COPYING |
61 | rename to COPYING.2 | |
ddafa7e9 JH |
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 | |
74 | ||
75 | test_expect_success \ | |
76 | 'validate output from diff-helper (#1)' \ | |
77 | 'compare_diff_patch current expected' | |
78 | ||
79 | ################################################################ | |
80 | ||
81 | test_expect_success \ | |
82 | 'prepare work tree again' \ | |
83 | 'mv COPYING.2 COPYING && | |
215a7ad1 | 84 | git-update-index --add --remove COPYING COPYING.1 COPYING.2' |
ddafa7e9 JH |
85 | |
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. | |
90 | ||
215a7ad1 | 91 | git-diff-index -z -C $tree >current |
ddafa7e9 JH |
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 | |
99 | ||
100 | test_expect_success \ | |
101 | 'validate output from rename/copy detection (#2)' \ | |
edb0c724 | 102 | 'compare_diff_raw_z current expected' |
ddafa7e9 JH |
103 | |
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 | |
128 | EOF | |
129 | ||
130 | test_expect_success \ | |
131 | 'validate output from diff-helper (#2)' \ | |
132 | 'compare_diff_patch current expected' | |
133 | ||
134 | ################################################################ | |
135 | ||
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. | |
140 | ||
141 | test_expect_success \ | |
142 | 'prepare work tree once again' \ | |
143 | 'cat ../../COPYING >COPYING && | |
215a7ad1 | 144 | git-update-index --add --remove COPYING COPYING.1' |
ddafa7e9 | 145 | |
215a7ad1 | 146 | git-diff-index -z -C --find-copies-harder $tree >current |
ddafa7e9 JH |
147 | cat >expected <<\EOF |
148 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 | |
149 | COPYING | |
150 | COPYING.1 | |
151 | EOF | |
152 | ||
153 | test_expect_success \ | |
154 | 'validate output from rename/copy detection (#3)' \ | |
edb0c724 | 155 | 'compare_diff_raw_z current expected' |
ddafa7e9 JH |
156 | |
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 | |
169 | EOF | |
170 | ||
171 | test_expect_success \ | |
172 | 'validate output from diff-helper (#3)' \ | |
173 | 'compare_diff_patch current expected' | |
174 | ||
175 | test_done |