Skip to content

Commit 64a8a03

Browse files
hvoigtdscho
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 1729079 commit 64a8a03

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

git-sh-setup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ case $(uname -s) in
250250
find () {
251251
/usr/bin/find "$@"
252252
}
253+
# Let pwd always return the uniqe real windows path
254+
alias pwd='pwd -W'
253255
is_absolute_path () {
254256
case "$1" in
255257
[/\\]* | [A-Za-z]:*)

git-submodule.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ 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
157154
# Remove all common leading directories after a sanity check
158155
if test "${a#$b}" != "$a" || test "${b#$a}" != "$b"; then
159156
die "$(eval_gettext "Gitdir '\$a' is part of the submodule path '\$b' or vice versa")"

0 commit comments

Comments
 (0)