Merge branch 'ab/wildmatch'
authorJunio C Hamano <gitster@pobox.com>
Mon, 10 Jul 2017 20:42:51 +0000 (13:42 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Jul 2017 20:42:51 +0000 (13:42 -0700)
Minor code cleanup.

* ab/wildmatch:
wildmatch: remove unused wildopts parameter

16 files changed:
apply.c
builtin/describe.c
builtin/ls-remote.c
builtin/name-rev.c
builtin/reflog.c
builtin/replace.c
builtin/show-branch.c
config.c
diffcore-order.c
dir.c
ref-filter.c
refs.c
revision.c
t/helper/test-wildmatch.c
wildmatch.c
wildmatch.h
diff --git a/apply.c b/apply.c
index 946be4d2f553813a3df7b513c816f002591fd89f..4050cebcfacc233f6d449221ec5c44b3551a4678 100644 (file)
--- a/apply.c
+++ b/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 */
        for (i = 0; i < state->limit_by_name.nr; 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);
        }
 
index 70eb1446089583cd859ea1f05b260283cd78067f..19eacdd170d98ea583cc2eb373247df600be24d7 100644 (file)
@@ -143,7 +143,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
                        return 0;
 
                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;
                }
        }
@@ -159,7 +159,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
                        return 0;
 
                for_each_string_list_item(item, &patterns) {
-                       if (!wildmatch(item->string, path + 10, 0, NULL))
+                       if (!wildmatch(item->string, path + 10, 0))
                                break;
 
                        /* If we get here, no pattern matched. */
index b2d7d5ce6841cf9cb9e310c659aac043ad00cfb0..c4be98ab9e84fdcde2842b88d4bb60600f7bf627 100644 (file)
@@ -24,7 +24,7 @@ static int tail_match(const char **pattern, const char *path)
 
        pathbuf = xstrfmt("/%s", path);
        while ((p = *(pattern++)) != NULL) {
-               if (!wildmatch(p, pathbuf, 0, NULL)) {
+               if (!wildmatch(p, pathbuf, 0)) {
                        free(pathbuf);
                        return 1;
                }
index e21715f1d0874171bcda2486adb4d27ea5cbbc99..c41ea7c2a62ba868061884e511256c24f4d020d9 100644 (file)
@@ -130,7 +130,7 @@ static int subpath_matches(const char *path, const char *filter)
        const char *subpath = path;
 
        while (subpath) {
-               if (!wildmatch(filter, subpath, 0, NULL))
+               if (!wildmatch(filter, subpath, 0))
                        return subpath - path;
                subpath = strchr(subpath, '/');
                if (subpath)
index 44cdc2dbd0cbf64be1672428e930223425ed7b04..e237d927a0881b56135a21a1b0041e7de6ff39ab 100644 (file)
@@ -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 */
 
        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))
                                cb->expire_total = ent->expire_total;
                        if (!(slot & EXPIRE_UNREACH))
index 80a15cf35f3fa5a1a7c038924a84e34fdc15aa0b..fba336a68a375e20e9b40d332eb58a3f302249fa 100644 (file)
@@ -41,7 +41,7 @@ static int show_reference(const char *refname, const struct object_id *oid,
 {
        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)
                        printf("%s\n", refname);
                else if (data->format == REPLACE_FORMAT_MEDIUM)
index 527f69e283fd592c7b862b4ad6467d08d33e561c..7073a3eb9769cae1f00e714a93528b33ca651d9c 100644 (file)
@@ -438,7 +438,7 @@ static int append_matching_ref(const char *refname, const struct object_id *oid,
                        slash--;
        if (!*tail)
                return 0;
-       if (wildmatch(match_ref_pattern, tail, 0, NULL))
+       if (wildmatch(match_ref_pattern, tail, 0))
                return 0;
        if (starts_with(refname, "refs/heads/"))
                return append_head_ref(refname, oid, flag, cb_data);
index 4638b0696ab8885afe1fc696dd6e0a25dcc1c89f..a9356c1383861ecf7f33ee0262c8a60bbe20864f 100644 (file)
--- a/config.c
+++ b/config.c
@@ -238,7 +238,7 @@ static int include_by_gitdir(const struct config_options *opts,
        }
 
        ret = !wildmatch(pattern.buf + prefix, text.buf + prefix,
-                        icase ? WM_CASEFOLD : 0, NULL);
+                        icase ? WM_CASEFOLD : 0);
 
        if (!ret && !already_tried_absolute) {
                /*
index 1957f822a5120a463ea4dff503fd8fe78f63b663..19e73311f9cd830da70428439b7b6a14d5345eec 100644 (file)
@@ -67,7 +67,7 @@ static int match_order(const char *path)
                strbuf_addstr(&p, path);
                while (p.buf[0]) {
                        char *cp;
-                       if (!wildmatch(order[i], p.buf, 0, NULL))
+                       if (!wildmatch(order[i], p.buf, 0))
                                return i;
                        cp = strrchr(p.buf, '/');
                        if (!cp)
diff --git a/dir.c b/dir.c
index 332f9d8095faf0ec4549cab41811167aecea31d3..ae6f5c9636abd34d026579b7ddc8452825af9b30 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -92,13 +92,11 @@ int git_fnmatch(const struct pathspec_item *item,
        if (item->magic & PATHSPEC_GLOB)
                return wildmatch(pattern, string,
                                 WM_PATHNAME |
-                                (item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0),
-                                NULL);
+                                (item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0));
        else
                /* wildmatch has not learned no FNM_PATHNAME mode yet */
                return wildmatch(pattern, string,
-                                item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0,
-                                NULL);
+                                item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0);
 }
 
 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)
                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(&str_buf);
index 72e6cb8ecc3e46481239314d27f48a1c8a392518..e0578d8b5ae1a467082ee94ff798d054db1450bf 100644 (file)
@@ -1624,7 +1624,7 @@ static int match_pattern(const struct ref_filter *filter, const char *refname)
               skip_prefix(refname, "refs/", &refname));
 
        for (; *patterns; patterns++) {
-               if (!wildmatch(*patterns, refname, flags, NULL))
+               if (!wildmatch(*patterns, refname, flags))
                        return 1;
        }
        return 0;
