Skip to content

Commit 594a867

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e333175 commit 594a867

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

t/t7405-submodule-merge.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,58 @@ test_expect_success 'recursive merge with submodule' '
279279
grep "$(cat expect3)" actual > /dev/null)
280280
'
281281

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+
282336
test_done

0 commit comments

Comments
 (0)