@@ -46,41 +46,6 @@ prefix=
46
46
custom_name=
47
47
depth=
48
48
49
- # Resolve a path to be relative to another path. This is intended for
50
- # converting submodule paths when git-submodule is run in a subdirectory
51
- # and only handles paths where the directory separator is '/'.
52
- #
53
- # The output is the first argument as a path relative to the second argument,
54
- # which defaults to $wt_prefix if it is omitted.
55
- relative_path ()
56
- {
57
- local target curdir result
58
- target=$1
59
- curdir=${2-$wt_prefix }
60
- curdir=${curdir%/ }
61
- result=
62
-
63
- while test -n " $curdir "
64
- do
65
- case " $target " in
66
- " $curdir /" * )
67
- target=${target# " $curdir " / }
68
- break
69
- ;;
70
- esac
71
-
72
- result=" ${result} ../"
73
- if test " $curdir " = " ${curdir%/* } "
74
- then
75
- curdir=
76
- else
77
- curdir=" ${curdir%/* } "
78
- fi
79
- done
80
-
81
- echo " $result$target "
82
- }
83
-
84
49
die_if_unmatched ()
85
50
{
86
51
if test " $1 " = " #unmatched"
@@ -354,14 +319,14 @@ cmd_foreach()
354
319
die_if_unmatched " $mode "
355
320
if test -e " $sm_path " /.git
356
321
then
357
- displaypath=$( relative_path " $prefix$sm_path " )
322
+ displaypath=$( git submodule--helper relative-path " $prefix$sm_path " " $wt_prefix " )
358
323
say " $( eval_gettext " Entering '\$ displaypath'" ) "
359
324
name=$( git submodule--helper name " $sm_path " )
360
325
(
361
326
prefix=" $prefix$sm_path /"
362
327
sanitize_submodule_env
363
328
cd " $sm_path " &&
364
- sm_path=$( relative_path " $sm_path " ) &&
329
+ sm_path=$( git submodule--helper relative-path " $sm_path " " $wt_prefix " ) &&
365
330
# we make $path available to scripts ...
366
331
path=$sm_path &&
367
332
if test $# -eq 1
@@ -465,7 +430,7 @@ cmd_deinit()
465
430
die_if_unmatched " $mode "
466
431
name=$( git submodule--helper name " $sm_path " ) || exit
467
432
468
- displaypath=$( relative_path " $sm_path " )
433
+ displaypath=$( git submodule--helper relative-path " $sm_path " " $wt_prefix " )
469
434
470
435
# Remove the submodule work tree (unless the user already did it)
471
436
if test -d " $sm_path "
@@ -629,7 +594,7 @@ cmd_update()
629
594
fi
630
595
fi
631
596
632
- displaypath=$( relative_path " $prefix$sm_path " )
597
+ displaypath=$( git submodule--helper relative-path " $prefix$sm_path " " $wt_prefix " )
633
598
634
599
if test $just_cloned -eq 1
635
600
then
@@ -723,7 +688,7 @@ cmd_update()
723
688
if test -n " $recursive "
724
689
then
725
690
(
726
- prefix=$( relative_path " $prefix$sm_path /" )
691
+ prefix=$( git submodule--helper relative-path " $prefix$sm_path /" " $wt_prefix " )
727
692
wt_prefix=
728
693
sanitize_submodule_env
729
694
cd " $sm_path " &&
@@ -907,7 +872,7 @@ cmd_summary() {
907
872
! GIT_DIR=" $name /.git" git-rev-parse -q --verify $sha1_dst ^0 > /dev/null &&
908
873
missing_dst=t
909
874
910
- display_name=$( relative_path " $name " )
875
+ display_name=$( git submodule--helper relative-path " $name " " $wt_prefix " )
911
876
912
877
total_commits=
913
878
case " $missing_src ,$missing_dst " in
@@ -1028,7 +993,7 @@ cmd_status()
1028
993
die_if_unmatched " $mode "
1029
994
name=$( git submodule--helper name " $sm_path " ) || exit
1030
995
url=$( git config submodule." $name " .url)
1031
- displaypath=$( relative_path " $prefix$sm_path " )
996
+ displaypath=$( git submodule--helper relative-path " $prefix$sm_path " " $wt_prefix " )
1032
997
if test " $stage " = U
1033
998
then
1034
999
say " U$sha1 $displaypath "
@@ -1131,7 +1096,7 @@ cmd_sync()
1131
1096
1132
1097
if git config " submodule.$name .url" > /dev/null 2> /dev/null
1133
1098
then
1134
- displaypath=$( relative_path " $prefix$sm_path " )
1099
+ displaypath=$( git submodule--helper relative-path " $prefix$sm_path " " $wt_prefix " )
1135
1100
say " $( eval_gettext " Synchronizing submodule url for '\$ displaypath'" ) "
1136
1101
git config submodule." $name " .url " $super_config_url "
1137
1102
0 commit comments