Merge branch 'ab/wildmatch'
Minor code cleanup. * ab/wildmatch: wildmatch: remove unused wildopts parametermaint
commit
0c6435a4d6
2
apply.c
2
apply.c
|
@ -2100,7 +2100,7 @@ static int use_patch(struct apply_state *state, struct patch *p)
|
||||||
/* See if it matches any of exclude/include rule */
|
/* See if it matches any of exclude/include rule */
|
||||||
for (i = 0; i < state->limit_by_name.nr; i++) {
|
for (i = 0; i < state->limit_by_name.nr; i++) {
|
||||||
struct string_list_item *it = &state->limit_by_name.items[i];
|
struct string_list_item *it = &state->limit_by_name.items[i];
|
||||||
if (!wildmatch(it->string, pathname, 0, NULL))
|
if (!wildmatch(it->string, pathname, 0))
|
||||||
return (it->util != NULL);
|
return (it->util != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for_each_string_list_item(item, &exclude_patterns) {
|
for_each_string_list_item(item, &exclude_patterns) {
|
||||||
if (!wildmatch(item->string, path + 10, 0, NULL))
|
if (!wildmatch(item->string, path + 10, 0))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for_each_string_list_item(item, &patterns) {
|
for_each_string_list_item(item, &patterns) {
|
||||||
if (!wildmatch(item->string, path + 10, 0, NULL))
|
if (!wildmatch(item->string, path + 10, 0))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* If we get here, no pattern matched. */
|
/* If we get here, no pattern matched. */
|
||||||
|
|
|
@ -24,7 +24,7 @@ static int tail_match(const char **pattern, const char *path)
|
||||||
|
|
||||||
pathbuf = xstrfmt("/%s", path);
|
pathbuf = xstrfmt("/%s", path);
|
||||||
while ((p = *(pattern++)) != NULL) {
|
while ((p = *(pattern++)) != NULL) {
|
||||||
if (!wildmatch(p, pathbuf, 0, NULL)) {
|
if (!wildmatch(p, pathbuf, 0)) {
|
||||||
free(pathbuf);
|
free(pathbuf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ static int subpath_matches(const char *path, const char *filter)
|
||||||
const char *subpath = path;
|
const char *subpath = path;
|
||||||
|
|
||||||
while (subpath) {
|
while (subpath) {
|
||||||
if (!wildmatch(filter, subpath, 0, NULL))
|
if (!wildmatch(filter, subpath, 0))
|
||||||
return subpath - path;
|
return subpath - path;
|
||||||
subpath = strchr(subpath, '/');
|
subpath = strchr(subpath, '/');
|
||||||
if (subpath)
|
if (subpath)
|
||||||
|
|
|
@ -486,7 +486,7 @@ static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, c
|
||||||
return; /* both given explicitly -- nothing to tweak */
|
return; /* both given explicitly -- nothing to tweak */
|
||||||
|
|
||||||
for (ent = reflog_expire_cfg; ent; ent = ent->next) {
|
for (ent = reflog_expire_cfg; ent; ent = ent->next) {
|
||||||
if (!wildmatch(ent->pattern, ref, 0, NULL)) {
|
if (!wildmatch(ent->pattern, ref, 0)) {
|
||||||
if (!(slot & EXPIRE_TOTAL))
|
if (!(slot & EXPIRE_TOTAL))
|
||||||
cb->expire_total = ent->expire_total;
|
cb->expire_total = ent->expire_total;
|
||||||
if (!(slot & EXPIRE_UNREACH))
|
if (!(slot & EXPIRE_UNREACH))
|
||||||
|
|
|
@ -41,7 +41,7 @@ static int show_reference(const char *refname, const struct object_id *oid,
|
||||||
{
|
{
|
||||||
struct show_data *data = cb_data;
|
struct show_data *data = cb_data;
|
||||||
|
|
||||||
if (!wildmatch(data->pattern, refname, 0, NULL)) {
|
if (!wildmatch(data->pattern, refname, 0)) {
|
||||||
if (data->format == REPLACE_FORMAT_SHORT)
|
if (data->format == REPLACE_FORMAT_SHORT)
|
||||||
printf("%s\n", refname);
|
printf("%s\n", refname);
|
||||||
else if (data->format == REPLACE_FORMAT_MEDIUM)
|
else if (data->format == REPLACE_FORMAT_MEDIUM)
|
||||||
|
|
|
@ -438,7 +438,7 @@ static int append_matching_ref(const char *refname, const struct object_id *oid,
|
||||||
slash--;
|
slash--;
|
||||||
if (!*tail)
|
if (!*tail)
|
||||||
return 0;
|
return 0;
|
||||||
if (wildmatch(match_ref_pattern, tail, 0, NULL))
|
if (wildmatch(match_ref_pattern, tail, 0))
|
||||||
return 0;
|
return 0;
|
||||||
if (starts_with(refname, "refs/heads/"))
|
if (starts_with(refname, "refs/heads/"))
|
||||||
return append_head_ref(refname, oid, flag, cb_data);
|
return append_head_ref(refname, oid, flag, cb_data);
|
||||||
|
|
2
config.c
2
config.c
|
@ -238,7 +238,7 @@ again:
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = !wildmatch(pattern.buf + prefix, text.buf + prefix,
|
ret = !wildmatch(pattern.buf + prefix, text.buf + prefix,
|
||||||
icase ? WM_CASEFOLD : 0, NULL);
|
icase ? WM_CASEFOLD : 0);
|
||||||
|
|
||||||
if (!ret && !already_tried_absolute) {
|
if (!ret && !already_tried_absolute) {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -67,7 +67,7 @@ static int match_order(const char *path)
|
||||||
strbuf_addstr(&p, path);
|
strbuf_addstr(&p, path);
|
||||||
while (p.buf[0]) {
|
while (p.buf[0]) {
|
||||||
char *cp;
|
char *cp;
|
||||||
if (!wildmatch(order[i], p.buf, 0, NULL))
|
if (!wildmatch(order[i], p.buf, 0))
|
||||||
return i;
|
return i;
|
||||||
cp = strrchr(p.buf, '/');
|
cp = strrchr(p.buf, '/');
|
||||||
if (!cp)
|
if (!cp)
|
||||||
|
|
8
dir.c
8
dir.c
|
@ -92,13 +92,11 @@ int git_fnmatch(const struct pathspec_item *item,
|
||||||
if (item->magic & PATHSPEC_GLOB)
|
if (item->magic & PATHSPEC_GLOB)
|
||||||
return wildmatch(pattern, string,
|
return wildmatch(pattern, string,
|
||||||
WM_PATHNAME |
|
WM_PATHNAME |
|
||||||
(item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0),
|
(item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0));
|
||||||
NULL);
|
|
||||||
else
|
else
|
||||||
/* wildmatch has not learned no FNM_PATHNAME mode yet */
|
/* wildmatch has not learned no FNM_PATHNAME mode yet */
|
||||||
return wildmatch(pattern, string,
|
return wildmatch(pattern, string,
|
||||||
item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0,
|
item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0);
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fnmatch_icase_mem(const char *pattern, int patternlen,
|
static int fnmatch_icase_mem(const char *pattern, int patternlen,
|
||||||
|
@ -122,7 +120,7 @@ static int fnmatch_icase_mem(const char *pattern, int patternlen,
|
||||||
|
|
||||||
if (ignore_case)
|
if (ignore_case)
|
||||||
flags |= WM_CASEFOLD;
|
flags |= WM_CASEFOLD;
|
||||||
match_status = wildmatch(use_pat, use_str, flags, NULL);
|
match_status = wildmatch(use_pat, use_str, flags);
|
||||||
|
|
||||||
strbuf_release(&pat_buf);
|
strbuf_release(&pat_buf);
|
||||||
strbuf_release(&str_buf);
|
strbuf_release(&str_buf);
|
||||||
|
|
|
@ -1624,7 +1624,7 @@ static int match_pattern(const struct ref_filter *filter, const char *refname)
|
||||||
skip_prefix(refname, "refs/", &refname));
|
skip_prefix(refname, "refs/", &refname));
|
||||||
|
|
||||||
for (; *patterns; patterns++) {
|
for (; *patterns; patterns++) {
|
||||||
if (!wildmatch(*patterns, refname, flags, NULL))
|
if (!wildmatch(*patterns, refname, flags))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1655,7 +1655,7 @@ static int match_name_as_path(const struct ref_filter *filter, const char *refna
|
||||||
refname[plen] == '/' ||
|
refname[plen] == '/' ||
|
||||||
p[plen-1] == '/'))
|
p[plen-1] == '/'))
|
||||||
return 1;
|
return 1;
|
||||||
if (!wildmatch(p, refname, WM_PATHNAME, NULL))
|
if (!wildmatch(p, refname, WM_PATHNAME))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
2
refs.c
2
refs.c
|
@ -230,7 +230,7 @@ static int filter_refs(const char *refname, const struct object_id *oid,
|
||||||
{
|
{
|
||||||
struct ref_filter *filter = (struct ref_filter *)data;
|
struct ref_filter *filter = (struct ref_filter *)data;
|
||||||
|
|
||||||
if (wildmatch(filter->pattern, refname, 0, NULL))
|
if (wildmatch(filter->pattern, refname, 0))
|
||||||
return 0;
|
return 0;
|
||||||
return filter->fn(refname, oid, flags, filter->cb_data);
|
return filter->fn(refname, oid, flags, filter->cb_data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1142,7 +1142,7 @@ int ref_excluded(struct string_list *ref_excludes, const char *path)
|
||||||
if (!ref_excludes)
|
if (!ref_excludes)
|
||||||
return 0;
|
return 0;
|
||||||
for_each_string_list_item(item, ref_excludes) {
|
for_each_string_list_item(item, ref_excludes) {
|
||||||
if (!wildmatch(item->string, path, 0, NULL))
|
if (!wildmatch(item->string, path, 0))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -11,11 +11,11 @@ int cmd_main(int argc, const char **argv)
|
||||||
argv[i] += 3;
|
argv[i] += 3;
|
||||||
}
|
}
|
||||||
if (!strcmp(argv[1], "wildmatch"))
|
if (!strcmp(argv[1], "wildmatch"))
|
||||||
return !!wildmatch(argv[3], argv[2], WM_PATHNAME, NULL);
|
return !!wildmatch(argv[3], argv[2], WM_PATHNAME);
|
||||||
else if (!strcmp(argv[1], "iwildmatch"))
|
else if (!strcmp(argv[1], "iwildmatch"))
|
||||||
return !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD, NULL);
|
return !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD);
|
||||||
else if (!strcmp(argv[1], "pathmatch"))
|
else if (!strcmp(argv[1], "pathmatch"))
|
||||||
return !!wildmatch(argv[3], argv[2], 0, NULL);
|
return !!wildmatch(argv[3], argv[2], 0);
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,8 +272,7 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Match the "pattern" against the "text" string. */
|
/* Match the "pattern" against the "text" string. */
|
||||||
int wildmatch(const char *pattern, const char *text,
|
int wildmatch(const char *pattern, const char *text, unsigned int flags)
|
||||||
unsigned int flags, struct wildopts *wo)
|
|
||||||
{
|
{
|
||||||
return dowild((const uchar*)pattern, (const uchar*)text, flags);
|
return dowild((const uchar*)pattern, (const uchar*)text, flags);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,5 @@
|
||||||
#define WM_ABORT_ALL -1
|
#define WM_ABORT_ALL -1
|
||||||
#define WM_ABORT_TO_STARSTAR -2
|
#define WM_ABORT_TO_STARSTAR -2
|
||||||
|
|
||||||
struct wildopts;
|
int wildmatch(const char *pattern, const char *text, unsigned int flags);
|
||||||
|
|
||||||
int wildmatch(const char *pattern, const char *text,
|
|
||||||
unsigned int flags,
|
|
||||||
struct wildopts *wo);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue