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 ()
37
37
die " remote ($remote ) does not have a url defined in .git/config"
38
38
url=" $1 "
39
39
remoteurl=${remoteurl%/ }
40
+ sep=/
40
41
while test -n " $url "
41
42
do
42
43
case " $url " in
43
44
../* )
44
45
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
46
58
;;
47
59
./* )
48
60
url=" ${url# ./ } "
@@ -51,7 +63,7 @@ resolve_relative_url ()
51
63
break ;;
52
64
esac
53
65
done
54
- echo " $remoteurl / ${url%/ } "
66
+ echo " $remoteurl$sep ${url%/ } "
55
67
}
56
68
57
69
#
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'
446
446
)
447
447
'
448
448
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
+
449
487
test_done
You can’t perform that action at this time.
0 commit comments