refs: replace `refs_for_each_fullref_in()`

Replace calls to `refs_for_each_fullref_in()` with the newly introduced `refs_for_each_ref_ext()` function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Feb 23, 2026 at 12:59 UTC 1dd4f1e43f8f11ebb13c1b9edbd91219a134443d
8 files changed +37 -46
bisect.c
+5 -3
@@ -1190,13 +1190,15 @@ static int mark_for_removal(const struct reference *ref, void *cb_data)
1190
1191 int bisect_clean_state(void)
1192 {
1193 + struct refs_for_each_ref_options opts = {
1194 + .prefix = "refs/bisect/",
1195 + };
1196 int result = 0;
1197
1198 /* There may be some refs packed during bisection */
1199 struct string_list refs_for_removal = STRING_LIST_INIT_DUP;
1197 - refs_for_each_fullref_in(get_main_ref_store(the_repository),
1198 - "refs/bisect/", NULL, mark_for_removal,
1199 - &refs_for_removal);
1200 + refs_for_each_ref_ext(get_main_ref_store(the_repository),
1201 + mark_for_removal, &refs_for_removal, &opts);
1202 string_list_append(&refs_for_removal, "BISECT_HEAD");
1203 string_list_append(&refs_for_removal, "BISECT_EXPECTED_REV");
1204 result = refs_delete_refs(get_main_ref_store(the_repository),
builtin/receive-pack.c
+4 -4
@@ -343,9 +343,9 @@ static void show_one_alternate_ref(const struct object_id *oid,
343
344 static void write_head_info(void)
345 {
346 + struct refs_for_each_ref_options opts = { 0 };
347 static struct oidset seen = OIDSET_INIT;
348 struct strvec excludes_vector = STRVEC_INIT;
348 - const char **exclude_patterns;
349
350 /*
351 * We need access to the reference names both with and without their
@@ -353,12 +353,12 @@ static void write_head_info(void)
353 * thus have to adapt exclude patterns to carry the namespace prefix
354 * ourselves.
355 */
356 - exclude_patterns = get_namespaced_exclude_patterns(
356 + opts.exclude_patterns = get_namespaced_exclude_patterns(
357 hidden_refs_to_excludes(&hidden_refs),
358 get_git_namespace(), &excludes_vector);
359
360 - refs_for_each_fullref_in(get_main_ref_store(the_repository), "",
361 - exclude_patterns, show_ref_cb, &seen);
360 + refs_for_each_ref_ext(get_main_ref_store(the_repository),
361 + show_ref_cb, &seen, &opts);
362 odb_for_each_alternate_ref(the_repository->objects,
363 show_one_alternate_ref, &seen);
364
builtin/rev-parse.c
+7 -8
@@ -940,14 +940,13 @@ int cmd_rev_parse(int argc,
940 continue;
941 }
942 if (!strcmp(arg, "--bisect")) {
943 - refs_for_each_fullref_in(get_main_ref_store(the_repository),
944 - "refs/bisect/bad",
945 - NULL, show_reference,
946 - NULL);
947 - refs_for_each_fullref_in(get_main_ref_store(the_repository),
948 - "refs/bisect/good",
949 - NULL, anti_reference,
950 - NULL);
943 + struct refs_for_each_ref_options opts = { 0 };
944 + opts.prefix = "refs/bisect/bad";
945 + refs_for_each_ref_ext(get_main_ref_store(the_repository),
946 + show_reference, NULL, &opts);
947 + opts.prefix = "refs/bisect/good";
948 + refs_for_each_ref_ext(get_main_ref_store(the_repository),
949 + anti_reference, NULL, &opts);
950 continue;
951 }
952 if (opt_with_value(arg, "--branches", &arg)) {
builtin/show-ref.c
+13 -8
@@ -215,14 +215,19 @@ static int cmd_show_ref__patterns(const struct patterns_options *opts,
215 refs_head_ref(get_main_ref_store(the_repository), show_ref,
216 &show_ref_data);
217 if (opts->branches_only || opts->tags_only) {
218 - if (opts->branches_only)
219 - refs_for_each_fullref_in(get_main_ref_store(the_repository),
220 - "refs/heads/", NULL,
221 - show_ref, &show_ref_data);
222 - if (opts->tags_only)
223 - refs_for_each_fullref_in(get_main_ref_store(the_repository),
224 - "refs/tags/", NULL, show_ref,
225 - &show_ref_data);
218 + struct refs_for_each_ref_options for_each_ref_opts = { 0 };
219 +
220 + if (opts->branches_only) {
221 + for_each_ref_opts.prefix = "refs/heads/";
222 + refs_for_each_ref_ext(get_main_ref_store(the_repository),
223 + show_ref, &show_ref_data, &for_each_ref_opts);
224 + }
225 +
226 + if (opts->tags_only) {
227 + for_each_ref_opts.prefix = "refs/tags/";
228 + refs_for_each_ref_ext(get_main_ref_store(the_repository),
229 + show_ref, &show_ref_data, &for_each_ref_opts);
230 + }
231 } else {
232 refs_for_each_ref(get_main_ref_store(the_repository),
233 show_ref, &show_ref_data);
refs.c
-11
@@ -1929,17 +1929,6 @@ int refs_for_each_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data
1929 return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
1930 }
1931
1932 -int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
1933 - const char **exclude_patterns,
1934 - refs_for_each_cb cb, void *cb_data)
1935 -{
1936 - struct refs_for_each_ref_options opts = {
1937 - .prefix = prefix,
1938 - .exclude_patterns = exclude_patterns,
1939 - };
1940 - return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
1941 -}
1942 -
1932 int refs_for_each_replace_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data)
1933 {
1934 const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
refs.h
-8
@@ -510,14 +510,6 @@ int refs_for_each_remote_ref(struct ref_store *refs,
510 int refs_for_each_replace_ref(struct ref_store *refs,
511 refs_for_each_cb fn, void *cb_data);
512
513 -/*
514 - * references matching any pattern in "exclude_patterns" are omitted from the
515 - * result set on a best-effort basis.
516 - */
517 -int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
518 - const char **exclude_patterns,
519 - refs_for_each_cb fn, void *cb_data);
520 -
513 /**
514 * Iterate all refs in "prefixes" by partitioning prefixes into disjoint sets
515 * and iterating the longest-common prefix of each set.
revision.c
+3 -1
@@ -2731,10 +2731,12 @@ void revision_opts_finish(struct rev_info *revs)
2731 static int for_each_bisect_ref(struct ref_store *refs, refs_for_each_cb fn,
2732 void *cb_data, const char *term)
2733 {
2734 + struct refs_for_each_ref_options opts = { 0 };
2735 struct strbuf bisect_refs = STRBUF_INIT;
2736 int status;
2737 strbuf_addf(&bisect_refs, "refs/bisect/%s", term);
2737 - status = refs_for_each_fullref_in(refs, bisect_refs.buf, NULL, fn, cb_data);
2738 + opts.prefix = bisect_refs.buf;
2739 + status = refs_for_each_ref_ext(refs, fn, cb_data, &opts);
2740 strbuf_release(&bisect_refs);
2741 return status;
2742 }
t/helper/test-ref-store.c
+5 -3
@@ -173,10 +173,12 @@ static int cmd_for_each_ref(struct ref_store *refs, const char **argv)
173 static int cmd_for_each_ref__exclude(struct ref_store *refs, const char **argv)
174 {
175 const char *prefix = notnull(*argv++, "prefix");
176 - const char **exclude_patterns = argv;
176 + struct refs_for_each_ref_options opts = {
177 + .prefix = prefix,
178 + .exclude_patterns = argv,
179 + };
180
178 - return refs_for_each_fullref_in(refs, prefix, exclude_patterns, each_ref,
179 - NULL);
181 + return refs_for_each_ref_ext(refs, each_ref, NULL, &opts);
182 }
183
184 static int cmd_resolve_ref(struct ref_store *refs, const char **argv)