Skip to content

Commit 4dce7d9

Browse files
j6tgitster
authored andcommitted
submodules: fix ambiguous absolute paths under Windows
Under Windows the "git rev-parse --git-dir" and "pwd" commands may return either drive-letter-colon or POSIX style paths. This makes module_clone() behave badly because it expects absolute paths to always start with a '/'. Fix that by always converting the "c:/" notation into "/c/" when computing the relative paths from gitdir to the submodule work tree and back. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 69c3051 commit 4dce7d9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

git-submodule.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ module_clone()
151151

152152
a=$(cd "$gitdir" && pwd)/
153153
b=$(cd "$path" && pwd)/
154+
# normalize Windows-style absolute paths to POSIX-style absolute paths
155+
case $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} ;; esac
156+
case $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} ;; esac
154157
# Remove all common leading directories after a sanity check
155158
if test "${a#$b}" != "$a" || test "${b#$a}" != "$b"; then
156159
die "$(eval_gettext "Gitdir '\$a' is part of the submodule path '\$b' or vice versa")"

0 commit comments

Comments
 (0)