use wildmatch() directly without fnmatch() wrapper

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>

Nguyễn Thái Ngọc Duy committed Feb 15, 2014 at 09:01 UTC eb07894fe036566acccb71420ab79ccb9c9e2d66
14 files changed +20 -17
builtin/apply.c
+1 -1
@@ -4152,7 +4152,7 @@ static int use_patch(struct patch *p)
4152 /* See if it matches any of exclude/include rule */
4153 for (i = 0; i < limit_by_name.nr; i++) {
4154 struct string_list_item *it = &limit_by_name.items[i];
4155 - if (!fnmatch(it->string, pathname, 0))
4155 + if (!wildmatch(it->string, pathname, 0, NULL))
4156 return (it->util != NULL);
4157 }
4158
builtin/branch.c
+1 -1
@@ -315,7 +315,7 @@ static int match_patterns(const char **pattern, const char *refname)
315 if (!*pattern)
316 return 1; /* no pattern always matches */
317 while (*pattern) {
318 - if (!fnmatch(*pattern, refname, 0))
318 + if (!wildmatch(*pattern, refname, 0, NULL))
319 return 1;
320 pattern++;
321 }
builtin/describe.c
+1 -1
@@ -150,7 +150,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
150 return 0;
151
152 /* Accept only tags that match the pattern, if given */
153 - if (pattern && (!is_tag || fnmatch(pattern, path + 10, 0)))
153 + if (pattern && (!is_tag || wildmatch(pattern, path + 10, 0, NULL)))
154 return 0;
155
156 /* Is it annotated? */
builtin/for-each-ref.c
+1 -1
@@ -864,7 +864,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
864 refname[plen] == '/' ||
865 p[plen-1] == '/'))
866 break;
867 - if (!fnmatch(p, refname, FNM_PATHNAME))
867 + if (!wildmatch(p, refname, WM_PATHNAME, NULL))
868 break;
869 }
870 if (!*pattern)
builtin/ls-remote.c
+1 -1
@@ -22,7 +22,7 @@ static int tail_match(const char **pattern, const char *path)
22 if (snprintf(pathbuf, sizeof(pathbuf), "/%s", path) > sizeof(pathbuf))
23 return error("insanely long ref %.*s...", 20, path);
24 while ((p = *(pattern++)) != NULL) {
25 - if (!fnmatch(p, pathbuf, 0))
25 + if (!wildmatch(p, pathbuf, 0, NULL))
26 return 1;
27 }
28 return 0;
builtin/name-rev.c
+1 -1
@@ -87,7 +87,7 @@ static int subpath_matches(const char *path, const char *filter)
87 const char *subpath = path;
88
89 while (subpath) {
90 - if (!fnmatch(filter, subpath, 0))
90 + if (!wildmatch(filter, subpath, 0, NULL))
91 return subpath - path;
92 subpath = strchr(subpath, '/');
93 if (subpath)
builtin/reflog.c
+1 -1
@@ -561,7 +561,7 @@ static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, c
561 return; /* both given explicitly -- nothing to tweak */
562
563 for (ent = reflog_expire_cfg; ent; ent = ent->next) {
564 - if (!fnmatch(ent->pattern, ref, 0)) {
564 + if (!wildmatch(ent->pattern, ref, 0, NULL)) {
565 if (!(slot & EXPIRE_TOTAL))
566 cb->expire_total = ent->expire_total;
567 if (!(slot & EXPIRE_UNREACH))
builtin/replace.c
+1 -1
@@ -36,7 +36,7 @@ static int show_reference(const char *refname, const unsigned char *sha1,
36 {
37 struct show_data *data = cb_data;
38
39 - if (!fnmatch(data->pattern, refname, 0)) {
39 + if (!wildmatch(data->pattern, refname, 0, NULL)) {
40 if (data->format == REPLACE_FORMAT_SHORT)
41 printf("%s\n", refname);
42 else if (data->format == REPLACE_FORMAT_MEDIUM)
builtin/show-branch.c
+1 -1
@@ -450,7 +450,7 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i
450 slash--;
451 if (!*tail)
452 return 0;
453 - if (fnmatch(match_ref_pattern, tail, 0))
453 + if (wildmatch(match_ref_pattern, tail, 0, NULL))
454 return 0;
455 if (starts_with(refname, "refs/heads/"))
456 return append_head_ref(refname, sha1, flag, cb_data);
builtin/tag.c
+1 -1
@@ -42,7 +42,7 @@ static int match_pattern(const char **patterns, const char *ref)
42 if (!*patterns)
43 return 1;
44 for (; *patterns; patterns++)
45 - if (!fnmatch(*patterns, ref, 0))
45 + if (!wildmatch(*patterns, ref, 0, NULL))
46 return 1;
47 return 0;
48 }
diffcore-order.c
+1 -1
@@ -73,7 +73,7 @@ static int match_order(const char *path)
73 strbuf_addstr(&p, path);
74 while (p.buf[0]) {
75 char *cp;
76 - if (!fnmatch(order[i], p.buf, 0))
76 + if (!wildmatch(order[i], p.buf, 0, NULL))
77 return i;
78 cp = strrchr(p.buf, '/');
79 if (!cp)
dir.c
+7 -4
@@ -49,7 +49,9 @@ int strncmp_icase(const char *a, const char *b, size_t count)
49
50 int fnmatch_icase(const char *pattern, const char *string, int flags)
51 {
52 - return fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 0));
52 + return wildmatch(pattern, string,
53 + flags | (ignore_case ? WM_CASEFOLD : 0),
54 + NULL);
55 }
56
57 inline int git_fnmatch(const struct pathspec_item *item,
@@ -58,7 +60,7 @@ inline int git_fnmatch(const struct pathspec_item *item,
60 {
61 if (prefix > 0) {
62 if (ps_strncmp(item, pattern, string, prefix))
61 - return FNM_NOMATCH;
63 + return WM_NOMATCH;
64 pattern += prefix;
65 string += prefix;
66 }
@@ -76,8 +78,9 @@ inline int git_fnmatch(const struct pathspec_item *item,
78 NULL);
79 else
80 /* wildmatch has not learned no FNM_PATHNAME mode yet */
79 - return fnmatch(pattern, string,
80 - item->magic & PATHSPEC_ICASE ? FNM_CASEFOLD : 0);
81 + return wildmatch(pattern, string,
82 + item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0,
83 + NULL);
84 }
85
86 static int fnmatch_icase_mem(const char *pattern, int patternlen,
refs.c
+1 -1
@@ -1477,7 +1477,7 @@ static int filter_refs(const char *refname, const unsigned char *sha1, int flags
1477 void *data)
1478 {
1479 struct ref_filter *filter = (struct ref_filter *)data;
1480 - if (fnmatch(filter->pattern, refname, 0))
1480 + if (wildmatch(filter->pattern, refname, 0, NULL))
1481 return 0;
1482 return filter->fn(refname, sha1, flags, filter->cb_data);
1483 }
revision.c
+1 -1
@@ -1191,7 +1191,7 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
1191 if (!ref_excludes)
1192 return 0;
1193 for_each_string_list_item(item, ref_excludes) {
1194 - if (!fnmatch(item->string, path, 0))
1194 + if (!wildmatch(item->string, path, 0, NULL))
1195 return 1;
1196 }
1197 return 0;