refs: add `exclude_patterns` parameter to `for_each_fullref_in()`

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>

Patrick Steinhardt committed May 7, 2024 at 09:11 UTC 54876c6dfba771612245cf57b2217c5b00ced29d
5 files changed +16 -13
builtin/rev-parse.c
+2 -2
@@ -908,8 +908,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
908 continue;
909 }
910 if (!strcmp(arg, "--bisect")) {
911 - for_each_fullref_in("refs/bisect/bad", show_reference, NULL);
912 - for_each_fullref_in("refs/bisect/good", anti_reference, NULL);
911 + for_each_fullref_in("refs/bisect/bad", NULL, show_reference, NULL);
912 + for_each_fullref_in("refs/bisect/good", NULL, anti_reference, NULL);
913 continue;
914 }
915 if (opt_with_value(arg, "--branches", &arg)) {
builtin/show-ref.c
+2 -2
@@ -208,9 +208,9 @@ static int cmd_show_ref__patterns(const struct patterns_options *opts,
208 head_ref(show_ref, &show_ref_data);
209 if (opts->heads_only || opts->tags_only) {
210 if (opts->heads_only)
211 - for_each_fullref_in("refs/heads/", show_ref, &show_ref_data);
211 + for_each_fullref_in("refs/heads/", NULL, show_ref, &show_ref_data);
212 if (opts->tags_only)
213 - for_each_fullref_in("refs/tags/", show_ref, &show_ref_data);
213 + for_each_fullref_in("refs/tags/", NULL, show_ref, &show_ref_data);
214 } else {
215 for_each_ref(show_ref, &show_ref_data);
216 }
ref-filter.c
+5 -5
@@ -2640,7 +2640,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
2640 * prefixes like "refs/heads/" etc. are stripped off,
2641 * so we have to look at everything:
2642 */
2643 - return for_each_fullref_in("", cb, cb_data);
2643 + return for_each_fullref_in("", NULL, cb, cb_data);
2644 }
2645
2646 if (filter->ignore_case) {
@@ -2649,7 +2649,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
2649 * so just return everything and let the caller
2650 * sort it out.
2651 */
2652 - return for_each_fullref_in("", cb, cb_data);
2652 + return for_each_fullref_in("", NULL, cb, cb_data);
2653 }
2654
2655 if (!filter->name_patterns[0]) {
@@ -3060,11 +3060,11 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref
3060 * of filter_ref_kind().
3061 */
3062 if (filter->kind == FILTER_REFS_BRANCHES)
3063 - ret = for_each_fullref_in("refs/heads/", fn, cb_data);
3063 + ret = for_each_fullref_in("refs/heads/", NULL, fn, cb_data);
3064 else if (filter->kind == FILTER_REFS_REMOTES)
3065 - ret = for_each_fullref_in("refs/remotes/", fn, cb_data);
3065 + ret = for_each_fullref_in("refs/remotes/", NULL, fn, cb_data);
3066 else if (filter->kind == FILTER_REFS_TAGS)
3067 - ret = for_each_fullref_in("refs/tags/", fn, cb_data);
3067 + ret = for_each_fullref_in("refs/tags/", NULL, fn, cb_data);
3068 else if (filter->kind & FILTER_REFS_REGULAR)
3069 ret = for_each_fullref_in_pattern(filter, fn, cb_data);
3070
refs.c
+5 -3
@@ -1742,10 +1742,12 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
1742 return refs_for_each_ref_in(get_main_ref_store(the_repository), prefix, fn, cb_data);
1743 }
1744
1745 -int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data)
1745 +int for_each_fullref_in(const char *prefix,
1746 + const char **exclude_patterns,
1747 + each_ref_fn fn, void *cb_data)
1748 {
1747 - return do_for_each_ref(get_main_ref_store(the_repository),
1748 - prefix, NULL, fn, 0, 0, cb_data);
1749 + return refs_for_each_fullref_in(get_main_ref_store(the_repository),
1750 + prefix, exclude_patterns, fn, cb_data);
1751 }
1752
1753 int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
refs.h
+2 -1
@@ -353,7 +353,8 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data);
353 int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
354 const char **exclude_patterns,
355 each_ref_fn fn, void *cb_data);
356 -int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data);
356 +int for_each_fullref_in(const char *prefix, const char **exclude_patterns,
357 + each_ref_fn fn, void *cb_data);
358
359 /**
360 * iterate all refs in "patterns" by partitioning patterns into disjoint sets