remote-curl: let users turn off smart http
[gitweb.git] / t / t7400-submodule-basic.sh
index 9428c7a744cbcfd973b3da7cdd7b6d1d3d374c8a..56a81cd7486716897cc4f08196d0815a62461ffd 100755 (executable)
@@ -258,6 +258,27 @@ test_expect_success 'init should register submodule url in .git/config' '
        test_cmp expect url
 '
 
+test_failure_with_unknown_submodule () {
+       test_must_fail git submodule $1 no-such-submodule 2>output.err &&
+       grep "^error: .*no-such-submodule" output.err
+}
+
+test_expect_success 'init should fail with unknown submodule' '
+       test_failure_with_unknown_submodule init
+'
+
+test_expect_success 'update should fail with unknown submodule' '
+       test_failure_with_unknown_submodule update
+'
+
+test_expect_success 'status should fail with unknown submodule' '
+       test_failure_with_unknown_submodule status
+'
+
+test_expect_success 'sync should fail with unknown submodule' '
+       test_failure_with_unknown_submodule sync
+'
+
 test_expect_success 'update should fail when path is used by a file' '
        echo hello >expect &&
 
@@ -418,10 +439,7 @@ test_expect_success 'moving to a commit without submodule does not leave empty d
 '
 
 test_expect_success 'submodule <invalid-path> warns' '
-
-       git submodule no-such-submodule 2> output.err &&
-       grep "^error: .*no-such-submodule" output.err
-
+       test_failure_with_unknown_submodule
 '
 
 test_expect_success 'add submodules without specifying an explicit path' '
@@ -510,14 +528,19 @@ test_expect_success '../subrepo works with port-qualified URL - ssh://hostname:2
        )
 '
 
-test_expect_success '../subrepo path works with local path - /foo/repo' '
+# About the choice of the path in the next test:
+# - double-slash side-steps path mangling issues on Windows
+# - it is still an absolute local path
+# - there cannot be a server with a blank in its name just in case the
+#   path is used erroneously to access a //server/share style path
+test_expect_success '../subrepo path works with local path - //somewhere else/repo' '
        (
                cd reltest &&
                cp pristine-.git-config .git/config &&
                cp pristine-.gitmodules .gitmodules &&
-               git config remote.origin.url /foo/repo &&
+               git config remote.origin.url "//somewhere else/repo" &&
                git submodule init &&
-               test "$(git config submodule.sub.url)" = /foo/subrepo
+               test "$(git config submodule.sub.url)" = "//somewhere else/subrepo"
        )
 '
 
@@ -564,6 +587,18 @@ test_expect_success '../subrepo works with scp-style URL - user@host:path/to/rep
        )
 '
 
+test_expect_success '../subrepo works with relative local path - foo' '
+       (
+               cd reltest &&
+               cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
+               git config remote.origin.url foo &&
+               # actual: fails with an error
+               git submodule init &&
+               test "$(git config submodule.sub.url)" = subrepo
+       )
+'
+
 test_expect_success '../subrepo works with relative local path - foo/bar' '
        (
                cd reltest &&
@@ -575,6 +610,28 @@ test_expect_success '../subrepo works with relative local path - foo/bar' '
        )
 '
 
+test_expect_success '../subrepo works with relative local path - ./foo' '
+       (
+               cd reltest &&
+               cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
+               git config remote.origin.url ./foo &&
+               git submodule init &&
+               test "$(git config submodule.sub.url)" = subrepo
+       )
+'
+
+test_expect_success '../subrepo works with relative local path - ./foo/bar' '
+       (
+               cd reltest &&
+               cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
+               git config remote.origin.url ./foo/bar &&
+               git submodule init &&
+               test "$(git config submodule.sub.url)" = foo/subrepo
+       )
+'
+
 test_expect_success '../subrepo works with relative local path - ../foo' '
        (
                cd reltest &&