submodule: additional regression tests for relative URLs
authorJon Seymour <jon.seymour@gmail.com>
Sun, 3 Jun 2012 09:46:47 +0000 (19:46 +1000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 3 Jun 2012 21:34:47 +0000 (14:34 -0700)
Some additional tests are added to support regression testing of the changes in the
remainder of the series.

We also add a pristine copy of .gitmodules in anticipation of this being
required by later tests.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7400-submodule-basic.sh

index 81827e696f21f598357313d6dad94400d8562718..9428c7a744cbcfd973b3da7cdd7b6d1d3d374c8a 100755 (executable)
@@ -483,21 +483,67 @@ test_expect_success 'set up for relative path tests' '
                git add sub &&
                git config -f .gitmodules submodule.sub.path sub &&
                git config -f .gitmodules submodule.sub.url ../subrepo &&
-               cp .git/config pristine-.git-config
+               cp .git/config pristine-.git-config &&
+               cp .gitmodules pristine-.gitmodules
        )
 '
 
-test_expect_success 'relative path works with URL' '
+test_expect_success '../subrepo works with URL - ssh://hostname/repo' '
        (
                cd reltest &&
                cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
                git config remote.origin.url ssh://hostname/repo &&
                git submodule init &&
                test "$(git config submodule.sub.url)" = ssh://hostname/subrepo
        )
 '
 
-test_expect_success 'relative path works with user@host:path' '
+test_expect_success '../subrepo works with port-qualified URL - ssh://hostname:22/repo' '
+       (
+               cd reltest &&
+               cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
+               git config remote.origin.url ssh://hostname:22/repo &&
+               git submodule init &&
+               test "$(git config submodule.sub.url)" = ssh://hostname:22/subrepo
+       )
+'
+
+test_expect_success '../subrepo path works with local path - /foo/repo' '
+       (
+               cd reltest &&
+               cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
+               git config remote.origin.url /foo/repo &&
+               git submodule init &&
+               test "$(git config submodule.sub.url)" = /foo/subrepo
+       )
+'
+
+test_expect_success '../subrepo works with file URL - file:///tmp/repo' '
+       (
+               cd reltest &&
+               cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
+               git config remote.origin.url file:///tmp/repo &&
+               git submodule init &&
+               test "$(git config submodule.sub.url)" = file:///tmp/subrepo
+       )
+'
+
+test_expect_success '../subrepo works with helper URL- helper:://hostname/repo' '
+       (
+               cd reltest &&
+               cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
+               git config remote.origin.url helper:://hostname/repo &&
+               git submodule init &&
+               test "$(git config submodule.sub.url)" = helper:://hostname/subrepo
+       )
+'
+
+test_expect_success '../subrepo works with scp-style URL - user@host:repo' '
        (
                cd reltest &&
                cp pristine-.git-config .git/config &&
@@ -507,6 +553,64 @@ test_expect_success 'relative path works with user@host:path' '
        )
 '
 
+test_expect_success '../subrepo works with scp-style URL - user@host:path/to/repo' '
+       (
+               cd reltest &&
+               cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
+               git config remote.origin.url user@host:path/to/repo &&
+               git submodule init &&
+               test "$(git config submodule.sub.url)" = user@host:path/to/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 &&
+               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 '../bar/a/b/c works with relative local path - ../foo/bar.git' '
+       (
+               cd reltest &&
+               cp pristine-.git-config .git/config &&
+               cp pristine-.gitmodules .gitmodules &&
+               mkdir -p a/b/c &&
+               (cd a/b/c; git init) &&
+               git config remote.origin.url ../foo/bar.git &&
+               git submodule add ../bar/a/b/c ./a/b/c &&
+               git submodule init &&
+               test "$(git config submodule.a/b/c.url)" = ../foo/bar/a/b/c
+       )
+'
+
 test_expect_success 'moving the superproject does not break submodules' '
        (
                cd addtest &&