Skip to content

Commit 25f81cb

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 f45805d commit 25f81cb

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
@@ -438,11 +438,11 @@ EOF
438438
test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstaged changes' '
439439
cat >expect <<-EOF &&
440440
file
441-
$(pwd)/file
441+
$PWD/file
442442
file2
443-
$(pwd)/file2
443+
$PWD/file2
444444
sub/sub
445-
$(pwd)/sub/sub
445+
$PWD/sub/sub
446446
EOF
447447
git difftool --dir-diff --symlink \
448448
--extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
@@ -456,14 +456,14 @@ EOF
456456
run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' '
457457
test_when_finished git reset --hard &&
458458
echo "orig content" >file &&
459-
git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch &&
459+
git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
460460
echo "new content" >expect &&
461461
test_cmp expect file
462462
'
463463

464464
run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
465465
test_when_finished git reset --hard &&
466-
git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch &&
466+
git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
467467
echo "new content" >expect &&
468468
test_cmp expect file
469469
'
@@ -474,7 +474,7 @@ EOF
474474

475475
test_expect_success PERL 'difftool --no-symlinks does not overwrite working tree file ' '
476476
echo "orig content" >file &&
477-
git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-file" branch &&
477+
git difftool --dir-diff --no-symlinks --extcmd "$PWD/modify-file" branch &&
478478
echo "new content" >expect &&
479479
test_cmp expect file
480480
'
@@ -490,7 +490,7 @@ test_expect_success PERL 'difftool --no-symlinks detects conflict ' '
490490
TMPDIR=$TRASH_DIRECTORY &&
491491
export TMPDIR &&
492492
echo "orig content" >file &&
493-
test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-both-files" branch &&
493+
test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$PWD/modify-both-files" branch &&
494494
echo "wt content" >expect &&
495495
test_cmp expect file &&
496496
echo "tmp content" >expect &&

t/t9400-git-cvsserver-server.sh

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

36-
WORKDIR=$(pwd)
37-
SERVERDIR=$(pwd)/gitcvs.git
36+
WORKDIR=$PWD
37+
SERVERDIR=$PWD/gitcvs.git
3838
git_config="$SERVERDIR/config"
3939
CVSROOT=":fork:$SERVERDIR"
40-
CVSWORK="$(pwd)/cvswork"
40+
CVSWORK="$PWD/cvswork"
4141
CVS_SERVER=git-cvsserver
4242
export CVSROOT CVS_SERVER
4343

t/t9401-git-cvsserver-crlf.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

t/t9402-git-cvsserver-refs.sh

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

9292
unset GIT_DIR GIT_CONFIG
93-
WORKDIR=$(pwd)
94-
SERVERDIR=$(pwd)/gitcvs.git
93+
WORKDIR=$PWD
94+
SERVERDIR=$PWD/gitcvs.git
9595
git_config="$SERVERDIR/config"
9696
CVSROOT=":fork:$SERVERDIR"
97-
CVSWORK="$(pwd)/cvswork"
97+
CVSWORK="$PWD/cvswork"
9898
CVS_SERVER=git-cvsserver
9999
export CVSROOT CVS_SERVER
100100

0 commit comments

Comments
 (0)