use wildmatch() directly without fnmatch() wrapper
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 15 Feb 2014 02:01:46 +0000 (09:01 +0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Feb 2014 22:15:46 +0000 (14:15 -0800)
Make it clear that we don't use fnmatch() anymore.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 files changed:
builtin/apply.c
builtin/branch.c
builtin/describe.c
builtin/for-each-ref.c
builtin/ls-remote.c
builtin/name-rev.c
builtin/reflog.c
builtin/replace.c
builtin/show-branch.c
builtin/tag.c
diffcore-order.c
dir.c
refs.c
revision.c
index b0d0986226ccb7fa06b08bacba6269b8834e8dd6..66e2eed539ab663556b769d4eb02ad7cbb002287 100644 (file)
@@ -4152,7 +4152,7 @@ static int use_patch(struct patch *p)
        /* See if it matches any of exclude/include rule */
        for (i = 0; i < limit_by_name.nr; i++) {
                struct string_list_item *it = &limit_by_name.items[i];
-               if (!fnmatch(it->string, pathname, 0))
+               if (!wildmatch(it->string, pathname, 0, NULL))
                        return (it->util != NULL);
        }
 
index b4d771673e7e9dccacbae8b29f4f1cd6a835151f..652b1d2d1484032fab51165f1d0b0a41426d114f 100644 (file)
@@ -315,7 +315,7 @@ static int match_patterns(const char **pattern, const char *refname)
        if (!*pattern)
                return 1; /* no pattern always matches */
        while (*pattern) {
-               if (!fnmatch(*pattern, refname, 0))
+               if (!wildmatch(*pattern, refname, 0, NULL))
                        return 1;
                pattern++;
        }
index 7db43dae1be95e86c21249d9150fc8553c367527..848acdf299ea8d4751e44027ab8af182742a87ac 100644 (file)
@@ -150,7 +150,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
                return 0;
 
        /* Accept only tags that match the pattern, if given */
-       if (pattern && (!is_tag || fnmatch(pattern, path + 10, 0)))
+       if (pattern && (!is_tag || wildmatch(pattern, path + 10, 0, NULL)))
                return 0;
 
        /* Is it annotated? */
index 51798b48b54266fccd2f7b4687646d152ab70588..3e1d5c3334e50035fdbf835cfdafbb39c0bacfd0 100644 (file)
@@ -864,7 +864,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
                             refname[plen] == '/' ||
                             p[plen-1] == '/'))
                                break;
-                       if (!fnmatch(p, refname, FNM_PATHNAME))
+                       if (!wildmatch(p, refname, WM_PATHNAME, NULL))
                                break;
                }
                if (!*pattern)
index 39e5144b9e38f1319f8fb881af6b1d34ad0c4089..3e9eefb0915a4496ead9ddbf3836a4455351dba0 100644 (file)
@@ -22,7 +22,7 @@ static int tail_match(const char **pattern, const char *path)
        if (snprintf(pathbuf, sizeof(pathbuf), "/%s", path) > sizeof(pathbuf))
                return error("insanely long ref %.*s...", 20, path);
        while ((p = *(pattern++)) != NULL) {
-               if (!fnmatch(p, pathbuf, 0))
+               if (!wildmatch(p, pathbuf, 0, NULL))
                        return 1;
        }
        return 0;
