File tree Expand file tree Collapse file tree 2 files changed +52
-2
lines changed
Expand file tree Collapse file tree 2 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,24 @@ resolve_relative_url ()
3737 die " remote ($remote ) does not have a url defined in .git/config"
3838 url=" $1 "
3939 remoteurl=${remoteurl%/ }
40+ sep=/
4041 while test -n " $url "
4142 do
4243 case " $url " in
4344 ../* )
4445 url=" ${url# ../ } "
45- remoteurl=" ${remoteurl%/* } "
46+ case " $remoteurl " in
47+ * /* )
48+ remoteurl=" ${remoteurl%/* } "
49+ ;;
50+ * :* )
51+ remoteurl=" ${remoteurl%:* } "
52+ sep=:
53+ ;;
54+ * )
55+ die " cannot strip one component off url '$remoteurl '"
56+ ;;
57+ esac
4658 ;;
4759 ./* )
4860 url=" ${url# ./ } "
@@ -51,7 +63,7 @@ resolve_relative_url ()
5163 break ;;
5264 esac
5365 done
54- echo " $remoteurl / ${url%/ } "
66+ echo " $remoteurl$sep ${url%/ } "
5567}
5668
5769#
Original file line number Diff line number Diff line change @@ -446,4 +446,42 @@ test_expect_success 'add should fail when path is used by an existing directory'
446446 )
447447'
448448
449+ test_expect_success ' set up for relative path tests' '
450+ mkdir reltest &&
451+ (
452+ cd reltest &&
453+ git init &&
454+ mkdir sub &&
455+ (
456+ cd sub &&
457+ git init &&
458+ test_commit foo
459+ ) &&
460+ git add sub &&
461+ git config -f .gitmodules submodule.sub.path sub &&
462+ git config -f .gitmodules submodule.sub.url ../subrepo &&
463+ cp .git/config pristine-.git-config
464+ )
465+ '
466+
467+ test_expect_success ' relative path works with URL' '
468+ (
469+ cd reltest &&
470+ cp pristine-.git-config .git/config &&
471+ git config remote.origin.url ssh://hostname/repo &&
472+ git submodule init &&
473+ test "$(git config submodule.sub.url)" = ssh://hostname/subrepo
474+ )
475+ '
476+
477+ test_expect_success ' relative path works with user@host:path' '
478+ (
479+ cd reltest &&
480+ cp pristine-.git-config .git/config &&
481+ git config remote.origin.url user@host:repo &&
482+ git submodule init &&
483+ test "$(git config submodule.sub.url)" = user@host:subrepo
484+ )
485+ '
486+
449487test_done
You can’t perform that action at this time.
0 commit comments