Skip to content

Commit 4114156

Browse files
committed
Tests on Windows: $(pwd) must return Windows-style paths
Many tests pass $(pwd) in some form to git and later test that the output of git contains the correct value of $(pwd). For example, the test of 'git remote show' sets up a remote that contains $(pwd) and then the expected result must contain $(pwd). Again, MSYS-bash's path mangling kicks in: Plain $(pwd) uses the MSYS style absolute path /c/path/to/git. The test case would write this name into the 'expect' file. But when git is invoked, MSYS-bash converts this name to the Windows style path c:/path/to/git, and git would produce this form in the result; the test would fail. We fix this by passing -W to bash's pwd that produces the Windows-style path. There are a two cases that need an accompanying change: - In t1504 the value of $(pwd) becomes part of a path list. In this case, the lone 'c' in something like /foo:c:/path/to/git:/bar inhibits MSYS-bashes path mangling; IOW in this case we want the /c/path/to/git form to allow path mangling. We use $PWD instead of $(pwd), which always has the latter form. - In t6200, $(pwd) - the Windows style path - must be used to construct the expected result because that is the path form that git sees. (The change in the test itself is just for consistency: 'git fetch' always sees the Windows-style path, with or without the change.) Signed-off-by: Johannes Sixt <j6t@kdbg.org>
1 parent 5397ea3 commit 4114156

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

t/t1504-ceiling-dirs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test_fail() {
1313
"git rev-parse --show-prefix"
1414
}
1515

16-
TRASH_ROOT="$(pwd)"
16+
TRASH_ROOT="$PWD"
1717
ROOT_PARENT=$(dirname "$TRASH_ROOT")
1818

1919

t/t6200-fmt-merge-msg.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ test_expect_success 'merge-msg test #1' '
8383
'
8484

8585
cat >expected <<EOF
86-
Merge branch 'left' of $TEST_DIRECTORY/$test
86+
Merge branch 'left' of $(pwd)
8787
EOF
8888

8989
test_expect_success 'merge-msg test #2' '
9090
9191
git checkout master &&
92-
git fetch "$TEST_DIRECTORY/$test" left &&
92+
git fetch "$(pwd)" left &&
9393
9494
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
9595
test_cmp expected actual

t/test-lib.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,5 +649,9 @@ case $(uname -s) in
649649
sum () {
650650
md5sum "$@"
651651
}
652+
# git sees Windows-style pwd
653+
pwd () {
654+
builtin pwd -W
655+
}
652656
;;
653657
esac

0 commit comments

Comments
 (0)