Skip to content

Commit fdd0e7a

Browse files
committed
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 <[email protected]>
1 parent 9606f58 commit fdd0e7a

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

t/t7800-difftool.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,11 @@ EOF
430430
test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstaged changes' '
431431
cat >expect <<-EOF &&
432432
file
433-
$(pwd)/file
433+
$PWD/file
434434
file2
435-
$(pwd)/file2
435+
$PWD/file2
436436
sub/sub
437-
$(pwd)/sub/sub
437+
$PWD/sub/sub
438438
EOF
439439
git difftool --dir-diff --symlink \
440440
--extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
@@ -448,14 +448,14 @@ EOF
448448
run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' '
449449
test_when_finished git reset --hard &&
450450
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 &&
452452
echo "new content" >expect &&
453453
test_cmp expect file
454454
'
455455

456456
run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
457457
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 &&
459459
echo "new content" >expect &&
460460
test_cmp expect file
461461
'
@@ -466,7 +466,7 @@ EOF
466466

467467
test_expect_success PERL 'difftool --no-symlinks does not overwrite working tree file ' '
468468
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 &&
470470
echo "new content" >expect &&
471471
test_cmp expect file
472472
'
@@ -482,7 +482,7 @@ test_expect_success PERL 'difftool --no-symlinks detects conflict ' '
482482
TMPDIR=$TRASH_DIRECTORY &&
483483
export TMPDIR &&
484484
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 &&
486486
echo "wt content" >expect &&
487487
test_cmp expect file &&
488488
echo "tmp content" >expect &&

t/t9400-git-cvsserver-server.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
2525
test_done
2626
}
2727

28-
WORKDIR=$(pwd)
29-
SERVERDIR=$(pwd)/gitcvs.git
28+
WORKDIR=$PWD
29+
SERVERDIR=$PWD/gitcvs.git
3030
git_config="$SERVERDIR/config"
3131
CVSROOT=":fork:$SERVERDIR"
32-
CVSWORK="$(pwd)/cvswork"
32+
CVSWORK="$PWD/cvswork"
3333
CVS_SERVER=git-cvsserver
3434
export CVSROOT CVS_SERVER
3535

t/t9401-git-cvsserver-crlf.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
7474
}
7575

7676
unset GIT_DIR GIT_CONFIG
77-
WORKDIR=$(pwd)
78-
SERVERDIR=$(pwd)/gitcvs.git
77+
WORKDIR=$PWD
78+
SERVERDIR=$PWD/gitcvs.git
7979
git_config="$SERVERDIR/config"
8080
CVSROOT=":fork:$SERVERDIR"
81-
CVSWORK="$(pwd)/cvswork"
81+
CVSWORK="$PWD/cvswork"
8282
CVS_SERVER=git-cvsserver
8383
export CVSROOT CVS_SERVER
8484

t/t9402-git-cvsserver-refs.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
8282
}
8383

8484
unset GIT_DIR GIT_CONFIG
85-
WORKDIR=$(pwd)
86-
SERVERDIR=$(pwd)/gitcvs.git
85+
WORKDIR=$PWD
86+
SERVERDIR=$PWD/gitcvs.git
8787
git_config="$SERVERDIR/config"
8888
CVSROOT=":fork:$SERVERDIR"
89-
CVSWORK="$(pwd)/cvswork"
89+
CVSWORK="$PWD/cvswork"
9090
CVS_SERVER=git-cvsserver
9191
export CVSROOT CVS_SERVER
9292

0 commit comments

Comments
 (0)