aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-02-23 12:59:51 +0100
committerJunio C Hamano <gitster@pobox.com>2026-02-23 13:21:19 -0800
commit1dd4f1e43f8f11ebb13c1b9edbd91219a134443d (patch)
tree710bfca410849ab8e8894fb38977c13013438127
parent96c35a9ba5f1b5afac1e30ca93815dcd540d8b16 (diff)
downloadgit-1dd4f1e43f8f11ebb13c1b9edbd91219a134443d.tar.xz
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>
-rw-r--r--bisect.c8
-rw-r--r--builtin/receive-pack.c8
-rw-r--r--builtin/rev-parse.c15
-rw-r--r--builtin/show-ref.c21
-rw-r--r--refs.c11
-rw-r--r--refs.h8
-rw-r--r--revision.c4
-rw-r--r--t/helper/test-ref-store.c8
8 files changed, 37 insertions, 46 deletions
diff --git a/bisect.c b/bisect.c
index 296836c154..ef17a442e5 100644
--- a/bisect.c
+++ b/bisect.c
@@ -1190,13 +1190,15 @@ static int mark_for_removal(const struct reference *ref, void *cb_data)
int bisect_clean_state(void)
{
+ struct refs_for_each_ref_options opts = {
+ .prefix = "refs/bisect/",
+ };
int result = 0;
/* There may be some refs packed during bisection */
struct string_list refs_for_removal = STRING_LIST_INIT_DUP;
- refs_for_each_fullref_in(get_main_ref_store(the_repository),
- "refs/bisect/", NULL, mark_for_removal,
- &refs_for_removal);
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
+ mark_for_removal, &refs_for_removal, &opts);
string_list_append(&refs_for_removal, "BISECT_HEAD");
string_list_append(&refs_for_removal, "BISECT_EXPECTED_REV");
result = refs_delete_refs(get_main_ref_store(the_repository),
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 4c0112b4bc..8c5ad5b81e 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -343,9 +343,9 @@ static void show_one_alternate_ref(const struct object_id *oid,
static void write_head_info(void)
{
+ struct refs_for_each_ref_options opts = { 0 };
static struct oidset seen = OIDSET_INIT;
struct strvec excludes_vector = STRVEC_INIT;
- const char **exclude_patterns;
/*
* We need access to the reference names both with and without their
@@ -353,12 +353,12 @@ static void write_head_info(void)
* thus have to adapt exclude patterns to carry the namespace prefix
* ourselves.
*/
- exclude_patterns = get_namespaced_exclude_patterns(
+ opts.exclude_patterns = get_namespaced_exclude_patterns(
hidden_refs_to_excludes(&hidden_refs),
get_git_namespace(), &excludes_vector);
- refs_for_each_fullref_in(get_main_ref_store(the_repository), "",
- exclude_patterns, show_ref_cb, &seen);
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
+ show_ref_cb, &seen, &opts);
odb_for_each_alternate_ref(the_repository->objects,
show_one_alternate_ref, &seen);
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 61a3f0fdb9..01a62800e8 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -940,14 +940,13 @@ int cmd_rev_parse(int argc,
continue;
}
if (!strcmp(arg, "--bisect")) {
- refs_for_each_fullref_in(get_main_ref_store(the_repository),
- "refs/bisect/bad",
- NULL, show_reference,
- NULL);
- refs_for_each_fullref_in(get_main_ref_store(the_repository),
- "refs/bisect/good",
- NULL, anti_reference,
- NULL);
+ struct refs_for_each_ref_options opts = { 0 };
+ opts.prefix = "refs/bisect/bad";
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
+ show_reference, NULL, &opts);
+ opts.prefix = "refs/bisect/good";
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
+ anti_reference, NULL, &opts);
continue;
}
if (opt_with_value(arg, "--branches", &arg)) {
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 4d4984e4e0..5d31acea7c 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -215,14 +215,19 @@ static int cmd_show_ref__patterns(const struct patterns_options *opts,
refs_head_ref(get_main_ref_store(the_repository), show_ref,
&show_ref_data);
if (opts->branches_only || opts->tags_only) {
- if (opts->branches_only)
- refs_for_each_fullref_in(get_main_ref_store(the_repository),
- "refs/heads/", NULL,
- show_ref, &show_ref_data);
- if (opts->tags_only)
- refs_for_each_fullref_in(get_main_ref_store(the_repository),
- "refs/tags/", NULL, show_ref,
- &show_ref_data);
+ struct refs_for_each_ref_options for_each_ref_opts = { 0 };
+
+ if (opts->branches_only) {
+ for_each_ref_opts.prefix = "refs/heads/";
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
+ show_ref, &show_ref_data, &for_each_ref_opts);
+ }
+
+ if (opts->tags_only) {
+ for_each_ref_opts.prefix = "refs/tags/";
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
+ show_ref, &show_ref_data, &for_each_ref_opts);
+ }
} else {
refs_for_each_ref(get_main_ref_store(the_repository),
show_ref, &show_ref_data);
diff --git a/refs.c b/refs.c
index 35a4925ac4..af51a648d5 100644
--- a/refs.c
+++ b/refs.c
@@ -1929,17 +1929,6 @@ int refs_for_each_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data
return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
}
-int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
- const char **exclude_patterns,
- refs_for_each_cb cb, void *cb_data)
-{
- struct refs_for_each_ref_options opts = {
- .prefix = prefix,
- .exclude_patterns = exclude_patterns,
- };
- return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
-}
-
int refs_for_each_replace_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data)
{
const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
diff --git a/refs.h b/refs.h
index 1b468c4ffb..9b5d57a9b7 100644
--- a/refs.h
+++ b/refs.h
@@ -510,14 +510,6 @@ int refs_for_each_remote_ref(struct ref_store *refs,
int refs_for_each_replace_ref(struct ref_store *refs,
refs_for_each_cb fn, void *cb_data);
-/*
- * references matching any pattern in "exclude_patterns" are omitted from the
- * result set on a best-effort basis.
- */
-int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
- const char **exclude_patterns,
- refs_for_each_cb fn, void *cb_data);
-
/**
* Iterate all refs in "prefixes" by partitioning prefixes into disjoint sets
* and iterating the longest-common prefix of each set.
diff --git a/revision.c b/revision.c
index 4ddb3370c6..0136ef64f5 100644
--- a/revision.c
+++ b/revision.c
@@ -2731,10 +2731,12 @@ void revision_opts_finish(struct rev_info *revs)
static int for_each_bisect_ref(struct ref_store *refs, refs_for_each_cb fn,
void *cb_data, const char *term)
{
+ struct refs_for_each_ref_options opts = { 0 };
struct strbuf bisect_refs = STRBUF_INIT;
int status;
strbuf_addf(&bisect_refs, "refs/bisect/%s", term);
- status = refs_for_each_fullref_in(refs, bisect_refs.buf, NULL, fn, cb_data);
+ opts.prefix = bisect_refs.buf;
+ status = refs_for_each_ref_ext(refs, fn, cb_data, &opts);
strbuf_release(&bisect_refs);
return status;
}
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index a2ef1b6949..74edf2029a 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -173,10 +173,12 @@ static int cmd_for_each_ref(struct ref_store *refs, const char **argv)
static int cmd_for_each_ref__exclude(struct ref_store *refs, const char **argv)
{
const char *prefix = notnull(*argv++, "prefix");
- const char **exclude_patterns = argv;
+ struct refs_for_each_ref_options opts = {
+ .prefix = prefix,
+ .exclude_patterns = argv,
+ };
- return refs_for_each_fullref_in(refs, prefix, exclude_patterns, each_ref,
- NULL);
+ return refs_for_each_ref_ext(refs, each_ref, NULL, &opts);
}
static int cmd_resolve_ref(struct ref_store *refs, const char **argv)