summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-01-13 19:34:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-01-13 19:34:39 (GMT)
commit4f93fc745ab4f51339ffb3b0e49a5f28a4c2a337 (patch)
tree92043345eeba362ecd1356a94067ec80d614021a
parent3e70e37e72207e780ca1c6e86bbc3c2963e6038c (diff)
parentea640cc691d56f7151c5ba654b09c4a987dbef93 (diff)
downloadgit-4f93fc745ab4f51339ffb3b0e49a5f28a4c2a337.zip
git-4f93fc745ab4f51339ffb3b0e49a5f28a4c2a337.tar.gz
git-4f93fc745ab4f51339ffb3b0e49a5f28a4c2a337.tar.bz2
Merge branch 'tr/submodule-relative-scp-url'
* tr/submodule-relative-scp-url: submodule: fix relative url parsing for scp-style origin
-rwxr-xr-xgit-submodule.sh16
-rwxr-xr-xt/t7400-submodule-basic.sh38
2 files changed, 52 insertions, 2 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index c21b77a..8b90589 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -37,12 +37,24 @@ resolve_relative_url ()
die "remote ($remote) does not have a url defined in .git/config"
url="$1"
remoteurl=${remoteurl%/}
+ sep=/
while test -n "$url"
do
case "$url" in
../*)
url="${url#../}"
- remoteurl="${remoteurl%/*}"
+ case "$remoteurl" in
+ */*)
+ remoteurl="${remoteurl%/*}"
+ ;;
+ *:*)
+ remoteurl="${remoteurl%:*}"
+ sep=:
+ ;;
+ *)
+ die "cannot strip one component off url '$remoteurl'"
+ ;;
+ esac
;;
./*)
url="${url#./}"
@@ -51,7 +63,7 @@ resolve_relative_url ()
break;;
esac
done
- echo "$remoteurl/${url%/}"
+ echo "$remoteurl$sep${url%/}"
}
#
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 2c49db9..874279e 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -446,4 +446,42 @@ test_expect_success 'add should fail when path is used by an existing directory'
)
'
+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