From 8f0720a5a781562fb1f750b351e14129fc8930ea Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 23 Feb 2026 12:59:38 +0100 Subject: refs: rename `do_for_each_ref_flags` The enum `do_for_each_ref_flags` and its individual values don't match to our current best practices when it comes to naming things. Rename it to `refs_for_each_flag`. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- refs/files-backend.c | 12 ++++++------ refs/packed-backend.c | 8 ++++---- refs/reftable-backend.c | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'refs') diff --git a/refs/files-backend.c b/refs/files-backend.c index b1b13b41f6..6c98e14414 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -439,7 +439,7 @@ static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs, dir = get_ref_dir(refs->loose->root); - if (flags & DO_FOR_EACH_INCLUDE_ROOT_REFS) + if (flags & REFS_FOR_EACH_INCLUDE_ROOT_REFS) add_root_refs(refs, dir); /* @@ -955,17 +955,17 @@ static int files_ref_iterator_advance(struct ref_iterator *ref_iterator) int ok; while ((ok = ref_iterator_advance(iter->iter0)) == ITER_OK) { - if (iter->flags & DO_FOR_EACH_PER_WORKTREE_ONLY && + if (iter->flags & REFS_FOR_EACH_PER_WORKTREE_ONLY && parse_worktree_ref(iter->iter0->ref.name, NULL, NULL, NULL) != REF_WORKTREE_CURRENT) continue; - if ((iter->flags & DO_FOR_EACH_OMIT_DANGLING_SYMREFS) && + if ((iter->flags & REFS_FOR_EACH_OMIT_DANGLING_SYMREFS) && (iter->iter0->ref.flags & REF_ISSYMREF) && (iter->iter0->ref.flags & REF_ISBROKEN)) continue; - if (!(iter->flags & DO_FOR_EACH_INCLUDE_BROKEN) && + if (!(iter->flags & REFS_FOR_EACH_INCLUDE_BROKEN) && !ref_resolves_to_object(iter->iter0->ref.name, iter->repo, iter->iter0->ref.oid, @@ -1012,7 +1012,7 @@ static struct ref_iterator *files_ref_iterator_begin( struct ref_iterator *ref_iterator; unsigned int required_flags = REF_STORE_READ; - if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) + if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN)) required_flags |= REF_STORE_ODB; refs = files_downcast(ref_store, required_flags, "ref_iterator_begin"); @@ -1050,7 +1050,7 @@ static struct ref_iterator *files_ref_iterator_begin( */ packed_iter = refs_ref_iterator_begin( refs->packed_ref_store, prefix, exclude_patterns, 0, - DO_FOR_EACH_INCLUDE_BROKEN); + REFS_FOR_EACH_INCLUDE_BROKEN); overlay_iter = overlay_ref_iterator_begin(loose_iter, packed_iter); diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 59b3ecb9d6..5ef4ae32b8 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -982,11 +982,11 @@ static int packed_ref_iterator_advance(struct ref_iterator *ref_iterator) const char *refname = iter->base.ref.name; const char *prefix = iter->prefix; - if (iter->flags & DO_FOR_EACH_PER_WORKTREE_ONLY && + if (iter->flags & REFS_FOR_EACH_PER_WORKTREE_ONLY && !is_per_worktree_ref(iter->base.ref.name)) continue; - if (!(iter->flags & DO_FOR_EACH_INCLUDE_BROKEN) && + if (!(iter->flags & REFS_FOR_EACH_INCLUDE_BROKEN) && !ref_resolves_to_object(iter->base.ref.name, iter->repo, &iter->oid, iter->flags)) continue; @@ -1159,7 +1159,7 @@ static struct ref_iterator *packed_ref_iterator_begin( struct ref_iterator *ref_iterator; unsigned int required_flags = REF_STORE_READ; - if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) + if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN)) required_flags |= REF_STORE_ODB; refs = packed_downcast(ref_store, required_flags, "ref_iterator_begin"); @@ -1401,7 +1401,7 @@ static enum ref_transaction_error write_with_updates(struct packed_ref_store *re * of updates is exhausted, leave i set to updates->nr. */ iter = packed_ref_iterator_begin(&refs->base, "", NULL, - DO_FOR_EACH_INCLUDE_BROKEN); + REFS_FOR_EACH_INCLUDE_BROKEN); if ((ok = ref_iterator_advance(iter)) != ITER_OK) { ref_iterator_free(iter); iter = NULL; diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c index 5611808ad7..34bc074dd3 100644 --- a/refs/reftable-backend.c +++ b/refs/reftable-backend.c @@ -662,7 +662,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator) * the root refs are to be included. We emulate the same behaviour here. */ if (!starts_with(iter->ref.refname, "refs/") && - !(iter->flags & DO_FOR_EACH_INCLUDE_ROOT_REFS && + !(iter->flags & REFS_FOR_EACH_INCLUDE_ROOT_REFS && is_root_ref(iter->ref.refname))) { continue; } @@ -676,7 +676,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator) if (iter->exclude_patterns && should_exclude_current_ref(iter)) continue; - if (iter->flags & DO_FOR_EACH_PER_WORKTREE_ONLY && + if (iter->flags & REFS_FOR_EACH_PER_WORKTREE_ONLY && parse_worktree_ref(iter->ref.refname, NULL, NULL, NULL) != REF_WORKTREE_CURRENT) continue; @@ -714,12 +714,12 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator) flags |= REF_BAD_NAME | REF_ISBROKEN; } - if (iter->flags & DO_FOR_EACH_OMIT_DANGLING_SYMREFS && + if (iter->flags & REFS_FOR_EACH_OMIT_DANGLING_SYMREFS && flags & REF_ISSYMREF && flags & REF_ISBROKEN) continue; - if (!(iter->flags & DO_FOR_EACH_INCLUDE_BROKEN) && + if (!(iter->flags & REFS_FOR_EACH_INCLUDE_BROKEN) && !ref_resolves_to_object(iter->ref.refname, refs->base.repo, &iter->oid, flags)) continue; @@ -871,7 +871,7 @@ static struct ref_iterator *reftable_be_iterator_begin(struct ref_store *ref_sto struct reftable_ref_store *refs; unsigned int required_flags = REF_STORE_READ; - if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) + if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN)) required_flags |= REF_STORE_ODB; refs = reftable_be_downcast(ref_store, required_flags, "ref_iterator_begin"); -- cgit v1.3 From 635f08b7394b9dda013a0b78f4db11348dc7717b Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 23 Feb 2026 12:59:39 +0100 Subject: refs: rename `each_ref_fn` Similar to the preceding commit, rename `each_ref_fn` to better match our current best practices around how we name things. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- pack-bitmap.c | 2 +- pack-bitmap.h | 2 +- ref-filter.c | 6 +++--- refs.c | 34 +++++++++++++++++----------------- refs.h | 38 +++++++++++++++++++------------------- refs/iterator.c | 2 +- revision.c | 8 ++++---- submodule.c | 2 +- upload-pack.c | 2 +- worktree.c | 2 +- worktree.h | 2 +- 11 files changed, 50 insertions(+), 50 deletions(-) (limited to 'refs') diff --git a/pack-bitmap.c b/pack-bitmap.c index 1c93871484..efef7081e6 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -3324,7 +3324,7 @@ static const struct string_list *bitmap_preferred_tips(struct repository *r) } void for_each_preferred_bitmap_tip(struct repository *repo, - each_ref_fn cb, void *cb_data) + refs_for_each_cb cb, void *cb_data) { struct string_list_item *item; const struct string_list *preferred_tips; diff --git a/pack-bitmap.h b/pack-bitmap.h index d0611d0481..a95e1c2d11 100644 --- a/pack-bitmap.h +++ b/pack-bitmap.h @@ -105,7 +105,7 @@ int for_each_bitmapped_object(struct bitmap_index *bitmap_git, * "pack.preferBitmapTips" and invoke the callback on each function. */ void for_each_preferred_bitmap_tip(struct repository *repo, - each_ref_fn cb, void *cb_data); + refs_for_each_cb cb, void *cb_data); #define GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL \ "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL" diff --git a/ref-filter.c b/ref-filter.c index 4bc54ebd9d..049e845a19 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -2781,7 +2781,7 @@ static int start_ref_iterator_after(struct ref_iterator *iter, const char *marke return ret; } -static int for_each_fullref_with_seek(struct ref_filter *filter, each_ref_fn cb, +static int for_each_fullref_with_seek(struct ref_filter *filter, refs_for_each_cb cb, void *cb_data, unsigned int flags) { struct ref_iterator *iter; @@ -2804,7 +2804,7 @@ static int for_each_fullref_with_seek(struct ref_filter *filter, each_ref_fn cb, * pattern match, so the callback still has to match each ref individually. */ static int for_each_fullref_in_pattern(struct ref_filter *filter, - each_ref_fn cb, + refs_for_each_cb cb, void *cb_data) { if (filter->kind & FILTER_REFS_ROOT_REFS) { @@ -3303,7 +3303,7 @@ void filter_is_base(struct repository *r, free(bases); } -static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref_fn fn, void *cb_data) +static int do_filter_refs(struct ref_filter *filter, unsigned int type, refs_for_each_cb fn, void *cb_data) { const char *prefix = NULL; int ret = 0; diff --git a/refs.c b/refs.c index 52a680797a..a45cc61211 100644 --- a/refs.c +++ b/refs.c @@ -445,7 +445,7 @@ char *refs_resolve_refdup(struct ref_store *refs, struct for_each_ref_filter { const char *pattern; const char *prefix; - each_ref_fn *fn; + refs_for_each_cb *fn; void *cb_data; }; @@ -527,22 +527,22 @@ void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp, refs_for_each_rawref(refs, warn_if_dangling_symref, &data); } -int refs_for_each_tag_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) +int refs_for_each_tag_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) { return refs_for_each_ref_in(refs, "refs/tags/", fn, cb_data); } -int refs_for_each_branch_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) +int refs_for_each_branch_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) { return refs_for_each_ref_in(refs, "refs/heads/", fn, cb_data); } -int refs_for_each_remote_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) +int refs_for_each_remote_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) { return refs_for_each_ref_in(refs, "refs/remotes/", fn, cb_data); } -int refs_head_ref_namespaced(struct ref_store *refs, each_ref_fn fn, void *cb_data) +int refs_head_ref_namespaced(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) { struct strbuf buf = STRBUF_INIT; int ret = 0; @@ -590,7 +590,7 @@ void normalize_glob_ref(struct string_list_item *item, const char *prefix, strbuf_release(&normalized_pattern); } -int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn, +int refs_for_each_glob_ref_in(struct ref_store *refs, refs_for_each_cb fn, const char *pattern, const char *prefix, void *cb_data) { struct strbuf real_pattern = STRBUF_INIT; @@ -620,7 +620,7 @@ int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn, return ret; } -int refs_for_each_glob_ref(struct ref_store *refs, each_ref_fn fn, +int refs_for_each_glob_ref(struct ref_store *refs, refs_for_each_cb fn, const char *pattern, void *cb_data) { return refs_for_each_glob_ref_in(refs, fn, pattern, NULL, cb_data); @@ -1788,7 +1788,7 @@ const char *find_descendant_ref(const char *dirname, return NULL; } -int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) +int refs_head_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) { struct object_id oid; int flag; @@ -1860,7 +1860,7 @@ struct ref_iterator *refs_ref_iterator_begin( static int do_for_each_ref(struct ref_store *refs, const char *prefix, const char **exclude_patterns, - each_ref_fn fn, int trim, + refs_for_each_cb fn, int trim, enum refs_for_each_flag flags, void *cb_data) { struct ref_iterator *iter; @@ -1874,25 +1874,25 @@ static int do_for_each_ref(struct ref_store *refs, const char *prefix, return do_for_each_ref_iterator(iter, fn, cb_data); } -int refs_for_each_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) +int refs_for_each_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) { return do_for_each_ref(refs, "", NULL, fn, 0, 0, cb_data); } int refs_for_each_ref_in(struct ref_store *refs, const char *prefix, - each_ref_fn fn, void *cb_data) + refs_for_each_cb fn, void *cb_data) { return do_for_each_ref(refs, prefix, NULL, fn, strlen(prefix), 0, cb_data); } int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix, const char **exclude_patterns, - each_ref_fn fn, void *cb_data) + refs_for_each_cb fn, void *cb_data) { return do_for_each_ref(refs, prefix, exclude_patterns, fn, 0, 0, cb_data); } -int refs_for_each_replace_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) +int refs_for_each_replace_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) { const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref; return do_for_each_ref(refs, git_replace_ref_base, NULL, fn, @@ -1902,7 +1902,7 @@ int refs_for_each_replace_ref(struct ref_store *refs, each_ref_fn fn, void *cb_d int refs_for_each_namespaced_ref(struct ref_store *refs, const char **exclude_patterns, - each_ref_fn fn, void *cb_data) + refs_for_each_cb fn, void *cb_data) { struct strvec namespaced_exclude_patterns = STRVEC_INIT; struct strbuf prefix = STRBUF_INIT; @@ -1920,13 +1920,13 @@ int refs_for_each_namespaced_ref(struct ref_store *refs, return ret; } -int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data) +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, - each_ref_fn fn, void *cb_data) + refs_for_each_cb fn, void *cb_data) { return do_for_each_ref(refs, prefix, NULL, fn, 0, REFS_FOR_EACH_INCLUDE_BROKEN, cb_data); @@ -1994,7 +1994,7 @@ int refs_for_each_fullref_in_prefixes(struct ref_store *ref_store, const char *namespace, const char **patterns, const char **exclude_patterns, - each_ref_fn fn, void *cb_data) + refs_for_each_cb fn, void *cb_data) { struct strvec namespaced_exclude_patterns = STRVEC_INIT; struct string_list prefixes = STRING_LIST_INIT_DUP; diff --git a/refs.h b/refs.h index 2ae4a6e75b..5190e98b2c 100644 --- a/refs.h +++ b/refs.h @@ -170,7 +170,7 @@ int ref_store_remove_on_disk(struct ref_store *refs, struct strbuf *err); * * peel_object(r, oid, &peeled); * - * with the "oid" value given to the each_ref_fn callback, except + * with the "oid" value given to the refs_for_each_cb callback, except * that some ref storage may be able to answer the query without * actually loading the object in memory. */ @@ -329,7 +329,7 @@ int check_tag_ref(struct strbuf *sb, const char *name); struct ref_transaction; /* - * Bit values set in the flags argument passed to each_ref_fn() and + * Bit values set in the flags argument passed to refs_for_each_cb() and * stored in ref_iterator::flags. Other bits are for internal use * only: */ @@ -400,7 +400,7 @@ int reference_get_peeled_oid(struct repository *repo, * argument is only guaranteed to be valid for the duration of a * single callback invocation. */ -typedef int each_ref_fn(const struct reference *ref, void *cb_data); +typedef int refs_for_each_cb(const struct reference *ref, void *cb_data); /* * These flags are passed to refs_ref_iterator_begin() (and do_for_each_ref(), @@ -449,22 +449,22 @@ enum refs_for_each_flag { * stop the iteration. Returned references are sorted. */ int refs_head_ref(struct ref_store *refs, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); int refs_head_ref_namespaced(struct ref_store *refs, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); int refs_for_each_ref(struct ref_store *refs, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); int refs_for_each_ref_in(struct ref_store *refs, const char *prefix, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); int refs_for_each_tag_ref(struct ref_store *refs, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); int refs_for_each_branch_ref(struct ref_store *refs, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); int refs_for_each_remote_ref(struct ref_store *refs, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); int refs_for_each_replace_ref(struct ref_store *refs, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); /* * references matching any pattern in "exclude_patterns" are omitted from the @@ -472,7 +472,7 @@ int refs_for_each_replace_ref(struct ref_store *refs, */ int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix, const char **exclude_patterns, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); /** * iterate all refs in "patterns" by partitioning patterns into disjoint sets @@ -487,13 +487,13 @@ int refs_for_each_fullref_in_prefixes(struct ref_store *refs, const char *namespace, const char **patterns, const char **exclude_patterns, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); /* iterates all refs that match the specified glob pattern. */ -int refs_for_each_glob_ref(struct ref_store *refs, each_ref_fn fn, +int refs_for_each_glob_ref(struct ref_store *refs, refs_for_each_cb fn, const char *pattern, void *cb_data); -int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn, +int refs_for_each_glob_ref_in(struct ref_store *refs, refs_for_each_cb fn, const char *pattern, const char *prefix, void *cb_data); /* @@ -502,12 +502,12 @@ int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn, */ int refs_for_each_namespaced_ref(struct ref_store *refs, const char **exclude_patterns, - each_ref_fn fn, void *cb_data); + 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, each_ref_fn fn, void *cb_data); +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, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); /* * Normalizes partial refs to their fully qualified form. @@ -1421,6 +1421,6 @@ void ref_iterator_free(struct ref_iterator *ref_iterator); * iterator style. */ int do_for_each_ref_iterator(struct ref_iterator *iter, - each_ref_fn fn, void *cb_data); + refs_for_each_cb fn, void *cb_data); #endif /* REFS_H */ diff --git a/refs/iterator.c b/refs/iterator.c index d79aa5ec82..d5cacde51b 100644 --- a/refs/iterator.c +++ b/refs/iterator.c @@ -423,7 +423,7 @@ struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0, } int do_for_each_ref_iterator(struct ref_iterator *iter, - each_ref_fn fn, void *cb_data) + refs_for_each_cb fn, void *cb_data) { int retval = 0, ok; diff --git a/revision.c b/revision.c index 29972c3a19..8c206830d5 100644 --- a/revision.c +++ b/revision.c @@ -1646,7 +1646,7 @@ static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs, static void handle_refs(struct ref_store *refs, struct rev_info *revs, unsigned flags, - int (*for_each)(struct ref_store *, each_ref_fn, void *)) + int (*for_each)(struct ref_store *, refs_for_each_cb, void *)) { struct all_refs_cb cb; @@ -2728,7 +2728,7 @@ void revision_opts_finish(struct rev_info *revs) } } -static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn, +static int for_each_bisect_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data, const char *term) { struct strbuf bisect_refs = STRBUF_INIT; @@ -2739,12 +2739,12 @@ static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn, return status; } -static int for_each_bad_bisect_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) +static int for_each_bad_bisect_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) { return for_each_bisect_ref(refs, fn, cb_data, term_bad); } -static int for_each_good_bisect_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) +static int for_each_good_bisect_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data) { return for_each_bisect_ref(refs, fn, cb_data, term_good); } diff --git a/submodule.c b/submodule.c index 508938e4da..4f9aaa2c75 100644 --- a/submodule.c +++ b/submodule.c @@ -101,7 +101,7 @@ int is_staging_gitmodules_ok(struct index_state *istate) } static int for_each_remote_ref_submodule(const char *submodule, - each_ref_fn fn, void *cb_data) + refs_for_each_cb fn, void *cb_data) { return refs_for_each_remote_ref(repo_get_submodule_ref_store(the_repository, submodule), diff --git a/upload-pack.c b/upload-pack.c index 2d2b70cbf2..7fe397b0d0 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -607,7 +607,7 @@ static int allow_hidden_refs(enum allow_uor allow_uor) return !(allow_uor & (ALLOW_TIP_SHA1 | ALLOW_REACHABLE_SHA1)); } -static void for_each_namespaced_ref_1(each_ref_fn fn, +static void for_each_namespaced_ref_1(refs_for_each_cb fn, struct upload_pack_data *data) { const char **excludes = NULL; diff --git a/worktree.c b/worktree.c index 9308389cb6..bf8c54c04d 100644 --- a/worktree.c +++ b/worktree.c @@ -575,7 +575,7 @@ void strbuf_worktree_ref(const struct worktree *wt, strbuf_addstr(sb, refname); } -int other_head_refs(each_ref_fn fn, void *cb_data) +int other_head_refs(refs_for_each_cb fn, void *cb_data) { struct worktree **worktrees, **p; struct strbuf refname = STRBUF_INIT; diff --git a/worktree.h b/worktree.h index e4bcccdc0a..12484a91a7 100644 --- a/worktree.h +++ b/worktree.h @@ -191,7 +191,7 @@ int is_shared_symref(const struct worktree *wt, * Similar to head_ref() for all HEADs _except_ one from the current * worktree, which is covered by head_ref(). */ -int other_head_refs(each_ref_fn fn, void *cb_data); +int other_head_refs(refs_for_each_cb fn, void *cb_data); int is_worktree_being_rebased(const struct worktree *wt, const char *target); int is_worktree_being_bisected(const struct worktree *wt, const char *target); -- cgit v1.3 From 67034081adc956c4dc8b51f59a9b70b8861c4642 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 23 Feb 2026 12:59:46 +0100 Subject: 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(-) (limited to 'refs') 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, -- cgit v1.3