Skip to content

Commit b738396

Browse files
dschogitster
authored andcommitted
mingw: fix regression in t1308-config-set
When we tried to fix in 58461bd (t1308: do not get fooled by symbolic links to the source tree, 2016-06-02) an obscure case where the user cd's into Git's source code via a symbolic link, a regression was introduced that affects all test runs on Windows. The original patch introducing the test case in question was careful to use `$(pwd)` instead of `$PWD`. This was done to account for the fact that Git's test suite uses shell scripting even on Windows, where the shell's Unix-y paths are incompatible with the main Git executable's idea of paths: it only accepts Windows paths. It is an awkward but necessary thing, then, to use `$(pwd)` (which gives us a Windows path) when interacting with the Git executable and `$PWD` (which gives the shell's idea of the current working directory in Unix-y form) for shell scripts, including the test suite itself. Obviously this broke the use case of the Git maintainer when changing the working directory into Git's source code directory via a symlink, i.e. when `$(pwd)` does not agree with `$PWD`. However, we must not fix that use case at the expense of regressing another use case. Let's special-case Windows here, even if it is ugly, for lack of a more elegant solution. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 20b20a2 commit b738396

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

t/t1308-config-set.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,19 @@ cmdline_config="'foo.bar=from-cmdline'"
233233
test_expect_success 'iteration shows correct origins' '
234234
echo "[foo]bar = from-repo" >.git/config &&
235235
echo "[foo]bar = from-home" >.gitconfig &&
236+
if test_have_prereq MINGW
237+
then
238+
# Use Windows path (i.e. *not* $HOME)
239+
HOME_GITCONFIG=$(pwd)/.gitconfig
240+
else
241+
# Do not get fooled by symbolic links, i.e. $HOME != $(pwd)
242+
HOME_GITCONFIG=$HOME/.gitconfig
243+
fi &&
236244
cat >expect <<-EOF &&
237245
key=foo.bar
238246
value=from-home
239247
origin=file
240-
name=$HOME/.gitconfig
248+
name=$HOME_GITCONFIG
241249
scope=global
242250
243251
key=foo.bar

0 commit comments

Comments
 (0)