submodule: fix relative url parsing for scp-style origin

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>
This commit is contained in:
Thomas Rast
2011-01-10 11:37:26 +01:00
committed by Junio C Hamano
parent cb198b3b67
commit ea640cc691
2 changed files with 52 additions and 2 deletions

View File

@ -36,12 +36,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#./}"
@ -50,7 +62,7 @@ resolve_relative_url ()
break;;
esac
done
echo "$remoteurl/${url%/}"
echo "$remoteurl$sep${url%/}"
}
#