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 <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Mar 4, 2012 at 22:16 UTC 4dce7d9b408b2935b85721b54a2010eda7ec1be9
1 file changed +3
git-submodule.sh
+3
@@ -151,6 +151,9 @@ module_clone()
151
152 a=$(cd "$gitdir" && pwd)/
153 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
157 # Remove all common leading directories after a sanity check
158 if test "${a#$b}" != "$a" || test "${b#$a}" != "$b"; then
159 die "$(eval_gettext "Gitdir '\$a' is part of the submodule path '\$b' or vice versa")"