From 67034081adc956c4dc8b51f59a9b70b8861c4642 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 23 Feb 2026 12:59:46 +0100 Subject: [PATCH] refs: replace `refs_for_each_rawref()` Replace calls to `refs_for_each_rawref()` with the newly introduced `refs_for_each_ref_ext()` function. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- builtin/describe.c | 7 +++++-- builtin/fsck.c | 7 +++++-- fetch-pack.c | 15 +++++++++++---- refs.c | 10 ++++------ refs.h | 1 - refs/files-backend.c | 7 +++++-- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/builtin/describe.c b/builtin/describe.c index abfe3525a5..bffeed13a3 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -641,6 +641,9 @@ int cmd_describe(int argc, const char *prefix, struct repository *repo UNUSED ) { + struct refs_for_each_ref_options for_each_ref_opts = { + .flags = REFS_FOR_EACH_INCLUDE_BROKEN, + }; int contains = 0; struct option options[] = { OPT_BOOL(0, "contains", &contains, N_("find the tag that comes after the commit")), @@ -738,8 +741,8 @@ int cmd_describe(int argc, } hashmap_init(&names, commit_name_neq, NULL, 0); - refs_for_each_rawref(get_main_ref_store(the_repository), get_name, - NULL); + refs_for_each_ref_ext(get_main_ref_store(the_repository), + get_name, NULL, &for_each_ref_opts); if (!hashmap_get_size(&names) && !always) die(_("No names found, cannot describe anything.")); diff --git a/builtin/fsck.c b/builtin/fsck.c index 0512f78a87..24cdb657f5 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -598,6 +598,9 @@ static int fsck_handle_ref(const struct reference *ref, void *cb_data UNUSED) static void snapshot_refs(struct snapshot *snap, int argc, const char **argv) { + struct refs_for_each_ref_options opts = { + .flags = REFS_FOR_EACH_INCLUDE_BROKEN, + }; struct worktree **worktrees, **p; const char *head_points_at; struct object_id head_oid; @@ -623,8 +626,8 @@ static void snapshot_refs(struct snapshot *snap, int argc, const char **argv) return; } - refs_for_each_rawref(get_main_ref_store(the_repository), - snapshot_ref, snap); + refs_for_each_ref_ext(get_main_ref_store(the_repository), + snapshot_ref, snap, &opts); worktrees = get_worktrees(); for (p = worktrees; *p; p++) { diff --git a/fetch-pack.c b/fetch-pack.c index 40316c9a34..570caa03fa 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -292,11 +292,14 @@ static int next_flush(int stateless_rpc, int count) static void mark_tips(struct fetch_negotiator *negotiator, const struct oid_array *negotiation_tips) { + struct refs_for_each_ref_options opts = { + .flags = REFS_FOR_EACH_INCLUDE_BROKEN, + }; int i; if (!negotiation_tips) { - refs_for_each_rawref(get_main_ref_store(the_repository), - rev_list_insert_ref_oid, negotiator); + refs_for_each_ref_ext(get_main_ref_store(the_repository), + rev_list_insert_ref_oid, negotiator, &opts); return; } @@ -792,8 +795,12 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator, */ trace2_region_enter("fetch-pack", "mark_complete_local_refs", NULL); if (!args->deepen) { - refs_for_each_rawref(get_main_ref_store(the_repository), - mark_complete_oid, NULL); + struct refs_for_each_ref_options opts = { + .flags = REFS_FOR_EACH_INCLUDE_BROKEN, + }; + + refs_for_each_ref_ext(get_main_ref_store(the_repository), + mark_complete_oid, NULL, &opts); for_each_cached_alternate(NULL, mark_alternate_complete); if (cutoff) mark_recent_complete_commits(args, cutoff); diff --git a/refs.c b/refs.c index 7b1ef769c0..791654a0f6 100644 --- a/refs.c +++ b/refs.c @@ -526,7 +526,10 @@ void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp, .indent = indent, .dry_run = dry_run, }; - refs_for_each_rawref(refs, warn_if_dangling_symref, &data); + struct refs_for_each_ref_options opts = { + .flags = REFS_FOR_EACH_INCLUDE_BROKEN, + }; + refs_for_each_ref_ext(refs, warn_if_dangling_symref, &data, &opts); } int refs_for_each_tag_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data) @@ -1979,11 +1982,6 @@ int refs_for_each_namespaced_ref(struct ref_store *refs, return refs_for_each_ref_ext(refs, cb, cb_data, &opts); } -int refs_for_each_rawref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) -{ - return refs_for_each_rawref_in(refs, "", fn, cb_data); -} - int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix, refs_for_each_cb cb, void *cb_data) { diff --git a/refs.h b/refs.h index 7a3bc9e5b7..01dc3c2fd4 100644 --- a/refs.h +++ b/refs.h @@ -543,7 +543,6 @@ int refs_for_each_namespaced_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data); /* can be used to learn about broken ref and symref */ -int refs_for_each_rawref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data); int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix, refs_for_each_cb fn, void *cb_data); diff --git a/refs/files-backend.c b/refs/files-backend.c index 6c98e14414..ab96760781 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3149,6 +3149,9 @@ static int files_transaction_finish_initial(struct files_ref_store *refs, struct ref_transaction *transaction, struct strbuf *err) { + struct refs_for_each_ref_options opts = { + .flags = REFS_FOR_EACH_INCLUDE_BROKEN, + }; size_t i; int ret = 0; struct string_list affected_refnames = STRING_LIST_INIT_NODUP; @@ -3173,8 +3176,8 @@ static int files_transaction_finish_initial(struct files_ref_store *refs, * so here we really only check that none of the references * that we are creating already exists. */ - if (refs_for_each_rawref(&refs->base, ref_present, - &transaction->refnames)) + if (refs_for_each_ref_ext(&refs->base, ref_present, + &transaction->refnames, &opts)) BUG("initial ref transaction called with existing refs"); packed_transaction = ref_store_transaction_begin(refs->packed_ref_store, -- 2.52.0