Subject: Re: [PATCH] t7500: fix tests with absolute path following ":(optional)" on Windows

From: Johannes Sixt <[email-masked]>
Date: Mon, 20 Oct 2025 19:24:47 +0200

Am 20.10.25 um 18:17 schrieb Junio C Hamano:
> Johannes Sixt <[email-masked]> writes:
> 
>> Existing test cases that expect that the specified file does not exist
>> are not incorrect (after all, git.exe will not find /c/dir/template).
>> Yet, they are conceptually incorrect.
> 
> Wow, if I am counting correctly, the oldest one is from July 2007,
> and we have been running these tests without anybody noticing?
> That's just ... wow.

Obviously, I didn't do a great job in explaining the situation. It isn't
*that* bad.

Before the invention of the ":(optional)" prefix, the tests are totally
fine, because /c/dir/template or /c/dir/notexist always appear as an
isolated command line argument. Then they are translated to
C:/dir/template and C:/dir/notexist as expected.

The tests become wrong-in-spirit only in combination with the
":(optional)" prefix, because now the MSYS layer sees
":(optional)/c/dir/notexist", which is not an absolute path. Yet, all
tests with the ":(optional)" prefix before this patch still work as
expected, because all expect the path to not exist. And from git.exe's
point of view, /c/dir/notexist does not exist.

The new test case would fail if $PWD was used, because it expects that
the file exists, but MSYS does not translate
":(optional)/c/dir/template" to ":(optional)C:/dir/template". So, we
must do the translation in the test script itself by using $(pwd). For
consistency, all other test cases with the ":(optional)" should then use
$(pwd), too. All remaining test cases could keep using $PWD, but I
changed them to $(pwd) for even more consistency.

-- Hannes