Skip to content

Commit ef49841

Browse files
pcloudsgitster
authored andcommitted
test-wildmatch: avoid Windows path mangling
The MSYS bash mangles arguments that begin with a forward slash when they are passed to test-wildmatch. This causes tests to fail. Avoid mangling by prepending "XXX", which is removed by test-wildmatch before further processing. [J6t: reworded commit message] Reported-by: Johannes Sixt <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Johannes Sixt <[email protected]>
1 parent 237ec6e commit ef49841

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

t/t3070-wildmatch.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ match 0 0 'foo/bar' 'foo[/]bar'
7474
match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
7575
match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
7676
match 1 0 'foo' '**/foo'
77-
match 1 x '/foo' '**/foo'
77+
match 1 x 'XXX/foo' '**/foo'
7878
match 1 0 'bar/baz/foo' '**/foo'
7979
match 0 0 'bar/baz/foo' '*/foo'
8080
match 0 0 'foo/bar/baz' '**/bar*'
@@ -95,8 +95,8 @@ match 0 0 ']' '[!]-]'
9595
match 1 x 'a' '[!]-]'
9696
match 0 0 '' '\'
9797
match 0 x '\' '\'
98-
match 0 x '/\' '*/\'
99-
match 1 x '/\' '*/\\'
98+
match 0 x 'XXX/\' '*/\'
99+
match 1 x 'XXX/\' '*/\\'
100100
match 1 1 'foo' 'foo'
101101
match 1 1 '@foo' '@foo'
102102
match 0 0 'foo' '@foo'
@@ -187,8 +187,8 @@ match 0 0 '-' '[[-\]]'
187187
match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
188188
match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
189189
match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
190-
match 1 1 '/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' '/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
191-
match 0 0 '/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' '/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
190+
match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
191+
match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
192192
match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
193193
match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
194194

test-wildmatch.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

44
int main(int argc, char **argv)
55
{
6+
int i;
7+
for (i = 2; i < argc; i++) {
8+
if (argv[i][0] == '/')
9+
die("Forward slash is not allowed at the beginning of the\n"
10+
"pattern because Windows does not like it. Use `XXX/' instead.");
11+
else if (!strncmp(argv[i], "XXX/", 4))
12+
argv[i] += 3;
13+
}
614
if (!strcmp(argv[1], "wildmatch"))
715
return !!wildmatch(argv[3], argv[2], 0);
816
else if (!strcmp(argv[1], "iwildmatch"))

0 commit comments

Comments
 (0)