Skip to content

Commit

Permalink
Merge branch 'nd/wildmatch-double-asterisk'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gitster committed Nov 13, 2018
2 parents 8c758f9 + e5bbe09 commit 25e4da8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Documentation/gitignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ full pathname may have special meaning:
matches zero or more directories. For example, "`a/**/b`"
matches "`a/b`", "`a/x/b`", "`a/x/y/b`" and so on.

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

NOTES
-----
Expand Down
4 changes: 2 additions & 2 deletions t/t3070-wildmatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ match 0 0 0 0 foobar 'foo\*bar'
match 1 1 1 1 'f\oo' 'f\\oo'
match 1 1 1 1 ball '*[al]?'
match 0 0 0 0 ten '[ten]'
match 0 0 1 1 ten '**[!te]'
match 1 1 1 1 ten '**[!te]'
match 0 0 0 0 ten '**[!ten]'
match 1 1 1 1 ten 't[a-g]n'
match 0 0 0 0 ten 't[!a-g]n'
Expand All @@ -253,7 +253,7 @@ match 1 1 1 1 ']' ']'
# Extended slash-matching features
match 0 0 1 1 'foo/baz/bar' 'foo*bar'
match 0 0 1 1 'foo/baz/bar' 'foo**bar'
match 0 0 1 1 'foobazbar' 'foo**bar'
match 1 1 1 1 'foobazbar' 'foo**bar'
match 1 1 1 1 'foo/baz/bar' 'foo/**/bar'
match 1 1 0 0 'foo/baz/bar' 'foo/**/**/bar'
match 1 1 1 1 'foo/b/a/z/bar' 'foo/**/bar'
Expand Down
4 changes: 2 additions & 2 deletions wildmatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
dowild(p + 1, text, flags) == WM_MATCH)
return WM_MATCH;
match_slash = 1;
} else
return WM_ABORT_MALFORMED;
} else /* WM_PATHNAME is set */
match_slash = 0;
} else
/* without WM_PATHNAME, '*' == '**' */
match_slash = flags & WM_PATHNAME ? 0 : 1;
Expand Down
1 change: 0 additions & 1 deletion wildmatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#define WM_CASEFOLD 1
#define WM_PATHNAME 2

#define WM_ABORT_MALFORMED 2
#define WM_NOMATCH 1
#define WM_MATCH 0
#define WM_ABORT_ALL -1
Expand Down

0 comments on commit 25e4da8

Please sign in to comment.