Code

Merge branch 'maint'
[git.git] / t / t7400-submodule-basic.sh
index 21b08395ce6da07842d4e993d2be50642748fae1..2c49db9f6244225db7f82b574f21f05b58bfdc26 100755 (executable)
@@ -413,18 +413,37 @@ test_expect_success 'submodule <invalid-path> warns' '
 
 test_expect_success 'add submodules without specifying an explicit path' '
        mkdir repo &&
-       (cd repo &&
-       git init &&
-       echo r >r &&
-       git add r &&
-       git commit -m "repo commit 1"
+       (
+               cd repo &&
+               git init &&
+               echo r >r &&
+               git add r &&
+               git commit -m "repo commit 1"
        ) &&
        git clone --bare repo/ bare.git &&
-       cd addtest &&
-       git submodule add "$submodurl/repo" &&
-       git config -f .gitmodules submodule.repo.path repo &&
-       git submodule add "$submodurl/bare.git" &&
-       git config -f .gitmodules submodule.bare.path bare
+       (
+               cd addtest &&
+               git submodule add "$submodurl/repo" &&
+               git config -f .gitmodules submodule.repo.path repo &&
+               git submodule add "$submodurl/bare.git" &&
+               git config -f .gitmodules submodule.bare.path bare
+       )
+'
+
+test_expect_success 'add should fail when path is used by a file' '
+       (
+               cd addtest &&
+               touch file &&
+               test_must_fail  git submodule add "$submodurl/repo" file
+       )
+'
+
+test_expect_success 'add should fail when path is used by an existing directory' '
+       (
+               cd addtest &&
+               mkdir empty-dir &&
+               test_must_fail git submodule add "$submodurl/repo" empty-dir
+       )
 '
 
 test_done