@@ -46,41 +46,6 @@ prefix=
4646custom_name=
4747depth=
4848
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-
8449die_if_unmatched ()
8550{
8651 if test " $1 " = " #unmatched"
@@ -354,14 +319,14 @@ cmd_foreach()
354319 die_if_unmatched " $mode "
355320 if test -e " $sm_path " /.git
356321 then
357- displaypath=$( relative_path " $prefix$sm_path " )
322+ displaypath=$( git submodule--helper relative-path " $prefix$sm_path " " $wt_prefix " )
358323 say " $( eval_gettext " Entering '\$ displaypath'" ) "
359324 name=$( git submodule--helper name " $sm_path " )
360325 (
361326 prefix=" $prefix$sm_path /"
362327 sanitize_submodule_env
363328 cd " $sm_path " &&
364- sm_path=$( relative_path " $sm_path " ) &&
329+ sm_path=$( git submodule--helper relative-path " $sm_path " " $wt_prefix " ) &&
365330 # we make $path available to scripts ...
366331 path=$sm_path &&
367332 if test $# -eq 1
@@ -465,7 +430,7 @@ cmd_deinit()
465430 die_if_unmatched " $mode "
466431 name=$( git submodule--helper name " $sm_path " ) || exit
467432
468- displaypath=$( relative_path " $sm_path " )
433+ displaypath=$( git submodule--helper relative-path " $sm_path " " $wt_prefix " )
469434
470435 # Remove the submodule work tree (unless the user already did it)
471436 if test -d " $sm_path "
@@ -629,7 +594,7 @@ cmd_update()
629594 fi
630595 fi
631596
632- displaypath=$( relative_path " $prefix$sm_path " )
597+ displaypath=$( git submodule--helper relative-path " $prefix$sm_path " " $wt_prefix " )
633598
634599 if test $just_cloned -eq 1
635600 then
@@ -723,7 +688,7 @@ cmd_update()
723688 if test -n " $recursive "
724689 then
725690 (
726- prefix=$( relative_path " $prefix$sm_path /" )
691+ prefix=$( git submodule--helper relative-path " $prefix$sm_path /" " $wt_prefix " )
727692 wt_prefix=
728693 sanitize_submodule_env
729694 cd " $sm_path " &&
@@ -907,7 +872,7 @@ cmd_summary() {
907872 ! GIT_DIR=" $name /.git" git-rev-parse -q --verify $sha1_dst ^0 > /dev/null &&
908873 missing_dst=t
909874
910- display_name=$( relative_path " $name " )
875+ display_name=$( git submodule--helper relative-path " $name " " $wt_prefix " )
911876
912877 total_commits=
913878 case " $missing_src ,$missing_dst " in
@@ -1028,7 +993,7 @@ cmd_status()
1028993 die_if_unmatched " $mode "
1029994 name=$( git submodule--helper name " $sm_path " ) || exit
1030995 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 " )
1032997 if test " $stage " = U
1033998 then
1034999 say " U$sha1 $displaypath "
@@ -1131,7 +1096,7 @@ cmd_sync()
11311096
11321097 if git config " submodule.$name .url" > /dev/null 2> /dev/null
11331098 then
1134- displaypath=$( relative_path " $prefix$sm_path " )
1099+ displaypath=$( git submodule--helper relative-path " $prefix$sm_path " " $wt_prefix " )
11351100 say " $( eval_gettext " Synchronizing submodule url for '\$ displaypath'" ) "
11361101 git config submodule." $name " .url " $super_config_url "
11371102
0 commit comments