]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: add `exclude_patterns` parameter to `for_each_fullref_in()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 7 May 2024 07:11:44 +0000 (09:11 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 May 2024 17:06:59 +0000 (10:06 -0700)
The `for_each_fullref_in()` function is supposedly the ref-store-less
equivalent of `refs_for_each_fullref_in()`, but the latter has gained a
new parameter `exclude_patterns` over time. Bring these two functions
back in sync again by adding the parameter to the former function, as
well.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rev-parse.c
builtin/show-ref.c
ref-filter.c
refs.c
refs.h

index 624182e507e5af9ac34a67f18d7a5dcf6fe2e58c..2b28d4393955be7f80b0df6f9e591b2e1770b6ac 100644 (file)
@@ -908,8 +908,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                continue;
                        }
                        if (!strcmp(arg, "--bisect")) {
-                               for_each_fullref_in("refs/bisect/bad", show_reference, NULL);
-                               for_each_fullref_in("refs/bisect/good", anti_reference, NULL);
+                               for_each_fullref_in("refs/bisect/bad", NULL, show_reference, NULL);
+                               for_each_fullref_in("refs/bisect/good", NULL, anti_reference, NULL);
                                continue;
                        }
                        if (opt_with_value(arg, "--branches", &arg)) {
index 1c15421e6008e80b1983c168592998f17667bf58..3c521dbfd4ccba47ece86ee267a4c063faa32ce9 100644 (file)
@@ -208,9 +208,9 @@ static int cmd_show_ref__patterns(const struct patterns_options *opts,
                head_ref(show_ref, &show_ref_data);
        if (opts->heads_only || opts->tags_only) {
                if (opts->heads_only)
-                       for_each_fullref_in("refs/heads/", show_ref, &show_ref_data);
+                       for_each_fullref_in("refs/heads/", NULL, show_ref, &show_ref_data);
                if (opts->tags_only)
-                       for_each_fullref_in("refs/tags/", show_ref, &show_ref_data);
+                       for_each_fullref_in("refs/tags/", NULL, show_ref, &show_ref_data);
        } else {
                for_each_ref(show_ref, &show_ref_data);
        }
index 59ad6f54ddb0983d9e5d50cf7352d7462e245334..eab4beba162a2151384389489cda06badf9adb29 100644 (file)
@@ -2640,7 +2640,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
                 * prefixes like "refs/heads/" etc. are stripped off,
                 * so we have to look at everything:
                 */
-               return for_each_fullref_in("", cb, cb_data);
+               return for_each_fullref_in("", NULL, cb, cb_data);
        }
 
        if (filter->ignore_case) {
@@ -2649,7 +2649,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
                 * so just return everything and let the caller
                 * sort it out.
                 */
-               return for_each_fullref_in("", cb, cb_data);
+               return for_each_fullref_in("", NULL, cb, cb_data);
        }
 
        if (!filter->name_patterns[0]) {
@@ -3060,11 +3060,11 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref
                 * of filter_ref_kind().
                 */
                if (filter->kind == FILTER_REFS_BRANCHES)
-                       ret = for_each_fullref_in("refs/heads/", fn, cb_data);
+                       ret = for_each_fullref_in("refs/heads/", NULL, fn, cb_data);
                else if (filter->kind == FILTER_REFS_REMOTES)
-                       ret = for_each_fullref_in("refs/remotes/", fn, cb_data);
+                       ret = for_each_fullref_in("refs/remotes/", NULL, fn, cb_data);
                else if (filter->kind == FILTER_REFS_TAGS)
-                       ret = for_each_fullref_in("refs/tags/", fn, cb_data);
+                       ret = for_each_fullref_in("refs/tags/", NULL, fn, cb_data);
                else if (filter->kind & FILTER_REFS_REGULAR)
                        ret = for_each_fullref_in_pattern(filter, fn, cb_data);
 
diff --git a/refs.c b/refs.c
index 7cafda1c2599d7b7f35eab13b85e4d5ada2fdab6..00bcc7271911f7fd9521180140e0ac9732988deb 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1742,10 +1742,12 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
        return refs_for_each_ref_in(get_main_ref_store(the_repository), prefix, fn, cb_data);
 }
 
-int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data)
+int for_each_fullref_in(const char *prefix,
+                       const char **exclude_patterns,
+                       each_ref_fn fn, void *cb_data)
 {
-       return do_for_each_ref(get_main_ref_store(the_repository),
-                              prefix, NULL, fn, 0, 0, cb_data);
+       return refs_for_each_fullref_in(get_main_ref_store(the_repository),
+                                       prefix, exclude_patterns, fn, cb_data);
 }
 
 int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
diff --git a/refs.h b/refs.h
index 10982dcf0324fd0b2543c9fa0037b818ea90a923..a28de62fb59bec6589c545344864784787790845 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -353,7 +353,8 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data);
 int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
                             const char **exclude_patterns,
                             each_ref_fn fn, void *cb_data);
-int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data);
+int for_each_fullref_in(const char *prefix, const char **exclude_patterns,
+                       each_ref_fn fn, void *cb_data);
 
 /**
  * iterate all refs in "patterns" by partitioning patterns into disjoint sets