summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cb198b3)
raw | patch | inline | side by side (parent: cb198b3)
author | Thomas Rast <trast@student.ethz.ch> | |
Mon, 10 Jan 2011 10:37:26 +0000 (11:37 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 10 Jan 2011 17:10:54 +0000 (09:10 -0800) |
The function resolve_relative_url was not prepared to deal with an
scp-style origin 'user@host:path' in the case where 'path' is only a
single component. Fix this by extending the logic that strips one
path component from the $remoteurl.
Also add tests for both styles of URLs.
Noticed-by: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
scp-style origin 'user@host:path' in the case where 'path' is only a
single component. Fix this by extending the logic that strips one
path component from the $remoteurl.
Also add tests for both styles of URLs.
Noticed-by: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-submodule.sh | patch | blob | history | |
t/t7400-submodule-basic.sh | patch | blob | history |
diff --git a/git-submodule.sh b/git-submodule.sh
index d3c583d0113e133b8fc75b533ff3f88d2a9c7efe..ac371e62536641df62e340d8f2105c9e9505a5a7 100755 (executable)
--- a/git-submodule.sh
+++ b/git-submodule.sh
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#./}"
break;;
esac
done
- echo "$remoteurl/${url%/}"
+ echo "$remoteurl$sep${url%/}"
}
#
index 1a4dc5f89353df7d7bda4bea539ee5bd7a3b9bae..8b004f60d68561d0a4d6701bfc0ad8525a596117 100755 (executable)
git config -f .gitmodules submodule.bare.path bare
'
+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