Skip to content

Commit

Permalink
submodule: additional regression tests for relative URLs
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
jonseymour authored and gitster committed Jun 3, 2012
1 parent 9de9681 commit 712693e
Showing 1 changed file with 107 additions and 3 deletions.
110 changes: 107 additions & 3 deletions t/t7400-submodule-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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 &&
Expand Down

0 comments on commit 712693e

Please sign in to comment.