* [PATCH] t3070: skip ls-files tests with backslash patterns on Windows
@ 2026-05-28 9:00 Kristofer Karlsson via GitGitGadget
2026-05-28 20:25 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Kristofer Karlsson via GitGitGadget @ 2026-05-28 9:00 UTC (permalink / raw)
To: git; +Cc: @dscho, Kristofer Karlsson, Kristofer Karlsson
From: Kristofer Karlsson <krka@spotify.com>
On Windows (MINGW), backslashes in pathspecs are silently converted to
forward slashes (directory separators), which changes the glob semantics.
This causes 36 test failures in t3070-wildmatch when the "via ls-files"
variants test patterns containing backslash escapes (e.g. '\[ab]',
'[\-_]', '[A-\\]').
The wildmatch function itself handles these patterns correctly — only the
ls-files code path fails because pathspec parsing converts the
backslashes before they reach the glob matcher.
Skip these ls-files tests on platforms where BSLASHPSPEC is not set,
which is the existing prereq that captures exactly this semantic:
"backslashes in pathspec are not directory separators."
Signed-off-by: Kristofer Karlsson <krka@spotify.com>
---
t3070: skip ls-files tests with backslash patterns on Windows
On Windows (MINGW), backslashes in pathspecs are silently converted to
forward slashes (directory separators), which changes the glob
semantics. This causes 36 test failures in t3070-wildmatch when the "via
ls-files" variants test patterns containing backslash escapes (e.g.
\[ab], [\-_], [A-\\]).
The wildmatch function itself handles these patterns correctly — only
the ls-files code path fails because pathspec parsing converts the
backslashes before they reach the glob matcher.
Skip these ls-files tests on platforms where BSLASHPSPEC is not set,
which is the existing prereq that captures exactly this semantic:
"backslashes in pathspec are not directory separators."
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2128%2Fspkrka%2Fwildmatch-windows-fix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2128/spkrka/wildmatch-windows-fix-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2128
t/t3070-wildmatch.sh | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
index 655bb1a0f2..3394122218 100755
--- a/t/t3070-wildmatch.sh
+++ b/t/t3070-wildmatch.sh
@@ -99,6 +99,13 @@ match_with_ls_files() {
match_function=$4
ls_files_args=$5
+ prereqs=EXPENSIVE_ON_WINDOWS
+ case "$pattern" in
+ *\\*)
+ prereqs="$prereqs,BSLASHPSPEC"
+ ;;
+ esac
+
match_stdout_stderr_cmp="
tr -d '\0' <actual.raw >actual &&
test_must_be_empty actual.err &&
@@ -108,36 +115,36 @@ match_with_ls_files() {
then
if test -e .git/created_test_file
then
- test_expect_success EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match dies on '$pattern' '$text'" "
+ test_expect_success $prereqs "$match_function (via ls-files): match dies on '$pattern' '$text'" "
printf '%s' '$text' >expect &&
test_must_fail git$ls_files_args ls-files -z -- '$pattern'
"
else
- test_expect_failure EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
+ test_expect_failure $prereqs "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
fi
elif test "$match_expect" = 1
then
if test -e .git/created_test_file
then
- test_expect_success EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match '$pattern' '$text'" "
+ test_expect_success $prereqs "$match_function (via ls-files): match '$pattern' '$text'" "
printf '%s' '$text' >expect &&
git$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&
$match_stdout_stderr_cmp
"
else
- test_expect_failure EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
+ test_expect_failure $prereqs "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
fi
elif test "$match_expect" = 0
then
if test -e .git/created_test_file
then
- test_expect_success EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): no match '$pattern' '$text'" "
+ test_expect_success $prereqs "$match_function (via ls-files): no match '$pattern' '$text'" "
>expect &&
git$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&
$match_stdout_stderr_cmp
"
else
- test_expect_failure EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): no match skip '$pattern' '$text'" 'false'
+ test_expect_failure $prereqs "$match_function (via ls-files): no match skip '$pattern' '$text'" 'false'
fi
else
test_expect_success "PANIC: Test framework error. Unknown matches value $match_expect" 'false'
base-commit: c69baaf57ba26cf117c2b6793802877f19738b0d
--
gitgitgadget
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] t3070: skip ls-files tests with backslash patterns on Windows
2026-05-28 9:00 [PATCH] t3070: skip ls-files tests with backslash patterns on Windows Kristofer Karlsson via GitGitGadget
@ 2026-05-28 20:25 ` Junio C Hamano
2026-05-29 8:04 ` Kristofer Karlsson
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2026-05-28 20:25 UTC (permalink / raw)
To: Kristofer Karlsson via GitGitGadget
Cc: git, Johannes Schindelin, Kristofer Karlsson
"Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Kristofer Karlsson <krka@spotify.com>
>
> On Windows (MINGW), backslashes in pathspecs are silently converted to
> forward slashes (directory separators), which changes the glob semantics.
> This causes 36 test failures in t3070-wildmatch when the "via ls-files"
> variants test patterns containing backslash escapes (e.g. '\[ab]',
> '[\-_]', '[A-\\]').
>
> The wildmatch function itself handles these patterns correctly — only the
> ls-files code path fails because pathspec parsing converts the
> backslashes before they reach the glob matcher.
>
> Skip these ls-files tests on platforms where BSLASHPSPEC is not set,
> which is the existing prereq that captures exactly this semantic:
> "backslashes in pathspec are not directory separators."
>
> Signed-off-by: Kristofer Karlsson <krka@spotify.com>
> ---
Thanks for noticing and addressing this. I think we fairly recently
started seeing this in GitHub actions CI, which puzzles me since
neither t3070 or wildmatch.[ch] have changed for quite some time.
8a6d158a (doc: document backslash in gitignore patterns, 2025-10-29)
added a few lines to the test about matching with backslash to t3070.
Two questions.
* Has this been broken on Windows since October, or has something
external change on Windows recently? I do not know. Anybody
knows?
* Is this change a workaround that sweeps ugly breakage under the
rug, or is backslash inherently unusable as an excape character
when handling paths on Windows (which I am afraid would make
wildmatch fairly useless there)?
Will queue. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] t3070: skip ls-files tests with backslash patterns on Windows
2026-05-28 20:25 ` Junio C Hamano
@ 2026-05-29 8:04 ` Kristofer Karlsson
2026-06-03 14:23 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Kristofer Karlsson @ 2026-05-29 8:04 UTC (permalink / raw)
To: Junio C Hamano
Cc: Kristofer Karlsson via GitGitGadget, git, Johannes Schindelin
On Thu, 28 May 2026 at 22:26, Junio C Hamano <gitster@pobox.com> wrote:
> Two questions.
>
> * Has this been broken on Windows since October, or has something
> external change on Windows recently? I do not know. Anybody
> knows?
>
> * Is this change a workaround that sweeps ugly breakage under the
> rug, or is backslash inherently unusable as an excape character
> when handling paths on Windows (which I am afraid would make
> wildmatch fairly useless there)?
>
I am fairly new to the git ecosystem as a developer (not as a user),
so I am not sure how long this has been broken. The backslash patterns
in the ls-files test path predate 8a6d158a - patterns like 'foo\*'
and '[\-_]' have been there since de8bada2bf (2018) - so it may
have been failing for a while before anyone noticed.
My thinking was that it would be good in general if the CI results
were green and did not include false positives for errors that we
know cannot work on this platform. The risk is that people stop
looking into CI failures in detail because they start to assume it
is the same old backslash problem.
That said, there is also a risk that the real underlying issue does
not get fixed. I am hoping it is sufficient that the BSLASHPSPEC
prereq and the case *\\* filter make it obvious to anyone reading
the test what we are skipping over and why.
> Will queue. Thanks.
Thanks! It felt a bit heavyweight to add noise to the list for trivial CI test
changes but I suppose the process is the same even if it does not
affect the production code.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] t3070: skip ls-files tests with backslash patterns on Windows
2026-05-29 8:04 ` Kristofer Karlsson
@ 2026-06-03 14:23 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2026-06-03 14:23 UTC (permalink / raw)
To: Kristofer Karlsson
Cc: Kristofer Karlsson via GitGitGadget, git, Johannes Schindelin
Kristofer Karlsson <krka@spotify.com> writes:
> On Thu, 28 May 2026 at 22:26, Junio C Hamano <gitster@pobox.com> wrote:
>> Two questions.
>>
>> * Has this been broken on Windows since October, or has something
>> external change on Windows recently? I do not know. Anybody
>> knows?
>>
>> * Is this change a workaround that sweeps ugly breakage under the
>> rug, or is backslash inherently unusable as an excape character
>> when handling paths on Windows (which I am afraid would make
>> wildmatch fairly useless there)?
>>
>
> I am fairly new to the git ecosystem as a developer (not as a user),
> so I am not sure how long this has been broken. The backslash patterns
> in the ls-files test path predate 8a6d158a - patterns like 'foo\*'
> and '[\-_]' have been there since de8bada2bf (2018) - so it may
> have been failing for a while before anyone noticed.
Hmph.
> My thinking was that it would be good in general if the CI results
> were green and did not include false positives for errors that we
> know cannot work on this platform. The risk is that people stop
> looking into CI failures in detail because they start to assume it
> is the same old backslash problem.
Oh, no question about that.
> That said, there is also a risk that the real underlying issue does
> not get fixed. I am hoping it is sufficient that the BSLASHPSPEC
> prereq and the case *\\* filter make it obvious to anyone reading
> the test what we are skipping over and why.
>
>> Will queue. Thanks.
>
> Thanks! It felt a bit heavyweight to add noise to the list for trivial CI test
> changes but I suppose the process is the same even if it does not
> affect the production code.
Sure. I just found it a little disturbing to declare that there
won't be ways on Windows to quote special letters with backslash
when writing wildmatch patterns. But if some Windows folks got
motivated enough, they are capable of lifting the prereq when they
fix the underlying code as well, so it probably is not something I
should be worrying too much about.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-03 14:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-28 9:00 [PATCH] t3070: skip ls-files tests with backslash patterns on Windows Kristofer Karlsson via GitGitGadget
2026-05-28 20:25 ` Junio C Hamano
2026-05-29 8:04 ` Kristofer Karlsson
2026-06-03 14:23 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox