Skip to content

Commit 650c90a

Browse files
committed
Merge branch 'nd/no-more-fnmatch'
We started using wildmatch() in place of fnmatch(3); complete the process and stop using fnmatch(3). * nd/no-more-fnmatch: actually remove compat fnmatch source code stop using fnmatch (either native or compat) Revert "test-wildmatch: add "perf" command to compare wildmatch and fnmatch" use wildmatch() directly without fnmatch() wrapper
2 parents 3a66e1b + 2c0a1bd commit 650c90a

22 files changed

+20
-759
lines changed

Makefile

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ all::
101101
#
102102
# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
103103
#
104-
# Define NO_FNMATCH if you don't have fnmatch in the C library.
105-
#
106-
# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
107-
# FNM_CASEFOLD GNU extension.
108-
#
109-
# Define NO_WILDMATCH if you do not want to use Git's wildmatch
110-
# implementation as fnmatch
111-
#
112104
# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
113105
# in the C library.
114106
#
@@ -1283,20 +1275,6 @@ endif
12831275
ifdef NO_STRTOULL
12841276
COMPAT_CFLAGS += -DNO_STRTOULL
12851277
endif
1286-
ifdef NO_FNMATCH
1287-
COMPAT_CFLAGS += -Icompat/fnmatch
1288-
COMPAT_CFLAGS += -DNO_FNMATCH
1289-
COMPAT_OBJS += compat/fnmatch/fnmatch.o
1290-
else
1291-
ifdef NO_FNMATCH_CASEFOLD
1292-
COMPAT_CFLAGS += -Icompat/fnmatch
1293-
COMPAT_CFLAGS += -DNO_FNMATCH_CASEFOLD
1294-
COMPAT_OBJS += compat/fnmatch/fnmatch.o
1295-
endif
1296-
endif
1297-
ifndef NO_WILDMATCH
1298-
COMPAT_CFLAGS += -DUSE_WILDMATCH
1299-
endif
13001278
ifdef NO_SETENV
13011279
COMPAT_CFLAGS += -DNO_SETENV
13021280
COMPAT_OBJS += compat/setenv.o

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
@@ -138,7 +138,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
138138
return 0;
139139

140140
/* Accept only tags that match the pattern, if given */
141-
if (pattern && (!is_tag || fnmatch(pattern, path + 10, 0)))
141+
if (pattern && (!is_tag || wildmatch(pattern, path + 10, 0, NULL)))
142142
return 0;
143143

144144
/* 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);

0 commit comments

Comments
 (0)