Skip to content

Commit 25e4da8

Browse files
committed
Merge branch 'nd/wildmatch-double-asterisk'
A pattern with '**' that does not have a slash on either side used to be an invalid one, but the code now treats such double-asterisks the same way as two normal asterisks that happen to be adjacent to each other. * nd/wildmatch-double-asterisk: wildmatch: change behavior of "foo**bar" in WM_PATHNAME mode
2 parents 8c758f9 + e5bbe09 commit 25e4da8

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

Documentation/gitignore.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ full pathname may have special meaning:
129129
matches zero or more directories. For example, "`a/**/b`"
130130
matches "`a/b`", "`a/x/b`", "`a/x/y/b`" and so on.
131131

132-
- Other consecutive asterisks are considered invalid.
132+
- Other consecutive asterisks are considered regular asterisks and
133+
will match according to the previous rules.
133134

134135
NOTES
135136
-----

t/t3070-wildmatch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ match 0 0 0 0 foobar 'foo\*bar'
237237
match 1 1 1 1 'f\oo' 'f\\oo'
238238
match 1 1 1 1 ball '*[al]?'
239239
match 0 0 0 0 ten '[ten]'
240-
match 0 0 1 1 ten '**[!te]'
240+
match 1 1 1 1 ten '**[!te]'
241241
match 0 0 0 0 ten '**[!ten]'
242242
match 1 1 1 1 ten 't[a-g]n'
243243
match 0 0 0 0 ten 't[!a-g]n'
@@ -253,7 +253,7 @@ match 1 1 1 1 ']' ']'
253253
# Extended slash-matching features
254254
match 0 0 1 1 'foo/baz/bar' 'foo*bar'
255255
match 0 0 1 1 'foo/baz/bar' 'foo**bar'
256-
match 0 0 1 1 'foobazbar' 'foo**bar'
256+
match 1 1 1 1 'foobazbar' 'foo**bar'
257257
match 1 1 1 1 'foo/baz/bar' 'foo/**/bar'
258258
match 1 1 0 0 'foo/baz/bar' 'foo/**/**/bar'
259259
match 1 1 1 1 'foo/b/a/z/bar' 'foo/**/bar'

wildmatch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
104104
dowild(p + 1, text, flags) == WM_MATCH)
105105
return WM_MATCH;
106106
match_slash = 1;
107-
} else
108-
return WM_ABORT_MALFORMED;
107+
} else /* WM_PATHNAME is set */
108+
match_slash = 0;
109109
} else
110110
/* without WM_PATHNAME, '*' == '**' */
111111
match_slash = flags & WM_PATHNAME ? 0 : 1;

wildmatch.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#define WM_CASEFOLD 1
55
#define WM_PATHNAME 2
66

7-
#define WM_ABORT_MALFORMED 2
87
#define WM_NOMATCH 1
98
#define WM_MATCH 0
109
#define WM_ABORT_ALL -1

0 commit comments

Comments
 (0)