diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-06-13 15:27:22 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2019-06-15 09:34:21 +0200 |
commit | de70bb46ae4ea91c26f6afdc210f37b8980b7a76 (patch) | |
tree | 6f650a4b546924ef65dd9c8f9ef6302658312930 /src/ignore.c | |
parent | 451df7930db432e7b251bbd0fe2862fe96424ae9 (diff) | |
download | libgit2-de70bb46ae4ea91c26f6afdc210f37b8980b7a76.tar.gz |
global: convert trivial `fnmatch` users to use `wildcard`
Upstream git.git has converted its codebase to use wildcard in
favor of fnmatch in commit 70a8fc999d (stop using fnmatch (either
native or compat), 2014-02-15). To keep our own regex-matching in
line with what git does, convert all trivial instances of
`fnmatch` usage to use `wildcard`, instead. Trivial usage is
defined to be use of `fnmatch` with either no flags or flags that
have a 1:1 equivalent in wildmatch (PATHNAME, IGNORECASE).
Diffstat (limited to 'src/ignore.c')
-rw-r--r-- | src/ignore.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ignore.c b/src/ignore.c index 5427efa29..1d256c995 100644 --- a/src/ignore.c +++ b/src/ignore.c @@ -12,7 +12,7 @@ #include "attrcache.h" #include "path.h" #include "config.h" -#include "fnmatch.h" +#include "wildmatch.h" #define GIT_IGNORE_INTERNAL "[internal]exclude" @@ -101,7 +101,7 @@ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg) */ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match) { - int error = 0, fnflags; + int error = 0, wildmatch_flags; size_t i; git_attr_fnmatch *rule; char *path; @@ -109,9 +109,9 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match *out = 0; - fnflags = FNM_PATHNAME; + wildmatch_flags = WM_PATHNAME; if (match->flags & GIT_ATTR_FNMATCH_ICASE) - fnflags |= FNM_IGNORECASE; + wildmatch_flags |= WM_CASEFOLD; /* path of the file relative to the workdir, so we match the rules in subdirs */ if (match->containing_dir) { @@ -141,13 +141,13 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match if (git_buf_oom(&buf)) goto out; - if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) { + if ((error = wildmatch(git_buf_cstr(&buf), path, wildmatch_flags)) < 0) { git_error_set(GIT_ERROR_INVALID, "error matching pattern"); goto out; } /* if we found a match, we want to keep this rule */ - if (error != FNM_NOMATCH) { + if (error != WM_NOMATCH) { *out = 1; error = 0; goto out; |