l10n: de.po: translate 13 new messages
[alt-git.git] / t / t4027-diff-submodule.sh
blob518bf9524e0b55181f3c440d202b69c12a0b314f
1 #!/bin/sh
3 test_description='difference in submodules'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/diff-lib.sh
8 test_expect_success setup '
9 test_tick &&
10 test_create_repo sub &&
12 cd sub &&
13 echo hello >world &&
14 git add world &&
15 git commit -m submodule
16 ) &&
18 test_tick &&
19 echo frotz >nitfol &&
20 git add nitfol sub &&
21 git commit -m superproject &&
24 cd sub &&
25 echo goodbye >world &&
26 git add world &&
27 git commit -m "submodule #2"
28 ) &&
30 set x $(
31 cd sub &&
32 git rev-list HEAD
33 ) &&
34 echo ":160000 160000 $3 $_z40 M sub" >expect &&
35 subtip=$3 subprev=$2
38 test_expect_success 'git diff --raw HEAD' '
39 git diff --raw --abbrev=40 HEAD >actual &&
40 test_cmp expect actual
43 test_expect_success 'git diff-index --raw HEAD' '
44 git diff-index --raw HEAD >actual.index &&
45 test_cmp expect actual.index
48 test_expect_success 'git diff-files --raw' '
49 git diff-files --raw >actual.files &&
50 test_cmp expect actual.files
53 expect_from_to () {
54 printf "%sSubproject commit %s\n+Subproject commit %s\n" \
55 "-" "$1" "$2"
58 test_expect_success 'git diff HEAD' '
59 git diff HEAD >actual &&
60 sed -e "1,/^@@/d" actual >actual.body &&
61 expect_from_to >expect.body $subtip $subprev &&
62 test_cmp expect.body actual.body
65 test_expect_success 'git diff HEAD with dirty submodule (work tree)' '
66 echo >>sub/world &&
67 git diff HEAD >actual &&
68 sed -e "1,/^@@/d" actual >actual.body &&
69 expect_from_to >expect.body $subtip $subprev-dirty &&
70 test_cmp expect.body actual.body
73 test_expect_success 'git diff HEAD with dirty submodule (index)' '
75 cd sub &&
76 git reset --hard &&
77 echo >>world &&
78 git add world
79 ) &&
80 git diff HEAD >actual &&
81 sed -e "1,/^@@/d" actual >actual.body &&
82 expect_from_to >expect.body $subtip $subprev-dirty &&
83 test_cmp expect.body actual.body
86 test_expect_success 'git diff HEAD with dirty submodule (untracked)' '
88 cd sub &&
89 git reset --hard &&
90 git clean -qfdx &&
91 >cruft
92 ) &&
93 git diff HEAD >actual &&
94 sed -e "1,/^@@/d" actual >actual.body &&
95 expect_from_to >expect.body $subtip $subprev-dirty &&
96 test_cmp expect.body actual.body
99 test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)' '
100 git commit -m "x" sub &&
101 echo >>sub/world &&
102 git diff HEAD >actual &&
103 sed -e "1,/^@@/d" actual >actual.body &&
104 expect_from_to >expect.body $subprev $subprev-dirty &&
105 test_cmp expect.body actual.body &&
106 git diff --ignore-submodules HEAD >actual2 &&
107 ! test -s actual2 &&
108 git diff --ignore-submodules=untracked HEAD >actual3 &&
109 sed -e "1,/^@@/d" actual3 >actual3.body &&
110 expect_from_to >expect.body $subprev $subprev-dirty &&
111 test_cmp expect.body actual3.body &&
112 git diff --ignore-submodules=dirty HEAD >actual4 &&
113 ! test -s actual4
116 test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) [.git/config]' '
117 git config diff.ignoreSubmodules all &&
118 git diff HEAD >actual &&
119 ! test -s actual &&
120 git config submodule.subname.ignore none &&
121 git config submodule.subname.path sub &&
122 git diff HEAD >actual &&
123 sed -e "1,/^@@/d" actual >actual.body &&
124 expect_from_to >expect.body $subprev $subprev-dirty &&
125 test_cmp expect.body actual.body &&
126 git config submodule.subname.ignore all &&
127 git diff HEAD >actual2 &&
128 ! test -s actual2 &&
129 git config submodule.subname.ignore untracked &&
130 git diff HEAD >actual3 &&
131 sed -e "1,/^@@/d" actual3 >actual3.body &&
132 expect_from_to >expect.body $subprev $subprev-dirty &&
133 test_cmp expect.body actual3.body &&
134 git config submodule.subname.ignore dirty &&
135 git diff HEAD >actual4 &&
136 ! test -s actual4 &&
137 git diff HEAD --ignore-submodules=none >actual &&
138 sed -e "1,/^@@/d" actual >actual.body &&
139 expect_from_to >expect.body $subprev $subprev-dirty &&
140 test_cmp expect.body actual.body &&
141 git config --remove-section submodule.subname &&
142 git config --unset diff.ignoreSubmodules
145 test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) [.gitmodules]' '
146 git config diff.ignoreSubmodules dirty &&
147 git diff HEAD >actual &&
148 ! test -s actual &&
149 git config --add -f .gitmodules submodule.subname.ignore none &&
150 git config --add -f .gitmodules submodule.subname.path sub &&
151 git diff HEAD >actual &&
152 sed -e "1,/^@@/d" actual >actual.body &&
153 expect_from_to >expect.body $subprev $subprev-dirty &&
154 test_cmp expect.body actual.body &&
155 git config -f .gitmodules submodule.subname.ignore all &&
156 git config -f .gitmodules submodule.subname.path sub &&
157 git diff HEAD >actual2 &&
158 ! test -s actual2 &&
159 git config -f .gitmodules submodule.subname.ignore untracked &&
160 git diff HEAD >actual3 &&
161 sed -e "1,/^@@/d" actual3 >actual3.body &&
162 expect_from_to >expect.body $subprev $subprev-dirty &&
163 test_cmp expect.body actual3.body &&
164 git config -f .gitmodules submodule.subname.ignore dirty &&
165 git diff HEAD >actual4 &&
166 ! test -s actual4 &&
167 git config submodule.subname.ignore none &&
168 git config submodule.subname.path sub &&
169 git diff HEAD >actual &&
170 sed -e "1,/^@@/d" actual >actual.body &&
171 expect_from_to >expect.body $subprev $subprev-dirty &&
172 test_cmp expect.body actual.body &&
173 git config --remove-section submodule.subname &&
174 git config --remove-section -f .gitmodules submodule.subname &&
175 git config --unset diff.ignoreSubmodules &&
176 rm .gitmodules
179 test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '
181 cd sub &&
182 git reset --hard &&
183 echo >>world &&
184 git add world
185 ) &&
186 git diff HEAD >actual &&
187 sed -e "1,/^@@/d" actual >actual.body &&
188 expect_from_to >expect.body $subprev $subprev-dirty &&
189 test_cmp expect.body actual.body
192 test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)' '
194 cd sub &&
195 git reset --hard &&
196 git clean -qfdx &&
197 >cruft
198 ) &&
199 git diff HEAD >actual &&
200 sed -e "1,/^@@/d" actual >actual.body &&
201 expect_from_to >expect.body $subprev $subprev-dirty &&
202 test_cmp expect.body actual.body &&
203 git diff --ignore-submodules=all HEAD >actual2 &&
204 ! test -s actual2 &&
205 git diff --ignore-submodules=untracked HEAD >actual3 &&
206 ! test -s actual3 &&
207 git diff --ignore-submodules=dirty HEAD >actual4 &&
208 ! test -s actual4
211 test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match) [.git/config]' '
212 git config submodule.subname.ignore all &&
213 git config submodule.subname.path sub &&
214 git diff HEAD >actual2 &&
215 ! test -s actual2 &&
216 git config submodule.subname.ignore untracked &&
217 git diff HEAD >actual3 &&
218 ! test -s actual3 &&
219 git config submodule.subname.ignore dirty &&
220 git diff HEAD >actual4 &&
221 ! test -s actual4 &&
222 git diff --ignore-submodules=none HEAD >actual &&
223 sed -e "1,/^@@/d" actual >actual.body &&
224 expect_from_to >expect.body $subprev $subprev-dirty &&
225 test_cmp expect.body actual.body &&
226 git config --remove-section submodule.subname
229 test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match) [.gitmodules]' '
230 git config --add -f .gitmodules submodule.subname.ignore all &&
231 git config --add -f .gitmodules submodule.subname.path sub &&
232 git diff HEAD >actual2 &&
233 ! test -s actual2 &&
234 git config -f .gitmodules submodule.subname.ignore untracked &&
235 git diff HEAD >actual3 &&
236 ! test -s actual3 &&
237 git config -f .gitmodules submodule.subname.ignore dirty &&
238 git diff HEAD >actual4 &&
239 ! test -s actual4 &&
240 git config submodule.subname.ignore none &&
241 git config submodule.subname.path sub &&
242 git diff HEAD >actual &&
243 sed -e "1,/^@@/d" actual >actual.body &&
244 expect_from_to >expect.body $subprev $subprev-dirty &&
245 test_cmp expect.body actual.body &&
246 git config --remove-section submodule.subname &&
247 git config --remove-section -f .gitmodules submodule.subname &&
248 rm .gitmodules
251 test_expect_success 'git diff between submodule commits' '
252 git diff HEAD^..HEAD >actual &&
253 sed -e "1,/^@@/d" actual >actual.body &&
254 expect_from_to >expect.body $subtip $subprev &&
255 test_cmp expect.body actual.body &&
256 git diff --ignore-submodules=dirty HEAD^..HEAD >actual &&
257 sed -e "1,/^@@/d" actual >actual.body &&
258 expect_from_to >expect.body $subtip $subprev &&
259 test_cmp expect.body actual.body &&
260 git diff --ignore-submodules HEAD^..HEAD >actual &&
261 ! test -s actual
264 test_expect_success 'git diff between submodule commits [.git/config]' '
265 git diff HEAD^..HEAD >actual &&
266 sed -e "1,/^@@/d" actual >actual.body &&
267 expect_from_to >expect.body $subtip $subprev &&
268 test_cmp expect.body actual.body &&
269 git config submodule.subname.ignore dirty &&
270 git config submodule.subname.path sub &&
271 git diff HEAD^..HEAD >actual &&
272 sed -e "1,/^@@/d" actual >actual.body &&
273 expect_from_to >expect.body $subtip $subprev &&
274 test_cmp expect.body actual.body &&
275 git config submodule.subname.ignore all &&
276 git diff HEAD^..HEAD >actual &&
277 ! test -s actual &&
278 git diff --ignore-submodules=dirty HEAD^..HEAD >actual &&
279 sed -e "1,/^@@/d" actual >actual.body &&
280 expect_from_to >expect.body $subtip $subprev &&
281 git config --remove-section submodule.subname
284 test_expect_success 'git diff between submodule commits [.gitmodules]' '
285 git diff HEAD^..HEAD >actual &&
286 sed -e "1,/^@@/d" actual >actual.body &&
287 expect_from_to >expect.body $subtip $subprev &&
288 test_cmp expect.body actual.body &&
289 git config --add -f .gitmodules submodule.subname.ignore dirty &&
290 git config --add -f .gitmodules submodule.subname.path sub &&
291 git diff HEAD^..HEAD >actual &&
292 sed -e "1,/^@@/d" actual >actual.body &&
293 expect_from_to >expect.body $subtip $subprev &&
294 test_cmp expect.body actual.body &&
295 git config -f .gitmodules submodule.subname.ignore all &&
296 git diff HEAD^..HEAD >actual &&
297 ! test -s actual &&
298 git config submodule.subname.ignore dirty &&
299 git config submodule.subname.path sub &&
300 git diff HEAD^..HEAD >actual &&
301 sed -e "1,/^@@/d" actual >actual.body &&
302 expect_from_to >expect.body $subtip $subprev &&
303 git config --remove-section submodule.subname &&
304 git config --remove-section -f .gitmodules submodule.subname &&
305 rm .gitmodules
308 test_expect_success 'git diff (empty submodule dir)' '
309 : >empty &&
310 rm -rf sub/* sub/.git &&
311 git diff > actual.empty &&
312 test_cmp empty actual.empty
315 test_expect_success 'conflicted submodule setup' '
317 # 39 efs
318 c=fffffffffffffffffffffffffffffffffffffff &&
320 echo "000000 $_z40 0 sub" &&
321 echo "160000 1$c 1 sub" &&
322 echo "160000 2$c 2 sub" &&
323 echo "160000 3$c 3 sub"
324 ) | git update-index --index-info &&
325 echo >expect.nosub '\''diff --cc sub
326 index 2ffffff,3ffffff..0000000
327 --- a/sub
328 +++ b/sub
329 @@@ -1,1 -1,1 +1,1 @@@
330 - Subproject commit 2fffffffffffffffffffffffffffffffffffffff
331 -Subproject commit 3fffffffffffffffffffffffffffffffffffffff
332 ++Subproject commit 0000000000000000000000000000000000000000'\'' &&
334 hh=$(git rev-parse HEAD) &&
335 sed -e "s/$_z40/$hh/" expect.nosub >expect.withsub
339 test_expect_success 'combined (empty submodule)' '
340 rm -fr sub && mkdir sub &&
341 git diff >actual &&
342 test_cmp expect.nosub actual
345 test_expect_success 'combined (with submodule)' '
346 rm -fr sub &&
347 git clone --no-checkout . sub &&
348 git diff >actual &&
349 test_cmp expect.withsub actual
354 test_done