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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2026-02-23 12:59:39 +01:00
committed by Junio C Hamano
parent 8f0720a5a7
commit 635f08b739
11 changed files with 50 additions and 50 deletions

View File

@@ -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;

View File

@@ -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"

View File

@@ -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;

34
refs.c
View File

@@ -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;

38
refs.h
View File

@@ -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 */

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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),

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);