Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 75c8664

Browse files
hvoigtkasal
authored andcommitted
Windows: Always normalize paths to Windows-style
It appears that `pwd` returns the POSIX-style or the DOS-style path depending which style the previous `cd` used. To normalize, enforce `pwd -W` in scripts. From the original e-mail exchange: On Thu, Mar 22, 2012 at 11:13:37AM +0100, Sebastian Schuberth wrote: > On Wed, Mar 21, 2012 at 22:21, Johannes Sixt <[email protected]> wrote: > > > I build git and run its tests outside the msysgit environment. Does that > > explain the difference? (And I use CMD.) > > It does not make a difference for me. I started cmd.exe at > c:\msysgit\git\t, added c:\msysgit\bin temporarily to PATH, and ran > "sh t5526-fetch-submodules.sh -i -v", and the test still fails. Yes it probably does. Johannes said that he runs the tests outside of the msysgit folder. That way there is only one path the submodule script gets reported and not two like '/c/msysgit/git' and '/git'. That would explain to me why it is passing. I am afraid that the only solution is to patch msys itself to report the long absolute path when passing window style paths to cd. Currently when I do cd c:/msysgit/git I will end up in '/git' instead of the long path. I found that there is a -W option to pwd in msys bash which makes it always return the real windows path. A normalization in that direction is unique and thus might be more robust. Have a look at the attached patch. With this at least t5526 passes. I was not able to run the whole testsuite properly at the moment. I can have a look at that tomorrow. What do you think? Cheers Heiko Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d4c3651 commit 75c8664

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

git-sh-setup.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,8 @@ case $(uname -s) in
304304
find () {
305305
/usr/bin/find "$@"
306306
}
307-
# git sees Windows-style pwd
308-
pwd () {
309-
builtin pwd -W
310-
}
307+
# Let pwd always return the uniqe real windows path
308+
alias pwd='pwd -W'
311309
is_absolute_path () {
312310
case "$1" in
313311
[/\\]* | [A-Za-z]:*)

git-submodule.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,6 @@ module_clone()
285285
# resolve any symlinks that might be present in $PWD
286286
a=$(cd_to_toplevel && cd "$gitdir" && pwd)/
287287
b=$(cd_to_toplevel && cd "$sm_path" && pwd)/
288-
# normalize Windows-style absolute paths to POSIX-style absolute paths
289-
case $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} ;; esac
290-
case $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} ;; esac
291288
# Remove all common leading directories after a sanity check
292289
if test "${a#$b}" != "$a" || test "${b#$a}" != "$b"; then
293290
die "$(eval_gettext "Gitdir '\$a' is part of the submodule path '\$b' or vice versa")"

0 commit comments

Comments
 (0)