Skip to content

Commit eb07894

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent 5f95c9f commit eb07894

File tree

14 files changed

+20
-17
lines changed

14 files changed

+20
-17
lines changed

builtin/apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4152,7 +4152,7 @@ static int use_patch(struct patch *p)
41524152
/* See if it matches any of exclude/include rule */
41534153
for (i = 0; i < limit_by_name.nr; i++) {
41544154
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))
41564156
return (it->util != NULL);
41574157
}
41584158

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static int match_patterns(const char **pattern, const char *refname)
315315
if (!*pattern)
316316
return 1; /* no pattern always matches */
317317
while (*pattern) {
318-
if (!fnmatch(*pattern, refname, 0))
318+
if (!wildmatch(*pattern, refname, 0, NULL))
319319
return 1;
320320
pattern++;
321321
}

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
150150
return 0;
151151

152152
/* 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)))
154154
return 0;
155155

156156
/* Is it annotated? */

builtin/for-each-ref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
864864
refname[plen] == '/' ||
865865
p[plen-1] == '/'))
866866
break;
867-
if (!fnmatch(p, refname, FNM_PATHNAME))
867+
if (!wildmatch(p, refname, WM_PATHNAME, NULL))
868868
break;
869869
}
870870
if (!*pattern)

builtin/ls-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static int tail_match(const char **pattern, const char *path)
2222
if (snprintf(pathbuf, sizeof(pathbuf), "/%s", path) > sizeof(pathbuf))
2323
return error("insanely long ref %.*s...", 20, path);
2424
while ((p = *(pattern++)) != NULL) {
25-
if (!fnmatch(p, pathbuf, 0))
25+
if (!wildmatch(p, pathbuf, 0, NULL))
2626
return 1;
2727
}
2828
return 0;

builtin/name-rev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int subpath_matches(const char *path, const char *filter)
8787
const char *subpath = path;
8888

8989
while (subpath) {
90-
if (!fnmatch(filter, subpath, 0))
90+
if (!wildmatch(filter, subpath, 0, NULL))
9191
return subpath - path;
9292
subpath = strchr(subpath, '/');
9393
if (subpath)

builtin/reflog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, c
561561
return; /* both given explicitly -- nothing to tweak */
562562

563563
for (ent = reflog_expire_cfg; ent; ent = ent->next) {
564-
if (!fnmatch(ent->pattern, ref, 0)) {
564+
if (!wildmatch(ent->pattern, ref, 0, NULL)) {
565565
if (!(slot & EXPIRE_TOTAL))
566566
cb->expire_total = ent->expire_total;
567567
if (!(slot & EXPIRE_UNREACH))

builtin/replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int show_reference(const char *refname, const unsigned char *sha1,
3636
{
3737
struct show_data *data = cb_data;
3838

39-
if (!fnmatch(data->pattern, refname, 0)) {
39+
if (!wildmatch(data->pattern, refname, 0, NULL)) {
4040
if (data->format == REPLACE_FORMAT_SHORT)
4141
printf("%s\n", refname);
4242
else if (data->format == REPLACE_FORMAT_MEDIUM)

builtin/show-branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i
450450
slash--;
451451
if (!*tail)
452452
return 0;
453-
if (fnmatch(match_ref_pattern, tail, 0))
453+
if (wildmatch(match_ref_pattern, tail, 0, NULL))
454454
return 0;
455455
if (starts_with(refname, "refs/heads/"))
456456
return append_head_ref(refname, sha1, flag, cb_data);

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int match_pattern(const char **patterns, const char *ref)
4242
if (!*patterns)
4343
return 1;
4444
for (; *patterns; patterns++)
45-
if (!fnmatch(*patterns, ref, 0))
45+
if (!wildmatch(*patterns, ref, 0, NULL))
4646
return 1;
4747
return 0;
4848
}

0 commit comments

Comments
 (0)