]> git.ipfire.org Git - thirdparty/git.git/commit
t7500: fix tests with absolute path following ":(optional)" on Windows
authorJohannes Sixt <j6t@kdbg.org>
Mon, 20 Oct 2025 09:40:08 +0000 (11:40 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Oct 2025 16:16:49 +0000 (09:16 -0700)
commit91e6a645e75026a42977e37f24fca3f1fe54de58
treee4baf41f8c9baadecaef4a5c3e3f1b3175ed3ef6
parentccfcaf399ffcc91553395a8de8e833e7685e7cc2
t7500: fix tests with absolute path following ":(optional)" on Windows

On Windows, the MSYS layer translates absolute path names generated by
a shell script from the POSIX style /c/dir/file to the Windows style
C:/dir/file form that is understood by git.exe. This happens only when
the absolute path stands on its own as a program argument or a value of
an environment variable.

The earlier commits 749d6d166d (config: values of pathname type can be
prefixed with :(optional), 2025-09-28) and ccfcaf399f (parseopt: values
of pathname type can be prefixed with :(optional), 2025-09-28) added
test cases where ":(optional)" is inserted before an absolute path.
$PWD is used to construct the absolute paths, which gives the POSIX
form, and the result is ":(optional)/c/dir/template". Such command line
arguments are no longer recognized as absolute paths and do not undergo
translation.

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. That the use of $PWD is erroneous
is revealed by a test case that expects that the optional file exists.
Since no such test case is present, add one. Use "$(pwd)" to generate
the absolute paths, so that the command line arguments become
":(optional)C:/dir/template".

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7500-commit-template-squash-signoff.sh