]>
Commit | Line | Data |
---|---|---|
05e934bb CB |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2008 Charles Bailey | |
4 | # | |
5 | ||
47a528ad | 6 | test_description='git mergetool |
05e934bb CB |
7 | |
8 | Testing basic merge tool invocation' | |
9 | ||
10 | . ./test-lib.sh | |
11 | ||
b9b5078e CB |
12 | # All the mergetool test work by checking out a temporary branch based |
13 | # off 'branch1' and then merging in master and checking the results of | |
14 | # running mergetool | |
15 | ||
05e934bb | 16 | test_expect_success 'setup' ' |
f9e43085 | 17 | test_config rerere.enabled true && |
74578618 DA |
18 | echo master >file1 && |
19 | echo master spaced >"spaced name" && | |
20 | echo master file11 >file11 && | |
21 | echo master file12 >file12 && | |
22 | echo master file13 >file13 && | |
23 | echo master file14 >file14 && | |
24 | mkdir subdir && | |
25 | echo master sub >subdir/file3 && | |
26 | test_create_repo submod && | |
27 | ( | |
28 | cd submod && | |
29 | : >foo && | |
30 | git add foo && | |
31 | git commit -m "Add foo" | |
32 | ) && | |
33 | git submodule add git://example.com/submod submod && | |
34 | git add file1 "spaced name" file1[1-4] subdir/file3 .gitmodules submod && | |
35 | git commit -m "add initial versions" && | |
36 | ||
37 | git checkout -b branch1 master && | |
38 | git submodule update -N && | |
39 | echo branch1 change >file1 && | |
40 | echo branch1 newfile >file2 && | |
41 | echo branch1 spaced >"spaced name" && | |
42 | echo branch1 both added >both && | |
43 | echo branch1 change file11 >file11 && | |
44 | echo branch1 change file13 >file13 && | |
45 | echo branch1 sub >subdir/file3 && | |
46 | ( | |
47 | cd submod && | |
48 | echo branch1 submodule >bar && | |
49 | git add bar && | |
50 | git commit -m "Add bar on branch1" && | |
51 | git checkout -b submod-branch1 | |
52 | ) && | |
53 | git add file1 "spaced name" file11 file13 file2 subdir/file3 submod && | |
54 | git add both && | |
55 | git rm file12 && | |
56 | git commit -m "branch1 changes" && | |
57 | ||
58 | git checkout -b stash1 master && | |
59 | echo stash1 change file11 >file11 && | |
60 | git add file11 && | |
61 | git commit -m "stash1 changes" && | |
62 | ||
63 | git checkout -b stash2 master && | |
64 | echo stash2 change file11 >file11 && | |
65 | git add file11 && | |
66 | git commit -m "stash2 changes" && | |
67 | ||
68 | git checkout master && | |
69 | git submodule update -N && | |
70 | echo master updated >file1 && | |
71 | echo master new >file2 && | |
72 | echo master updated spaced >"spaced name" && | |
73 | echo master both added >both && | |
74 | echo master updated file12 >file12 && | |
75 | echo master updated file14 >file14 && | |
76 | echo master new sub >subdir/file3 && | |
77 | ( | |
78 | cd submod && | |
79 | echo master submodule >bar && | |
80 | git add bar && | |
81 | git commit -m "Add bar on master" && | |
82 | git checkout -b submod-master | |
83 | ) && | |
84 | git add file1 "spaced name" file12 file14 file2 subdir/file3 submod && | |
85 | git add both && | |
86 | git rm file11 && | |
87 | git commit -m "master updates" && | |
88 | ||
89 | git config merge.tool mytool && | |
90 | git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && | |
91 | git config mergetool.mytool.trustExitCode true && | |
92 | git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" && | |
93 | git config mergetool.mybase.trustExitCode true | |
b9b5078e CB |
94 | ' |
95 | ||
96 | test_expect_success 'custom mergetool' ' | |
74578618 DA |
97 | git checkout -b test1 branch1 && |
98 | git submodule update -N && | |
99 | test_must_fail git merge master >/dev/null 2>&1 && | |
100 | ( yes "" | git mergetool both >/dev/null 2>&1 ) && | |
101 | ( yes "" | git mergetool file1 file1 ) && | |
102 | ( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) && | |
103 | ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && | |
104 | ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && | |
105 | ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && | |
106 | ( yes "l" | git mergetool submod >/dev/null 2>&1 ) && | |
107 | test "$(cat file1)" = "master updated" && | |
108 | test "$(cat file2)" = "master new" && | |
109 | test "$(cat subdir/file3)" = "master new sub" && | |
110 | test "$(cat submod/bar)" = "branch1 submodule" && | |
111 | git commit -m "branch1 resolved with mergetool" | |
0ec7b6c2 CB |
112 | ' |
113 | ||
114 | test_expect_success 'mergetool crlf' ' | |
f9e43085 | 115 | test_config core.autocrlf true && |
74578618 DA |
116 | git checkout -b test2 branch1 && |
117 | test_must_fail git merge master >/dev/null 2>&1 && | |
118 | ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && | |
119 | ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && | |
120 | ( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) && | |
121 | ( yes "" | git mergetool both >/dev/null 2>&1 ) && | |
122 | ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && | |
123 | ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && | |
124 | ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && | |
125 | ( yes "r" | git mergetool submod >/dev/null 2>&1 ) && | |
126 | test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" && | |
127 | test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" && | |
128 | test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" && | |
129 | git submodule update -N && | |
130 | test "$(cat submod/bar)" = "master submodule" && | |
131 | git commit -m "branch1 resolved with mergetool - autocrlf" && | |
f9e43085 | 132 | test_config core.autocrlf false && |
74578618 | 133 | git reset --hard |
b9b5078e CB |
134 | ' |
135 | ||
ff4a1855 | 136 | test_expect_success 'mergetool in subdir' ' |
74578618 DA |
137 | git checkout -b test3 branch1 && |
138 | git submodule update -N && | |
139 | ( | |
140 | cd subdir && | |
141 | test_must_fail git merge master >/dev/null 2>&1 && | |
142 | ( yes "" | git mergetool file3 >/dev/null 2>&1 ) && | |
143 | test "$(cat file3)" = "master new sub" | |
144 | ) | |
05e934bb CB |
145 | ' |
146 | ||
bb0a484e | 147 | test_expect_success 'mergetool on file in parent dir' ' |
74578618 DA |
148 | ( |
149 | cd subdir && | |
150 | ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && | |
151 | ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && | |
152 | ( yes "" | git mergetool ../both >/dev/null 2>&1 ) && | |
153 | ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && | |
154 | ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && | |
155 | ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) && | |
156 | test "$(cat ../file1)" = "master updated" && | |
157 | test "$(cat ../file2)" = "master new" && | |
158 | test "$(cat ../submod/bar)" = "branch1 submodule" && | |
159 | git commit -m "branch1 resolved with mergetool - subdir" | |
160 | ) | |
bb0a484e DA |
161 | ' |
162 | ||
163 | test_expect_success 'mergetool skips autoresolved' ' | |
74578618 DA |
164 | git checkout -b test4 branch1 && |
165 | git submodule update -N && | |
166 | test_must_fail git merge master && | |
167 | test -n "$(git ls-files -u)" && | |
168 | ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && | |
169 | ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && | |
170 | ( yes "l" | git mergetool submod >/dev/null 2>&1 ) && | |
171 | output="$(git mergetool --no-prompt)" && | |
172 | test "$output" = "No files need merging" && | |
173 | git reset --hard | |
bb0a484e DA |
174 | ' |
175 | ||
176 | test_expect_success 'mergetool merges all from subdir' ' | |
1a9a23e3 | 177 | test_config rerere.enabled false && |
74578618 DA |
178 | ( |
179 | cd subdir && | |
74578618 DA |
180 | test_must_fail git merge master && |
181 | ( yes "r" | git mergetool ../submod ) && | |
182 | ( yes "d" "d" | git mergetool --no-prompt ) && | |
183 | test "$(cat ../file1)" = "master updated" && | |
184 | test "$(cat ../file2)" = "master new" && | |
185 | test "$(cat file3)" = "master new sub" && | |
186 | ( cd .. && git submodule update -N ) && | |
187 | test "$(cat ../submod/bar)" = "master submodule" && | |
188 | git commit -m "branch2 resolved by mergetool from subdir" | |
189 | ) | |
bb0a484e | 190 | ' |
b9b5078e | 191 | |
2f59c947 | 192 | test_expect_success 'mergetool skips resolved paths when rerere is active' ' |
f9e43085 | 193 | test_config rerere.enabled true && |
74578618 | 194 | rm -rf .git/rr-cache && |
4756c057 | 195 | git checkout -b test5 branch1 && |
74578618 DA |
196 | git submodule update -N && |
197 | test_must_fail git merge master >/dev/null 2>&1 && | |
198 | ( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) && | |
199 | ( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) && | |
200 | git submodule update -N && | |
201 | output="$(yes "n" | git mergetool --no-prompt)" && | |
202 | test "$output" = "No files need merging" && | |
203 | git reset --hard | |
2f59c947 MZ |
204 | ' |
205 | ||
743bf6d8 | 206 | test_expect_success 'conflicted stash sets up rerere' ' |
f9e43085 | 207 | test_config rerere.enabled true && |
74578618 DA |
208 | git checkout stash1 && |
209 | echo "Conflicting stash content" >file11 && | |
210 | git stash && | |
211 | ||
212 | git checkout --detach stash2 && | |
213 | test_must_fail git stash apply && | |
214 | ||
215 | test -n "$(git ls-files -u)" && | |
216 | conflicts="$(git rerere remaining)" && | |
217 | test "$conflicts" = "file11" && | |
218 | output="$(git mergetool --no-prompt)" && | |
219 | test "$output" != "No files need merging" && | |
220 | ||
221 | git commit -am "save the stash resolution" && | |
222 | ||
223 | git reset --hard stash2 && | |
224 | test_must_fail git stash apply && | |
225 | ||
226 | test -n "$(git ls-files -u)" && | |
227 | conflicts="$(git rerere remaining)" && | |
228 | test -z "$conflicts" && | |
229 | output="$(git mergetool --no-prompt)" && | |
230 | test "$output" = "No files need merging" | |
79dc2d0b PH |
231 | ' |
232 | ||
3e8e691a | 233 | test_expect_success 'mergetool takes partial path' ' |
4756c057 | 234 | git reset --hard && |
f9e43085 | 235 | test_config rerere.enabled false && |
74578618 DA |
236 | git checkout -b test12 branch1 && |
237 | git submodule update -N && | |
238 | test_must_fail git merge master && | |
239 | ||
74578618 DA |
240 | ( yes "" | git mergetool subdir ) && |
241 | ||
242 | test "$(cat subdir/file3)" = "master new sub" && | |
243 | git reset --hard | |
3e8e691a JM |
244 | ' |
245 | ||
faaab8d5 DA |
246 | test_expect_success 'mergetool delete/delete conflict' ' |
247 | git checkout -b delete-base branch1 && | |
248 | mkdir -p a/a && | |
249 | (echo one; echo two; echo 3; echo 4) >a/a/file.txt && | |
250 | git add a/a/file.txt && | |
251 | git commit -m"base file" && | |
252 | git checkout -b move-to-b delete-base && | |
253 | mkdir -p b/b && | |
254 | git mv a/a/file.txt b/b/file.txt && | |
255 | (echo one; echo two; echo 4) >b/b/file.txt && | |
256 | git commit -a -m"move to b" && | |
257 | git checkout -b move-to-c delete-base && | |
258 | mkdir -p c/c && | |
259 | git mv a/a/file.txt c/c/file.txt && | |
260 | (echo one; echo two; echo 3) >c/c/file.txt && | |
261 | git commit -a -m"move to c" && | |
262 | test_must_fail git merge move-to-b && | |
263 | echo d | git mergetool a/a/file.txt && | |
264 | ! test -f a/a/file.txt && | |
265 | git reset --hard HEAD && | |
266 | test_must_fail git merge move-to-b && | |
267 | echo m | git mergetool a/a/file.txt && | |
268 | test -f b/b/file.txt && | |
269 | git reset --hard HEAD && | |
270 | test_must_fail git merge move-to-b && | |
271 | ! echo a | git mergetool a/a/file.txt && | |
272 | ! test -f a/a/file.txt && | |
273 | git reset --hard HEAD | |
274 | ' | |
275 | ||
276 | test_expect_success 'mergetool produces no errors when keepBackup is used' ' | |
277 | test_config mergetool.keepBackup true && | |
278 | test_must_fail git merge move-to-b && | |
279 | : >expect && | |
280 | echo d | git mergetool a/a/file.txt 2>actual && | |
281 | test_cmp expect actual && | |
a2986045 DA |
282 | ! test -d a && |
283 | git reset --hard HEAD | |
284 | ' | |
285 | ||
286 | test_expect_success 'mergetool honors tempfile config for deleted files' ' | |
287 | test_config mergetool.keepTemporaries false && | |
288 | test_must_fail git merge move-to-b && | |
289 | echo d | git mergetool a/a/file.txt && | |
290 | ! test -d a && | |
291 | git reset --hard HEAD | |
292 | ' | |
293 | ||
294 | test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' ' | |
295 | test_config mergetool.keepTemporaries true && | |
296 | test_must_fail git merge move-to-b && | |
297 | ! (echo a; echo n) | git mergetool a/a/file.txt && | |
298 | test -d a/a && | |
299 | cat >expect <<-\EOF && | |
300 | file_BASE_.txt | |
301 | file_LOCAL_.txt | |
302 | file_REMOTE_.txt | |
303 | EOF | |
304 | ls -1 a/a | sed -e "s/[0-9]*//g" >actual && | |
305 | test_cmp expect actual && | |
306 | git clean -fdx && | |
faaab8d5 DA |
307 | git reset --hard HEAD |
308 | ' | |
309 | ||
ff7f089e | 310 | test_expect_success 'deleted vs modified submodule' ' |
74578618 DA |
311 | git checkout -b test6 branch1 && |
312 | git submodule update -N && | |
313 | mv submod submod-movedaside && | |
314 | git rm --cached submod && | |
315 | git commit -m "Submodule deleted from branch" && | |
316 | git checkout -b test6.a test6 && | |
317 | test_must_fail git merge master && | |
318 | test -n "$(git ls-files -u)" && | |
319 | ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && | |
320 | ( yes "" | git mergetool both >/dev/null 2>&1 ) && | |
321 | ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && | |
322 | ( yes "r" | git mergetool submod ) && | |
323 | rmdir submod && mv submod-movedaside submod && | |
324 | test "$(cat submod/bar)" = "branch1 submodule" && | |
325 | git submodule update -N && | |
326 | test "$(cat submod/bar)" = "master submodule" && | |
327 | output="$(git mergetool --no-prompt)" && | |
328 | test "$output" = "No files need merging" && | |
329 | git commit -m "Merge resolved by keeping module" && | |
330 | ||
331 | mv submod submod-movedaside && | |
332 | git checkout -b test6.b test6 && | |
333 | git submodule update -N && | |
334 | test_must_fail git merge master && | |
335 | test -n "$(git ls-files -u)" && | |
336 | ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && | |
337 | ( yes "" | git mergetool both >/dev/null 2>&1 ) && | |
338 | ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && | |
339 | ( yes "l" | git mergetool submod ) && | |
340 | test ! -e submod && | |
341 | output="$(git mergetool --no-prompt)" && | |
342 | test "$output" = "No files need merging" && | |
343 | git commit -m "Merge resolved by deleting module" && | |
344 | ||
345 | mv submod-movedaside submod && | |
346 | git checkout -b test6.c master && | |
347 | git submodule update -N && | |
348 | test_must_fail git merge test6 && | |
349 | test -n "$(git ls-files -u)" && | |
350 | ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && | |
351 | ( yes "" | git mergetool both >/dev/null 2>&1 ) && | |
352 | ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && | |
353 | ( yes "r" | git mergetool submod ) && | |
354 | test ! -e submod && | |
355 | test -d submod.orig && | |
356 | git submodule update -N && | |
357 | output="$(git mergetool --no-prompt)" && | |
358 | test "$output" = "No files need merging" && | |
359 | git commit -m "Merge resolved by deleting module" && | |
360 | mv submod.orig submod && | |
361 | ||
362 | git checkout -b test6.d master && | |
363 | git submodule update -N && | |
364 | test_must_fail git merge test6 && | |
365 | test -n "$(git ls-files -u)" && | |
366 | ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && | |
367 | ( yes "" | git mergetool both >/dev/null 2>&1 ) && | |
368 | ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && | |
369 | ( yes "l" | git mergetool submod ) && | |
370 | test "$(cat submod/bar)" = "master submodule" && | |
371 | git submodule update -N && | |
372 | test "$(cat submod/bar)" = "master submodule" && | |
373 | output="$(git mergetool --no-prompt)" && | |
374 | test "$output" = "No files need merging" && | |
375 | git commit -m "Merge resolved by keeping module" && | |
376 | git reset --hard HEAD | |
ff7f089e JM |
377 | ' |
378 | ||
379 | test_expect_success 'file vs modified submodule' ' | |
74578618 DA |
380 | git checkout -b test7 branch1 && |
381 | git submodule update -N && | |
382 | mv submod submod-movedaside && | |
383 | git rm --cached submod && | |
384 | echo not a submodule >submod && | |
385 | git add submod && | |
386 | git commit -m "Submodule path becomes file" && | |
387 | git checkout -b test7.a branch1 && | |
388 | test_must_fail git merge master && | |
389 | test -n "$(git ls-files -u)" && | |
390 | ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && | |
391 | ( yes "" | git mergetool both >/dev/null 2>&1 ) && | |
392 | ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && | |
393 | ( yes "r" | git mergetool submod ) && | |
394 | rmdir submod && mv submod-movedaside submod && | |
395 | test "$(cat submod/bar)" = "branch1 submodule" && | |
396 | git submodule update -N && | |
397 | test "$(cat submod/bar)" = "master submodule" && | |
398 | output="$(git mergetool --no-prompt)" && | |
399 | test "$output" = "No files need merging" && | |
400 | git commit -m "Merge resolved by keeping module" && | |
401 | ||
402 | mv submod submod-movedaside && | |
403 | git checkout -b test7.b test7 && | |
404 | test_must_fail git merge master && | |
405 | test -n "$(git ls-files -u)" && | |
406 | ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && | |
407 | ( yes "" | git mergetool both >/dev/null 2>&1 ) && | |
408 | ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && | |
409 | ( yes "l" | git mergetool submod ) && | |
410 | git submodule update -N && | |
411 | test "$(cat submod)" = "not a submodule" && | |
412 | output="$(git mergetool --no-prompt)" && | |
413 | test "$output" = "No files need merging" && | |
414 | git commit -m "Merge resolved by keeping file" && | |
415 | ||
416 | git checkout -b test7.c master && | |
417 | rmdir submod && mv submod-movedaside submod && | |
418 | test ! -e submod.orig && | |
419 | git submodule update -N && | |
420 | test_must_fail git merge test7 && | |
421 | test -n "$(git ls-files -u)" && | |
422 | ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && | |
423 | ( yes "" | git mergetool both >/dev/null 2>&1 ) && | |
424 | ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && | |
425 | ( yes "r" | git mergetool submod ) && | |
426 | test -d submod.orig && | |
427 | git submodule update -N && | |
428 | test "$(cat submod)" = "not a submodule" && | |
429 | output="$(git mergetool --no-prompt)" && | |
430 | test "$output" = "No files need merging" && | |
431 | git commit -m "Merge resolved by keeping file" && | |
432 | ||
433 | git checkout -b test7.d master && | |
434 | rmdir submod && mv submod.orig submod && | |
435 | git submodule update -N && | |
436 | test_must_fail git merge test7 && | |
437 | test -n "$(git ls-files -u)" && | |
438 | ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && | |
439 | ( yes "" | git mergetool both>/dev/null 2>&1 ) && | |
440 | ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && | |
441 | ( yes "l" | git mergetool submod ) && | |
442 | test "$(cat submod/bar)" = "master submodule" && | |
443 | git submodule update -N && | |
444 | test "$(cat submod/bar)" = "master submodule" && | |
445 | output="$(git mergetool --no-prompt)" && | |
446 | test "$output" = "No files need merging" && | |
447 | git commit -m "Merge resolved by keeping module" | |
ff7f089e JM |
448 | ' |
449 | ||
450 | test_expect_success 'submodule in subdirectory' ' | |
74578618 DA |
451 | git checkout -b test10 branch1 && |
452 | git submodule update -N && | |
453 | ( | |
454 | cd subdir && | |
455 | test_create_repo subdir_module && | |
456 | ( | |
457 | cd subdir_module && | |
458 | : >file15 && | |
459 | git add file15 && | |
460 | git commit -m "add initial versions" | |
461 | ) | |
462 | ) && | |
463 | git submodule add git://example.com/subsubmodule subdir/subdir_module && | |
464 | git add subdir/subdir_module && | |
465 | git commit -m "add submodule in subdirectory" && | |
466 | ||
467 | git checkout -b test10.a test10 && | |
468 | git submodule update -N && | |
ff7f089e | 469 | ( |
ff7f089e | 470 | cd subdir/subdir_module && |
74578618 DA |
471 | git checkout -b super10.a && |
472 | echo test10.a >file15 && | |
473 | git add file15 && | |
474 | git commit -m "on branch 10.a" | |
475 | ) && | |
476 | git add subdir/subdir_module && | |
477 | git commit -m "change submodule in subdirectory on test10.a" && | |
478 | ||
479 | git checkout -b test10.b test10 && | |
480 | git submodule update -N && | |
481 | ( | |
482 | cd subdir/subdir_module && | |
483 | git checkout -b super10.b && | |
484 | echo test10.b >file15 && | |
485 | git add file15 && | |
486 | git commit -m "on branch 10.b" | |
487 | ) && | |
488 | git add subdir/subdir_module && | |
489 | git commit -m "change submodule in subdirectory on test10.b" && | |
490 | ||
491 | test_must_fail git merge test10.a >/dev/null 2>&1 && | |
492 | ( | |
493 | cd subdir && | |
494 | ( yes "l" | git mergetool subdir_module ) | |
495 | ) && | |
496 | test "$(cat subdir/subdir_module/file15)" = "test10.b" && | |
497 | git submodule update -N && | |
498 | test "$(cat subdir/subdir_module/file15)" = "test10.b" && | |
499 | git reset --hard && | |
500 | git submodule update -N && | |
501 | ||
502 | test_must_fail git merge test10.a >/dev/null 2>&1 && | |
503 | ( yes "r" | git mergetool subdir/subdir_module ) && | |
504 | test "$(cat subdir/subdir_module/file15)" = "test10.b" && | |
505 | git submodule update -N && | |
506 | test "$(cat subdir/subdir_module/file15)" = "test10.a" && | |
507 | git commit -m "branch1 resolved with mergetool" && | |
508 | rm -rf subdir/subdir_module | |
ff7f089e JM |
509 | ' |
510 | ||
511 | test_expect_success 'directory vs modified submodule' ' | |
74578618 DA |
512 | git checkout -b test11 branch1 && |
513 | mv submod submod-movedaside && | |
514 | git rm --cached submod && | |
515 | mkdir submod && | |
516 | echo not a submodule >submod/file16 && | |
517 | git add submod/file16 && | |
518 | git commit -m "Submodule path becomes directory" && | |
519 | ||
520 | test_must_fail git merge master && | |
521 | test -n "$(git ls-files -u)" && | |
522 | ( yes "l" | git mergetool submod ) && | |
523 | test "$(cat submod/file16)" = "not a submodule" && | |
524 | rm -rf submod.orig && | |
525 | ||
526 | git reset --hard >/dev/null 2>&1 && | |
527 | test_must_fail git merge master && | |
528 | test -n "$(git ls-files -u)" && | |
529 | test ! -e submod.orig && | |
530 | ( yes "r" | git mergetool submod ) && | |
531 | test -d submod.orig && | |
532 | test "$(cat submod.orig/file16)" = "not a submodule" && | |
533 | rm -r submod.orig && | |
534 | mv submod-movedaside/.git submod && | |
535 | ( cd submod && git clean -f && git reset --hard ) && | |
536 | git submodule update -N && | |
537 | test "$(cat submod/bar)" = "master submodule" && | |
538 | git reset --hard >/dev/null 2>&1 && rm -rf submod-movedaside && | |
539 | ||
540 | git checkout -b test11.c master && | |
541 | git submodule update -N && | |
542 | test_must_fail git merge test11 && | |
543 | test -n "$(git ls-files -u)" && | |
544 | ( yes "l" | git mergetool submod ) && | |
545 | git submodule update -N && | |
546 | test "$(cat submod/bar)" = "master submodule" && | |
547 | ||
548 | git reset --hard >/dev/null 2>&1 && | |
549 | git submodule update -N && | |
550 | test_must_fail git merge test11 && | |
551 | test -n "$(git ls-files -u)" && | |
552 | test ! -e submod.orig && | |
553 | ( yes "r" | git mergetool submod ) && | |
554 | test "$(cat submod/file16)" = "not a submodule" && | |
555 | ||
556 | git reset --hard master >/dev/null 2>&1 && | |
557 | ( cd submod && git clean -f && git reset --hard ) && | |
558 | git submodule update -N | |
ff7f089e JM |
559 | ' |
560 | ||
ec245ba0 | 561 | test_expect_success 'file with no base' ' |
74578618 DA |
562 | git checkout -b test13 branch1 && |
563 | test_must_fail git merge master && | |
564 | git mergetool --no-prompt --tool mybase -- both && | |
565 | >expected && | |
566 | test_cmp both expected && | |
567 | git reset --hard master >/dev/null 2>&1 | |
ec245ba0 DA |
568 | ' |
569 | ||
a427ef7a | 570 | test_expect_success 'custom commands override built-ins' ' |
74578618 | 571 | git checkout -b test14 branch1 && |
f9e43085 DA |
572 | test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && |
573 | test_config mergetool.defaults.trustExitCode true && | |
74578618 DA |
574 | test_must_fail git merge master && |
575 | git mergetool --no-prompt --tool defaults -- both && | |
576 | echo master both added >expected && | |
577 | test_cmp both expected && | |
74578618 | 578 | git reset --hard master >/dev/null 2>&1 |
a427ef7a DA |
579 | ' |
580 | ||
688684eb DA |
581 | test_expect_success 'filenames seen by tools start with ./' ' |
582 | git checkout -b test15 branch1 && | |
583 | test_config mergetool.writeToTemp false && | |
584 | test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && | |
585 | test_config mergetool.myecho.trustExitCode true && | |
586 | test_must_fail git merge master && | |
587 | git mergetool --no-prompt --tool myecho -- both >actual && | |
588 | grep ^\./both_LOCAL_ actual >/dev/null && | |
589 | git reset --hard master >/dev/null 2>&1 | |
590 | ' | |
591 | ||
c578a09b AK |
592 | test_lazy_prereq MKTEMP ' |
593 | tempdir=$(mktemp -d -t foo.XXXXXX) && | |
594 | test -d "$tempdir" | |
595 | ' | |
596 | ||
597 | test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' ' | |
688684eb DA |
598 | git checkout -b test16 branch1 && |
599 | test_config mergetool.writeToTemp true && | |
600 | test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && | |
601 | test_config mergetool.myecho.trustExitCode true && | |
602 | test_must_fail git merge master && | |
603 | git mergetool --no-prompt --tool myecho -- both >actual && | |
604 | test_must_fail grep ^\./both_LOCAL_ actual >/dev/null && | |
605 | grep /both_LOCAL_ actual >/dev/null && | |
606 | git reset --hard master >/dev/null 2>&1 | |
607 | ' | |
608 | ||
57937f70 DA |
609 | test_expect_success 'diff.orderFile configuration is honored' ' |
610 | test_config diff.orderFile order-file && | |
611 | test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && | |
612 | test_config mergetool.myecho.trustExitCode true && | |
613 | echo b >order-file && | |
614 | echo a >>order-file && | |
615 | git checkout -b order-file-start master && | |
616 | echo start >a && | |
617 | echo start >b && | |
618 | git add a b && | |
619 | git commit -m start && | |
620 | git checkout -b order-file-side1 order-file-start && | |
621 | echo side1 >a && | |
622 | echo side1 >b && | |
623 | git add a b && | |
624 | git commit -m side1 && | |
625 | git checkout -b order-file-side2 order-file-start && | |
626 | echo side2 >a && | |
627 | echo side2 >b && | |
628 | git add a b && | |
629 | git commit -m side2 && | |
630 | test_must_fail git merge order-file-side1 && | |
631 | cat >expect <<-\EOF && | |
632 | Merging: | |
633 | b | |
634 | a | |
635 | EOF | |
636 | git mergetool --no-prompt --tool myecho >output && | |
637 | git grep --no-index -h -A2 Merging: output >actual && | |
638 | test_cmp expect actual && | |
639 | git reset --hard >/dev/null | |
640 | ' | |
641 | ||
05e934bb | 642 | test_done |