]>
Commit | Line | Data |
---|---|---|
f7c1512a 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. | |
7 | ||
8 | ' | |
9 | . ./test-lib.sh | |
edb0c724 | 10 | . ../diff-lib.sh ;# test-lib chdir's into trash |
b6d8f309 | 11 | |
f7c1512a JH |
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' | |
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 && | |
25 | git-update-cache --add --remove COPYING COPYING.?' | |
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 | ||
32 | git-diff-cache -M $tree >current | |
33 | ||
34 | cat >expected <<\EOF | |
b6d8f309 JH |
35 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 |
36 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234 COPYING COPYING.2 | |
f7c1512a JH |
37 | EOF |
38 | ||
39 | test_expect_success \ | |
b6d8f309 JH |
40 | 'validate output from rename/copy detection (#1)' \ |
41 | 'compare_diff_raw current expected' | |
42 | ||
43 | # make sure diff-helper can grok it. | |
44 | mv expected diff-raw | |
45 | GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current | |
46 | cat >expected <<\EOF | |
47 | diff --git a/COPYING b/COPYING.1 | |
48 | copy from COPYING | |
49 | copy to COPYING.1 | |
50 | --- a/COPYING | |
51 | +++ b/COPYING.1 | |
52 | @@ -6 +6 @@ | |
53 | - HOWEVER, in order to allow a migration to GPLv3 if that seems like | |
54 | + However, in order to allow a migration to GPLv3 if that seems like | |
55 | diff --git a/COPYING b/COPYING.2 | |
dc938417 LT |
56 | rename from COPYING |
57 | rename to COPYING.2 | |
b6d8f309 JH |
58 | --- a/COPYING |
59 | +++ b/COPYING.2 | |
60 | @@ -2 +2 @@ | |
61 | - Note that the only valid version of the GPL as far as this project | |
62 | + Note that the only valid version of the G.P.L as far as this project | |
63 | @@ -6 +6 @@ | |
64 | - HOWEVER, in order to allow a migration to GPLv3 if that seems like | |
65 | + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like | |
66 | @@ -12 +12 @@ | |
67 | - This file is licensed under the GPL v2, or a later version | |
68 | + This file is licensed under the G.P.L v2, or a later version | |
69 | EOF | |
70 | ||
71 | test_expect_success \ | |
72 | 'validate output from diff-helper (#1)' \ | |
73 | 'compare_diff_patch current expected' | |
74 | ||
75 | ################################################################ | |
f7c1512a JH |
76 | |
77 | test_expect_success \ | |
78 | 'prepare work tree again' \ | |
79 | 'mv COPYING.2 COPYING && | |
80 | git-update-cache --add --remove COPYING COPYING.1 COPYING.2' | |
81 | ||
82 | # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, | |
83 | # both are slightly edited, and unchanged rezrov. We say COPYING.1 | |
84 | # is based on COPYING and COPYING is still there, and do not say anything | |
85 | # about rezrov. | |
86 | ||
87 | git-diff-cache -C $tree >current | |
88 | cat >expected <<\EOF | |
b6d8f309 | 89 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M COPYING |
25d5ea41 | 90 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 |
f7c1512a JH |
91 | EOF |
92 | ||
93 | test_expect_success \ | |
b6d8f309 JH |
94 | 'validate output from rename/copy detection (#2)' \ |
95 | 'compare_diff_raw current expected' | |
f7c1512a | 96 | |
b6d8f309 JH |
97 | # make sure diff-helper can grok it. |
98 | mv expected diff-raw | |
99 | GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current | |
100 | cat >expected <<\EOF | |
b6d8f309 JH |
101 | diff --git a/COPYING b/COPYING |
102 | --- a/COPYING | |
103 | +++ b/COPYING | |
104 | @@ -2 +2 @@ | |
105 | - Note that the only valid version of the GPL as far as this project | |
106 | + Note that the only valid version of the G.P.L as far as this project | |
107 | @@ -6 +6 @@ | |
108 | - HOWEVER, in order to allow a migration to GPLv3 if that seems like | |
109 | + HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like | |
110 | @@ -12 +12 @@ | |
111 | - This file is licensed under the GPL v2, or a later version | |
112 | + This file is licensed under the G.P.L v2, or a later version | |
25d5ea41 JH |
113 | diff --git a/COPYING b/COPYING.1 |
114 | copy from COPYING | |
115 | copy to COPYING.1 | |
116 | --- a/COPYING | |
117 | +++ b/COPYING.1 | |
118 | @@ -6 +6 @@ | |
119 | - HOWEVER, in order to allow a migration to GPLv3 if that seems like | |
120 | + However, in order to allow a migration to GPLv3 if that seems like | |
b6d8f309 JH |
121 | EOF |
122 | ||
123 | test_expect_success \ | |
124 | 'validate output from diff-helper (#2)' \ | |
125 | 'compare_diff_patch current expected' | |
126 | ||
127 | ################################################################ | |
128 | ||
f7c1512a | 129 | # tree has COPYING and rezrov. work tree has the same COPYING and |
bceafe75 JH |
130 | # copy-edited COPYING.1, and unchanged rezrov. We should not say |
131 | # anything about rezrov nor COPYING, since the revised again diff-raw | |
132 | # nows how to say Copy. | |
f7c1512a | 133 | |
ddafa7e9 JH |
134 | test_expect_success \ |
135 | 'prepare work tree once again' \ | |
136 | 'cat ../../COPYING >COPYING && | |
137 | git-update-cache --add --remove COPYING COPYING.1' | |
138 | ||
4727f640 | 139 | git-diff-cache -C --find-copies-harder $tree >current |
f7c1512a | 140 | cat >expected <<\EOF |
b6d8f309 | 141 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 |
b6d8f309 JH |
142 | EOF |
143 | ||
144 | test_expect_success \ | |
145 | 'validate output from rename/copy detection (#3)' \ | |
146 | 'compare_diff_raw current expected' | |
147 | ||
148 | # make sure diff-helper can grok it. | |
149 | mv expected diff-raw | |
150 | GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current | |
151 | cat >expected <<\EOF | |
152 | diff --git a/COPYING b/COPYING.1 | |
153 | copy from COPYING | |
154 | copy to COPYING.1 | |
155 | --- a/COPYING | |
156 | +++ b/COPYING.1 | |
157 | @@ -6 +6 @@ | |
158 | - HOWEVER, in order to allow a migration to GPLv3 if that seems like | |
159 | + However, in order to allow a migration to GPLv3 if that seems like | |
f7c1512a JH |
160 | EOF |
161 | ||
162 | test_expect_success \ | |
b6d8f309 JH |
163 | 'validate output from diff-helper (#3)' \ |
164 | 'compare_diff_patch current expected' | |
f7c1512a JH |
165 | |
166 | test_done |