Skip to content

Commit

Permalink
submodules: fix ambiguous absolute paths under Windows
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Sixt authored and Junio C Hamano committed Mar 5, 2012
1 parent 69c3051 commit 4dce7d9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ module_clone()

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

0 comments on commit 4dce7d9

Please sign in to comment.