@@ -1655,7 +1655,7 @@ static int match_name_as_path(const struct ref_filter *filter, const char *refna
                     refname[plen] == '/' ||
                     p[plen-1] == '/'))
                        return 1;
-               if (!wildmatch(p, refname, WM_PATHNAME, NULL))
+               if (!wildmatch(p, refname, WM_PATHNAME))
                        return 1;
        }
        return 0;
diff --git a/refs.c b/refs.c
index 88658ba76960401e4ab246b597d1212f5b435de1..7aae78cb551fd2743982d7f9fc60e6de45df9a11 100644 (file)
--- a/refs.c
+++ b/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;
 
-       if (wildmatch(filter->pattern, refname, 0, NULL))
+       if (wildmatch(filter->pattern, refname, 0))
                return 0;
        return filter->fn(refname, oid, flags, filter->cb_data);
 }
index e181ad1b70d06a0f64869a925c98cbc8558ef684..9ff120b30518aa2b3f7cc214a1c921d739108d7c 100644 (file)
@@ -1142,7 +1142,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 (!wildmatch(item->string, path, 0, NULL))
+               if (!wildmatch(item->string, path, 0))
                        return 1;
        }
        return 0;
index 52be876fed3bcc3bb5a1def5de8febe8b29c0ec4..921d7b3e7ea20efe85f15beb7c75b8a5263267fb 100644 (file)
@@ -11,11 +11,11 @@ int cmd_main(int argc, const char **argv)
                        argv[i] += 3;
        }
        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"))
-               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"))
-               return !!wildmatch(argv[3], argv[2], 0, NULL);
+               return !!wildmatch(argv[3], argv[2], 0);
        else
                return 1;
 }
index 57c876580592ab246d0c5c20cf20079d2097243c..d074c1be1046f1aba11d21eb5b66a738590bc712 100644 (file)
@@ -272,8 +272,7 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
 }
 
 /* Match the "pattern" against the "text" string. */
-int wildmatch(const char *pattern, const char *text,
-             unsigned int flags, struct wildopts *wo)
+int wildmatch(const char *pattern, const char *text, unsigned int flags)
 {
        return dowild((const uchar*)pattern, (const uchar*)text, flags);
 }
index 4090c8f4bb0587d36ec01069f1e8d832ea46d7d6..b8c826aa684ec2cb0251af8e24a89689d66614b1 100644 (file)
@@ -10,9 +10,5 @@
 #define WM_ABORT_ALL -1
 #define WM_ABORT_TO_STARSTAR -2
 
-struct wildopts;
-
-int wildmatch(const char *pattern, const char *text,
-             unsigned int flags,
-             struct wildopts *wo);
+int wildmatch(const char *pattern, const char *text, unsigned int flags);
 #endif