]> Kevux Git Server - rit/commitdiff
refs: replace `refs_for_each_rawref()`
authorPatrick Steinhardt <ps@pks.im>
Mon, 23 Feb 2026 11:59:46 +0000 (12:59 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Feb 2026 21:21:18 +0000 (13:21 -0800)
Replace calls to `refs_for_each_rawref()` 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>
builtin/describe.c
builtin/fsck.c
fetch-pack.c
refs.c
refs.h
refs/files-backend.c

index abfe3525a5385bfa4dd302b35a92c0902a6da517..bffeed13a3cb14d7ce738597460c29556fe8aa2a 100644 (file)
@@ -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."));
 
index 0512f78a87fe1da9ceb8786da89d94a3e17df72e..24cdb657f5f2f019e28923b03bc46d254d6166b5 100644 (file)
@@ -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++) {
index 40316c9a348f23dc1545930eb4ca7ad0a447affd..570caa03fab33d21dc0e89188e2dc5ea4a7b9e62 100644 (file)
@@ -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 7b1ef769c0ee9dd36e353008ba897a712d952d9b..791654a0f6c4c5a5f90246dcf71949ec335b6dd3 100644 (file)
--- 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 7a3bc9e5b70200d65d22d4e380fba7ff8c9bd5c5..01dc3c2fd40ec9daf30c162afd5dcc10b9cc32b0 100644 (file)
--- 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);
 
index 6c98e14414197bb52c887b1e27e8511cdfb682f1..ab96760781114221b0167fb54e3c8b63951fff51 100644 (file)
@@ -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,