mingw: work around pwd issues in the tests

In Git for Windows' SDK, the tests are run using a Bash that relies on the POSIX emulation layer MSYS2 (itself a friendly fork of Cygwin). As such, paths in tests can be POSIX paths. As soon as those paths are passed to git.exe (which does *not* use the POSIX emulation layer), those paths are converted into Windows paths, though. This happens for command-line parameters, but not when reading, say, config variables. To help with that, the `pwd` command is overridden to return the Windows path of the current working directory when testing Git on Windows. However, when talking to anything using the POSIX emulation layer, it is really much better to use POSIX paths because Windows paths contain a colon after the drive letter that will easily be mistaken for the common separator in path lists. So let's just use the $PWD variable when the POSIX path is needed. This lets t7800-difftool.sh, t9400-git-cvsserver-server.sh, t9402-git-cvsserver-refs.sh and t9401-git-cvsserver-crlf.sh pass in Git for Windows' SDK. Note: the cvsserver tests require not only the `cvs` package (install it into Git for Windows' SDK via `pacman -S cvs`) but also the Perl SQLite bindings (install them into Git for Windows' SDK via `cpan DBD::SQLite`). This patch is based on earlier work by 마누엘 and Karsten Blees. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jan 27, 2016 at 17:19 UTC fd318a941d8bb7cc832412f26a25313121cc0d21
4 files changed +16 -16
t/t7800-difftool.sh
+7 -7
@@ -430,11 +430,11 @@ EOF
430 test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstaged changes' '
431 cat >expect <<-EOF &&
432 file
433 - $(pwd)/file
433 + $PWD/file
434 file2
435 - $(pwd)/file2
435 + $PWD/file2
436 sub/sub
437 - $(pwd)/sub/sub
437 + $PWD/sub/sub
438 EOF
439 git difftool --dir-diff --symlink \
440 --extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
@@ -448,14 +448,14 @@ EOF
448 run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' '
449 test_when_finished git reset --hard &&
450 echo "orig content" >file &&
451 - git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch &&
451 + git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
452 echo "new content" >expect &&
453 test_cmp expect file
454 '
455
456 run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
457 test_when_finished git reset --hard &&
458 - git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch &&
458 + git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
459 echo "new content" >expect &&
460 test_cmp expect file
461 '
@@ -466,7 +466,7 @@ EOF
466
467 test_expect_success PERL 'difftool --no-symlinks does not overwrite working tree file ' '
468 echo "orig content" >file &&
469 - git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-file" branch &&
469 + git difftool --dir-diff --no-symlinks --extcmd "$PWD/modify-file" branch &&
470 echo "new content" >expect &&
471 test_cmp expect file
472 '
@@ -482,7 +482,7 @@ test_expect_success PERL 'difftool --no-symlinks detects conflict ' '
482 TMPDIR=$TRASH_DIRECTORY &&
483 export TMPDIR &&
484 echo "orig content" >file &&
485 - test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-both-files" branch &&
485 + test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$PWD/modify-both-files" branch &&
486 echo "wt content" >expect &&
487 test_cmp expect file &&
488 echo "tmp content" >expect &&
t/t9400-git-cvsserver-server.sh
+3 -3
@@ -25,11 +25,11 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
25 test_done
26 }
27
28 -WORKDIR=$(pwd)
29 -SERVERDIR=$(pwd)/gitcvs.git
28 +WORKDIR=$PWD
29 +SERVERDIR=$PWD/gitcvs.git
30 git_config="$SERVERDIR/config"
31 CVSROOT=":fork:$SERVERDIR"
32 -CVSWORK="$(pwd)/cvswork"
32 +CVSWORK="$PWD/cvswork"
33 CVS_SERVER=git-cvsserver
34 export CVSROOT CVS_SERVER
35
t/t9401-git-cvsserver-crlf.sh
+3 -3
@@ -74,11 +74,11 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
74 }
75
76 unset GIT_DIR GIT_CONFIG
77 -WORKDIR=$(pwd)
78 -SERVERDIR=$(pwd)/gitcvs.git
77 +WORKDIR=$PWD
78 +SERVERDIR=$PWD/gitcvs.git
79 git_config="$SERVERDIR/config"
80 CVSROOT=":fork:$SERVERDIR"
81 -CVSWORK="$(pwd)/cvswork"
81 +CVSWORK="$PWD/cvswork"
82 CVS_SERVER=git-cvsserver
83 export CVSROOT CVS_SERVER
84
t/t9402-git-cvsserver-refs.sh
+3 -3
@@ -82,11 +82,11 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
82 }
83
84 unset GIT_DIR GIT_CONFIG
85 -WORKDIR=$(pwd)
86 -SERVERDIR=$(pwd)/gitcvs.git
85 +WORKDIR=$PWD
86 +SERVERDIR=$PWD/gitcvs.git
87 git_config="$SERVERDIR/config"
88 CVSROOT=":fork:$SERVERDIR"
89 -CVSWORK="$(pwd)/cvswork"
89 +CVSWORK="$PWD/cvswork"
90 CVS_SERVER=git-cvsserver
91 export CVSROOT CVS_SERVER
92