From: Junio C Hamano Date: Mon, 10 Jan 2011 18:37:25 +0000 (-0800) Subject: Merge branch 'tr/submodule-relative-scp-url' into next X-Git-Tag: ko-next~20 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=895f88738d0de0a48091494c27123ed9c42a71a0;p=git.git Merge branch 'tr/submodule-relative-scp-url' into next * tr/submodule-relative-scp-url: submodule: fix relative url parsing for scp-style origin --- 895f88738d0de0a48091494c27123ed9c42a71a0 diff --cc t/t7400-submodule-basic.sh index 2c49db9f6,8b004f60d..874279e32 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@@ -413,37 -317,56 +413,75 @@@ test_expect_success 'submodule r && - git add r && - git commit -m "repo commit 1" && - cd .. && + ( + cd repo && + git init && + echo r >r && + git add r && + git commit -m "repo commit 1" + ) && 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 + ( + 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_expect_success 'add should fail when path is used by a file' ' + ( + cd addtest && + touch file && + test_must_fail git submodule add "$submodurl/repo" file + ) +' + +test_expect_success 'add should fail when path is used by an existing directory' ' + ( + cd addtest && + mkdir empty-dir && + test_must_fail git submodule add "$submodurl/repo" empty-dir + ) ' + test_expect_success 'set up for relative path tests' ' + mkdir reltest && + ( + cd reltest && + git init && + mkdir sub && + ( + cd sub && + git init && + test_commit foo + ) && + 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 + ) + ' + + test_expect_success 'relative path works with URL' ' + ( + cd reltest && + cp pristine-.git-config .git/config && + 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' ' + ( + cd reltest && + cp pristine-.git-config .git/config && + git config remote.origin.url user@host:repo && + git submodule init && + test "$(git config submodule.sub.url)" = user@host:subrepo + ) + ' + test_done