Re: [PATCH] t7500: fix tests with absolute path following ":(optional)" on Windows
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Oct 20, 2025, 17:24 UTC
- Message-ID
- <01e65d25-33de-4025-b3c1-52dc7d58fc27@kdbg.org>
- In-Reply-To
- <xmqqh5vt1rb0.fsf@gitster.g>
Am 20.10.25 um 18:17 schrieb Junio C Hamano:
Show 9 quoted lines
> Johannes Sixt <j6t@kdbg.org> 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