t7405: add a file/submodule conflict

In the case of a file/submodule conflict, although both cannot exist at the same path, we expect both to be present somewhere for the user to be able to resolve the conflict with. Add a testcase for this. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jul 10, 2018 at 20:56 UTC 594a8673f227e9a00b3b0c4d6a26c97d68651666
1 file changed +54
t/t7405-submodule-merge.sh
+54
@@ -279,4 +279,58 @@ test_expect_success 'recursive merge with submodule' '
279 grep "$(cat expect3)" actual > /dev/null)
280 '
281
282 +# File/submodule conflict
283 +# Commit O: <empty>
284 +# Commit A: path (submodule)
285 +# Commit B: path
286 +# Expected: path/ is submodule and file contents for B's path are somewhere
287 +
288 +test_expect_success 'setup file/submodule conflict' '
289 + test_create_repo file-submodule &&
290 + (
291 + cd file-submodule &&
292 +
293 + git commit --allow-empty -m O &&
294 +
295 + git branch A &&
296 + git branch B &&
297 +
298 + git checkout B &&
299 + echo content >path &&
300 + git add path &&
301 + git commit -m B &&
302 +
303 + git checkout A &&
304 + test_create_repo path &&
305 + test_commit -C path world &&
306 + git submodule add ./path &&
307 + git commit -m A
308 + )
309 +'
310 +
311 +test_expect_failure 'file/submodule conflict' '
312 + test_when_finished "git -C file-submodule reset --hard" &&
313 + (
314 + cd file-submodule &&
315 +
316 + git checkout A^0 &&
317 + test_must_fail git merge B^0 &&
318 +
319 + git ls-files -s >out &&
320 + test_line_count = 3 out &&
321 + git ls-files -u >out &&
322 + test_line_count = 2 out &&
323 +
324 + # path/ is still a submodule
325 + test_path_is_dir path/.git &&
326 +
327 + # There is a submodule at "path", so B:path cannot be written
328 + # there. We expect it to be written somewhere in the same
329 + # directory, though, so just grep for its content in all
330 + # files, and ignore "grep: path: Is a directory" message
331 + echo Checking if contents from B:path showed up anywhere &&
332 + grep -q content * 2>/dev/null
333 + )
334 +'
335 +
336 test_done