Merge branch 'tr/submodule-relative-scp-url' into maint

* tr/submodule-relative-scp-url:
  submodule: fix relative url parsing for scp-style origin
This commit is contained in:
Junio C Hamano 2011-01-19 08:26:41 -08:00
Родитель ea9590789f ea640cc691
Коммит 8a59702ad8
2 изменённых файлов: 52 добавлений и 2 удалений

Просмотреть файл

@ -37,12 +37,24 @@ resolve_relative_url ()
die "remote ($remote) does not have a url defined in .git/config" die "remote ($remote) does not have a url defined in .git/config"
url="$1" url="$1"
remoteurl=${remoteurl%/} remoteurl=${remoteurl%/}
sep=/
while test -n "$url" while test -n "$url"
do do
case "$url" in case "$url" in
../*) ../*)
url="${url#../}" url="${url#../}"
remoteurl="${remoteurl%/*}" case "$remoteurl" in
*/*)
remoteurl="${remoteurl%/*}"
;;
*:*)
remoteurl="${remoteurl%:*}"
sep=:
;;
*)
die "cannot strip one component off url '$remoteurl'"
;;
esac
;; ;;
./*) ./*)
url="${url#./}" url="${url#./}"
@ -51,7 +63,7 @@ resolve_relative_url ()
break;; break;;
esac esac
done done
echo "$remoteurl/${url%/}" echo "$remoteurl$sep${url%/}"
} }
# #

Просмотреть файл

@ -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 test_done