This patch series documents a few problems with submodules and merging, first mentioned at [1]. Changes since v1 (full range-diff below): - Incorporate suggestions from Stefan: use test_commit and git submodule add (note that git submodule add means there will also be a .gitmodules file, so the count of tracked files goes up by 1) - Explain the tests a little better - Test the merge --abort case a little more thoroughly. [1] https://public-inbox.org/git/CABPp-BHDrw_dAESic3xK7kC3jMgKeNQuPQF69OpbVYhRkbhJsw@xxxxxxxxxxxxxx/ Elijah Newren (3): t7405: add a file/submodule conflict t7405: add a directory/submodule conflict t7405: verify 'merge --abort' works after submodule/path conflicts t/t7405-submodule-merge.sh | 173 +++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) 1: 44bc2a05f ! 1: 16f6622ce t7405: add a file/submodule conflict @@ -32,20 +32,14 @@ + git branch B && + + git checkout B && -+ echo contents >path && ++ echo content >path && + git add path && + git commit -m B && + + git checkout A && + test_create_repo path && -+ ( -+ cd path && -+ -+ echo hello >world && -+ git add world && -+ git commit -m "submodule" -+ ) && -+ git add path && ++ test_commit -C path world && ++ git submodule add ./path && + git commit -m A + ) +' @@ -56,16 +50,20 @@ + cd file-submodule && + + git checkout A^0 && -+ test_must_fail git merge B^0 >out 2>err && ++ test_must_fail git merge B^0 && + + git ls-files -s >out && -+ test_line_count = 2 out && ++ test_line_count = 3 out && + git ls-files -u >out && + test_line_count = 2 out && + + # path/ is still a submodule + test_path_is_dir path/.git && + ++ # There is a submodule at "path", so B:path cannot be written ++ # there. We expect it to be written somewhere in the same ++ # directory, though, so just grep for its content in all ++ # files, and ignore "grep: path: Is a directory" message + echo Checking if contents from B:path showed up anywhere && + grep -q content * 2>/dev/null + ) 2: 2fa139d3b ! 2: 31dc3bc4e t7405: add a directory/submodule conflict @@ -56,14 +56,8 @@ + + git checkout A && + test_create_repo path && -+ ( -+ cd path && -+ -+ echo hello >world && -+ git add world && -+ git commit -m "submodule" -+ ) && -+ git add path && ++ test_commit -C path hello world && ++ git submodule add ./path && + git commit -m A + ) +' @@ -77,7 +71,7 @@ + test_must_fail git merge B1^0 && + + git ls-files -s >out && -+ test_line_count = 2 out && ++ test_line_count = 3 out && + git ls-files -u >out && + test_line_count = 1 out && + @@ -87,6 +81,9 @@ + echo Checking if contents from B1:path/file showed up && + # Would rather use grep -r, but that is GNU extension... + git ls-files -co | xargs grep -q contents 2>/dev/null && ++ ++ # However, B1:path/file should NOT have shown up at path/file, ++ # because we should not write into the submodule + test_path_is_missing path/file + ) +' 3: b2a44bedf ! 3: 49719952b t7405: verify 'merge --abort' works after submodule/path conflicts @@ -39,12 +39,17 @@ + test_when_finished "git -C directory-submodule reset --hard" && + ( + cd directory-submodule && -+ -+ git checkout A^0 && -+ test_must_fail git merge B2^0 >out 2>err && ++ git checkout A^0 && ++ test_must_fail git merge B2^0 && + test_path_is_file .git/MERGE_HEAD && -+ git merge --abort ++ ++ # merge --abort should succeed, should clear .git/MERGE_HEAD, ++ # and should not leave behind any conflicted files ++ git merge --abort && ++ test_path_is_missing .git/MERGE_HEAD && ++ git ls-files -u >conflicts && ++ test_must_be_empty conflicts ) ' -- 2.18.0.132.g6e63b23f4