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." Signed-off-by: Kristofer Karlsson <krka@spotify.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kristofer Karlsson committed May 28, 2026 at 09:00 UTC 8c84e6802c0e23503bfe655dadcdc4a15de7373a
1 file changed +13 -6
t/t3070-wildmatch.sh
+13 -6
@@ -99,6 +99,13 @@ match_with_ls_files() {
99 match_function=$4
100 ls_files_args=$5
101
102 + prereqs=EXPENSIVE_ON_WINDOWS
103 + case "$pattern" in
104 + *\\*)
105 + prereqs="$prereqs,BSLASHPSPEC"
106 + ;;
107 + esac
108 +
109 match_stdout_stderr_cmp="
110 tr -d '\0' <actual.raw >actual &&
111 test_must_be_empty actual.err &&
@@ -108,36 +115,36 @@ match_with_ls_files() {
115 then
116 if test -e .git/created_test_file
117 then
111 - test_expect_success EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match dies on '$pattern' '$text'" "
118 + test_expect_success $prereqs "$match_function (via ls-files): match dies on '$pattern' '$text'" "
119 printf '%s' '$text' >expect &&
120 test_must_fail git$ls_files_args ls-files -z -- '$pattern'
121 "
122 else
116 - test_expect_failure EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
123 + test_expect_failure $prereqs "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
124 fi
125 elif test "$match_expect" = 1
126 then
127 if test -e .git/created_test_file
128 then
122 - test_expect_success EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match '$pattern' '$text'" "
129 + test_expect_success $prereqs "$match_function (via ls-files): match '$pattern' '$text'" "
130 printf '%s' '$text' >expect &&
131 git$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&
132 $match_stdout_stderr_cmp
133 "
134 else
128 - test_expect_failure EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
135 + test_expect_failure $prereqs "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
136 fi
137 elif test "$match_expect" = 0
138 then
139 if test -e .git/created_test_file
140 then
134 - test_expect_success EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): no match '$pattern' '$text'" "
141 + test_expect_success $prereqs "$match_function (via ls-files): no match '$pattern' '$text'" "
142 >expect &&
143 git$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&
144 $match_stdout_stderr_cmp
145 "
146 else
140 - test_expect_failure EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): no match skip '$pattern' '$text'" 'false'
147 + test_expect_failure $prereqs "$match_function (via ls-files): no match skip '$pattern' '$text'" 'false'
148 fi
149 else
150 test_expect_success "PANIC: Test framework error. Unknown matches value $match_expect" 'false'