index 0b21d7e5b297ff3d2d1a73d8a74c8bc37e672ccb..c824d4ec5f1c076e4833c690dad378125dde6da9 100644 (file)
@@ -87,7 +87,7 @@ static int subpath_matches(const char *path, const char *filter)
        const char *subpath = path;
 
        while (subpath) {
-               if (!fnmatch(filter, subpath, 0))
+               if (!wildmatch(filter, subpath, 0, NULL))
                        return subpath - path;
                subpath = strchr(subpath, '/');
                if (subpath)
index 852cff60b784d316cddb59234b6276dfe18fd75d..c12a9784e6b45d50129b786a45bb5f4e4dd0801a 100644 (file)
@@ -561,7 +561,7 @@ static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, c
                return; /* both given explicitly -- nothing to tweak */
 
        for (ent = reflog_expire_cfg; ent; ent = ent->next) {
-               if (!fnmatch(ent->pattern, ref, 0)) {
+               if (!wildmatch(ent->pattern, ref, 0, NULL)) {
                        if (!(slot & EXPIRE_TOTAL))
                                cb->expire_total = ent->expire_total;
                        if (!(slot & EXPIRE_UNREACH))
index 2336325ce330f5268800a7bc949c066ce028852c..80b152a86c4ea3d003b113ae0402a5f1fb701b3d 100644 (file)
@@ -36,7 +36,7 @@ static int show_reference(const char *refname, const unsigned char *sha1,
 {
        struct show_data *data = cb_data;
 
-       if (!fnmatch(data->pattern, refname, 0)) {
+       if (!wildmatch(data->pattern, refname, 0, NULL)) {
                if (data->format == REPLACE_FORMAT_SHORT)
                        printf("%s\n", refname);
                else if (data->format == REPLACE_FORMAT_MEDIUM)
index d9217ce1e1a957462284224c08786db77f5a8f15..d87317290c0bbfffb7ac66fb7cff5c608f092d93 100644 (file)
@@ -450,7 +450,7 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i
                        slash--;
        if (!*tail)
                return 0;
-       if (fnmatch(match_ref_pattern, tail, 0))
+       if (wildmatch(match_ref_pattern, tail, 0, NULL))
                return 0;
        if (starts_with(refname, "refs/heads/"))
                return append_head_ref(refname, sha1, flag, cb_data);
index 74d3780b77548fc8a7bb2f51b47a51cbfb51969a..169c676636ff6b320f32f13126a5ff46b222f879 100644 (file)
@@ -42,7 +42,7 @@ static int match_pattern(const char **patterns, const char *ref)
        if (!*patterns)
                return 1;
        for (; *patterns; patterns++)
-               if (!fnmatch(*patterns, ref, 0))
+               if (!wildmatch(*patterns, ref, 0, NULL))
                        return 1;
        return 0;
 }
index fe7f1f4647a16a5882cc4c1e63738c7faa4bc677..53ea4d14c2e3a79f05d4c77895e4e60b507f5820 100644 (file)
@@ -73,7 +73,7 @@ static int match_order(const char *path)
                strbuf_addstr(&p, path);
                while (p.buf[0]) {
                        char *cp;
-                       if (!fnmatch(order[i], p.buf, 0))
+                       if (!wildmatch(order[i], p.buf, 0, NULL))
                                return i;
                        cp = strrchr(p.buf, '/');
                        if (!cp)
diff --git a/dir.c b/dir.c
index b35b6330f850f610b582b189d7e4d6a9ba4495db..59ccb5218ad27f35093b1f9abced9bf8a7dd9374 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -49,7 +49,9 @@ int strncmp_icase(const char *a, const char *b, size_t count)
 
 int fnmatch_icase(const char *pattern, const char *string, int flags)
 {
-       return fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 0));
+       return wildmatch(pattern, string,
+                        flags | (ignore_case ? WM_CASEFOLD : 0),
+                        NULL);
 }
 
 inline int git_fnmatch(const struct pathspec_item *item,
@@ -58,7 +60,7 @@ inline int git_fnmatch(const struct pathspec_item *item,
 {
        if (prefix > 0) {
                if (ps_strncmp(item, pattern, string, prefix))
-                       return FNM_NOMATCH;
+                       return WM_NOMATCH;
                pattern += prefix;
                string += prefix;
        }
@@ -76,8 +78,9 @@ inline int git_fnmatch(const struct pathspec_item *item,
                                 NULL);
        else
                /* wildmatch has not learned no FNM_PATHNAME mode yet */
-               return fnmatch(pattern, string,
-                              item->magic & PATHSPEC_ICASE ? FNM_CASEFOLD : 0);
+               return wildmatch(pattern, string,
+                                item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0,
+                                NULL);
 }
 
 static int fnmatch_icase_mem(const char *pattern, int patternlen,
diff --git a/refs.c b/refs.c
index 89228e23732ef7e2e83a2e84e82ffb5bd7afec3f..f89d589182fcfc595ff1d60f01ffe25e1ea81579 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1477,7 +1477,7 @@ static int filter_refs(const char *refname, const unsigned char *sha1, int flags
                       void *data)
 {
        struct ref_filter *filter = (struct ref_filter *)data;
-       if (fnmatch(filter->pattern, refname, 0))
+       if (wildmatch(filter->pattern, refname, 0, NULL))
                return 0;
        return filter->fn(refname, sha1, flags, filter->cb_data);
 }
index a0df72f32c100a68e5d99b5b00e597d43f3802a5..6addff1b5fcbfbffe6e30b9f72eea75d8bf755bc 100644 (file)
@@ -1191,7 +1191,7 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
        if (!ref_excludes)
                return 0;
        for_each_string_list_item(item, ref_excludes) {
-               if (!fnmatch(item->string, path, 0))
+               if (!wildmatch(item->string, path, 0, NULL))
                        return 1;
        }
        return 0;