]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t7400-submodule-basic.sh
git submodule add: make the <path> parameter optional
[thirdparty/git.git] / t / t7400-submodule-basic.sh
index 2ec7ac6a510c5b83bc1ee6ce428379beb7a8b5ef..a0cc99ab9f5b262851a1075193f5529b5582fd0a 100755 (executable)
@@ -47,6 +47,65 @@ test_expect_success 'Prepare submodule testing' '
        GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
 '
 
+test_expect_success 'Prepare submodule add testing' '
+       submodurl=$(pwd)
+       (
+               mkdir addtest &&
+               cd addtest &&
+               git init
+       )
+'
+
+test_expect_success 'submodule add' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" submod &&
+               git submodule init
+       )
+'
+
+test_expect_success 'submodule add --branch' '
+       (
+               cd addtest &&
+               git submodule add -b initial "$submodurl" submod-branch &&
+               git submodule init &&
+               cd submod-branch &&
+               git branch | grep initial
+       )
+'
+
+test_expect_success 'submodule add with ./ in path' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
+               git submodule init
+       )
+'
+
+test_expect_success 'submodule add with // in path' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" slashslashsubmod///frotz// &&
+               git submodule init
+       )
+'
+
+test_expect_success 'submodule add with /.. in path' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
+               git submodule init
+       )
+'
+
+test_expect_success 'submodule add with ./, /.. and // in path' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
+               git submodule init
+       )
+'
+
 test_expect_success 'status should fail for unmapped paths' '
        if git submodule status
        then
@@ -234,4 +293,33 @@ test_expect_success 'gracefully add submodule with a trailing slash' '
 
 '
 
+test_expect_success 'ls-files gracefully handles trailing slash' '
+
+       test "init" = "$(git ls-files init/)"
+
+'
+
+test_expect_success 'submodule <invalid-path> warns' '
+
+       git submodule no-such-submodule 2> output.err &&
+       grep "^error: .*no-such-submodule" output.err
+
+'
+
+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 .. &&
+       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
+'
+
 test_done