These tests document failures to detect submodule URLs that backtrack past the 'invariant' part of a superproject's origin URL. For example: if the origin URL is ssh://hostname/repo, then currently if a submodule URL is specified as ../../subrepo, then git will construct a submodule url of the form ssh://subrepo/ without complaint. Signed-off-by: Jon Seymour <jon.seymour@xxxxxxxxx> --- t/t7400-submodule-basic.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 9428c7a..a758c63 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -543,10 +543,80 @@ test_expect_success '../subrepo works with helper URL- helper:://hostname/repo' ) ' +test_expect_failure '../../subrepo fails 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 config -f .gitmodules submodule.sub.url ../../subrepo && + echo cannot strip one component off url \'ssh://hostname/\' > expected && + test_must_fail git submodule init 2>actual && + #actual no failure, url configured as ssh://subrepo + test_cmp expected actual + ) +" + +test_expect_failure '../../subrepo fails with absolute local path - /repo' " + ( + cd reltest && + cp pristine-.git-config .git/config && + cp pristine-.gitmodules .gitmodules && + git config remote.origin.url /repo && + git config -f .gitmodules submodule.sub.url ../../subrepo && + echo cannot strip one component off url \'/\' > expected && + test_must_fail git submodule init 2>actual && + test_cmp expected actual + ) +" + +test_expect_failure '../../../subrepo fails 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 config -f .gitmodules submodule.sub.url ../../../subrepo && + echo cannot strip one component off url \'ssh://hostname/\' > expected && + test_must_fail git submodule init 2>actual && + #actual no failure, url configured as ssh:/subrepo + test_cmp expected actual + ) +" + +test_expect_failure '../../../../subrepo fails with 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 config -f .gitmodules submodule.sub.url ../../../../subrepo && + echo cannot strip one component off url \'ssh://hostname/\' > expected && + test_must_fail git submodule init 2>actual && + #actual no failure, url configured as ssh:/subrepo + test_cmp expected actual + ) +" + +test_expect_failure '../../../../../subrepo fails 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 config -f .gitmodules submodule.sub.url ../../../../../subrepo && + echo cannot strip one component off url \'ssh://hostname/\' > expected && + test_must_fail git submodule init 2>actual && + #actual cannot strip one component off url 'ssh' + test_cmp expected actual + ) +" + test_expect_success '../subrepo works with scp-style URL - user@host:repo' ' ( cd reltest && cp pristine-.git-config .git/config && + cp pristine-.gitmodules .gitmodules && git config remote.origin.url user@host:repo && git submodule init && test "$(git config submodule.sub.url)" = user@host:subrepo -- 1.7.10.2.656.gb5a46db -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html