diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-10-27 10:48:23 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-10-29 05:19:22 +0100 |
commit | e5bbe09e88545cd1a3bcf2b157f020f92e0b5def (patch) | |
tree | fb7c8380878bffd65861a94bf9e26151b9d331d3 /wildmatch.c | |
parent | Git 2.18.1 (diff) | |
download | git-e5bbe09e88545cd1a3bcf2b157f020f92e0b5def.tar.xz git-e5bbe09e88545cd1a3bcf2b157f020f92e0b5def.zip |
wildmatch: change behavior of "foo**bar" in WM_PATHNAME mode
In WM_PATHNAME mode (or FNM_PATHNAME), '*' does not match '/' and '**'
can but only in three patterns:
- '**/' matches zero or more leading directories
- '/**/' matches zero or more directories in between
- '/**' matches zero or more trailing directories/files
When '**' is present but not in one of these patterns, the current
behavior is consider the pattern invalid and stop matching. In other
words, 'foo**bar' never matches anything, whatever you throw at it.
This behavior is arguably a bit confusing partly because we can't
really tell the user their pattern is invalid so that they can fix
it. So instead, tolerate it and make '**' act like two regular '*'s
(which is essentially the same as a single asterisk). This behavior
seems more predictable.
Noticed-by: dana <dana@dana.is>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wildmatch.c')
-rw-r--r-- | wildmatch.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/wildmatch.c b/wildmatch.c index d074c1be10..9e9e2a2f95 100644 --- a/wildmatch.c +++ b/wildmatch.c @@ -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; |