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>

Patrick Steinhardt committed Feb 23, 2026 at 12:59 UTC 635f08b7394b9dda013a0b78f4db11348dc7717b
11 files changed +50 -50
pack-bitmap.c
+1 -1
@@ -3324,7 +3324,7 @@ static const struct string_list *bitmap_preferred_tips(struct repository *r)
3324 }
3325
3326 void for_each_preferred_bitmap_tip(struct repository *repo,
3327 - each_ref_fn cb, void *cb_data)
3327 + refs_for_each_cb cb, void *cb_data)
3328 {
3329 struct string_list_item *item;
3330 const struct string_list *preferred_tips;
pack-bitmap.h
+1 -1
@@ -105,7 +105,7 @@ int for_each_bitmapped_object(struct bitmap_index *bitmap_git,
105 * "pack.preferBitmapTips" and invoke the callback on each function.
106 */
107 void for_each_preferred_bitmap_tip(struct repository *repo,
108 - each_ref_fn cb, void *cb_data);
108 + refs_for_each_cb cb, void *cb_data);
109
110 #define GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL \
111 "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL"
ref-filter.c
+3 -3
@@ -2781,7 +2781,7 @@ static int start_ref_iterator_after(struct ref_iterator *iter, const char *marke
2781 return ret;
2782 }
2783
2784 -static int for_each_fullref_with_seek(struct ref_filter *filter, each_ref_fn cb,
2784 +static int for_each_fullref_with_seek(struct ref_filter *filter, refs_for_each_cb cb,
2785 void *cb_data, unsigned int flags)
2786 {
2787 struct ref_iterator *iter;
@@ -2804,7 +2804,7 @@ static int for_each_fullref_with_seek(struct ref_filter *filter, each_ref_fn cb,
2804 * pattern match, so the callback still has to match each ref individually.
2805 */
2806 static int for_each_fullref_in_pattern(struct ref_filter *filter,
2807 - each_ref_fn cb,
2807 + refs_for_each_cb cb,
2808 void *cb_data)
2809 {
2810 if (filter->kind & FILTER_REFS_ROOT_REFS) {
@@ -3303,7 +3303,7 @@ void filter_is_base(struct repository *r,
3303 free(bases);
3304 }
3305
3306 -static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref_fn fn, void *cb_data)
3306 +static int do_filter_refs(struct ref_filter *filter, unsigned int type, refs_for_each_cb fn, void *cb_data)
3307 {
3308 const char *prefix = NULL;
3309 int ret = 0;
refs.c
+17 -17
@@ -445,7 +445,7 @@ char *refs_resolve_refdup(struct ref_store *refs,
445 struct for_each_ref_filter {
446 const char *pattern;
447 const char *prefix;
448 - each_ref_fn *fn;
448 + refs_for_each_cb *fn;
449 void *cb_data;
450 };
451
@@ -527,22 +527,22 @@ void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp,
527 refs_for_each_rawref(refs, warn_if_dangling_symref, &data);
528 }
529
530 -int refs_for_each_tag_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
530 +int refs_for_each_tag_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
531 {
532 return refs_for_each_ref_in(refs, "refs/tags/", fn, cb_data);
533 }
534
535 -int refs_for_each_branch_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
535 +int refs_for_each_branch_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
536 {
537 return refs_for_each_ref_in(refs, "refs/heads/", fn, cb_data);
538 }
539
540 -int refs_for_each_remote_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
540 +int refs_for_each_remote_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
541 {
542 return refs_for_each_ref_in(refs, "refs/remotes/", fn, cb_data);
543 }
544
545 -int refs_head_ref_namespaced(struct ref_store *refs, each_ref_fn fn, void *cb_data)
545 +int refs_head_ref_namespaced(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
546 {
547 struct strbuf buf = STRBUF_INIT;
548 int ret = 0;
@@ -590,7 +590,7 @@ void normalize_glob_ref(struct string_list_item *item, const char *prefix,
590 strbuf_release(&normalized_pattern);
591 }
592
593 -int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn,
593 +int refs_for_each_glob_ref_in(struct ref_store *refs, refs_for_each_cb fn,
594 const char *pattern, const char *prefix, void *cb_data)
595 {
596 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,
620 return ret;
621 }
622
623 -int refs_for_each_glob_ref(struct ref_store *refs, each_ref_fn fn,
623 +int refs_for_each_glob_ref(struct ref_store *refs, refs_for_each_cb fn,
624 const char *pattern, void *cb_data)
625 {
626 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,
1788 return NULL;
1789 }
1790
1791 -int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
1791 +int refs_head_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
1792 {
1793 struct object_id oid;
1794 int flag;
@@ -1860,7 +1860,7 @@ struct ref_iterator *refs_ref_iterator_begin(
1860
1861 static int do_for_each_ref(struct ref_store *refs, const char *prefix,
1862 const char **exclude_patterns,
1863 - each_ref_fn fn, int trim,
1863 + refs_for_each_cb fn, int trim,
1864 enum refs_for_each_flag flags, void *cb_data)
1865 {
1866 struct ref_iterator *iter;
@@ -1874,25 +1874,25 @@ static int do_for_each_ref(struct ref_store *refs, const char *prefix,
1874 return do_for_each_ref_iterator(iter, fn, cb_data);
1875 }
1876
1877 -int refs_for_each_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
1877 +int refs_for_each_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
1878 {
1879 return do_for_each_ref(refs, "", NULL, fn, 0, 0, cb_data);
1880 }
1881
1882 int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,
1883 - each_ref_fn fn, void *cb_data)
1883 + refs_for_each_cb fn, void *cb_data)
1884 {
1885 return do_for_each_ref(refs, prefix, NULL, fn, strlen(prefix), 0, cb_data);
1886 }
1887
1888 int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
1889 const char **exclude_patterns,
1890 - each_ref_fn fn, void *cb_data)
1890 + refs_for_each_cb fn, void *cb_data)
1891 {
1892 return do_for_each_ref(refs, prefix, exclude_patterns, fn, 0, 0, cb_data);
1893 }
1894
1895 -int refs_for_each_replace_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
1895 +int refs_for_each_replace_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
1896 {
1897 const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
1898 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
1902
1903 int refs_for_each_namespaced_ref(struct ref_store *refs,
1904 const char **exclude_patterns,
1905 - each_ref_fn fn, void *cb_data)
1905 + refs_for_each_cb fn, void *cb_data)
1906 {
1907 struct strvec namespaced_exclude_patterns = STRVEC_INIT;
1908 struct strbuf prefix = STRBUF_INIT;
@@ -1920,13 +1920,13 @@ int refs_for_each_namespaced_ref(struct ref_store *refs,
1920 return ret;
1921 }
1922
1923 -int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
1923 +int refs_for_each_rawref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
1924 {
1925 return refs_for_each_rawref_in(refs, "", fn, cb_data);
1926 }
1927
1928 int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix,
1929 - each_ref_fn fn, void *cb_data)
1929 + refs_for_each_cb fn, void *cb_data)
1930 {
1931 return do_for_each_ref(refs, prefix, NULL, fn, 0,
1932 REFS_FOR_EACH_INCLUDE_BROKEN, cb_data);
@@ -1994,7 +1994,7 @@ int refs_for_each_fullref_in_prefixes(struct ref_store *ref_store,
1994 const char *namespace,
1995 const char **patterns,
1996 const char **exclude_patterns,
1997 - each_ref_fn fn, void *cb_data)
1997 + refs_for_each_cb fn, void *cb_data)
1998 {
1999 struct strvec namespaced_exclude_patterns = STRVEC_INIT;
2000 struct string_list prefixes = STRING_LIST_INIT_DUP;
refs.h
+19 -19
@@ -170,7 +170,7 @@ int ref_store_remove_on_disk(struct ref_store *refs, struct strbuf *err);
170 *
171 * peel_object(r, oid, &peeled);
172 *
173 - * with the "oid" value given to the each_ref_fn callback, except
173 + * with the "oid" value given to the refs_for_each_cb callback, except
174 * that some ref storage may be able to answer the query without
175 * actually loading the object in memory.
176 */
@@ -329,7 +329,7 @@ int check_tag_ref(struct strbuf *sb, const char *name);
329 struct ref_transaction;
330
331 /*
332 - * Bit values set in the flags argument passed to each_ref_fn() and
332 + * Bit values set in the flags argument passed to refs_for_each_cb() and
333 * stored in ref_iterator::flags. Other bits are for internal use
334 * only:
335 */
@@ -400,7 +400,7 @@ int reference_get_peeled_oid(struct repository *repo,
400 * argument is only guaranteed to be valid for the duration of a
401 * single callback invocation.
402 */
403 -typedef int each_ref_fn(const struct reference *ref, void *cb_data);
403 +typedef int refs_for_each_cb(const struct reference *ref, void *cb_data);
404
405 /*
406 * These flags are passed to refs_ref_iterator_begin() (and do_for_each_ref(),
@@ -449,22 +449,22 @@ enum refs_for_each_flag {
449 * stop the iteration. Returned references are sorted.
450 */
451 int refs_head_ref(struct ref_store *refs,
452 - each_ref_fn fn, void *cb_data);
452 + refs_for_each_cb fn, void *cb_data);
453 int refs_head_ref_namespaced(struct ref_store *refs,
454 - each_ref_fn fn, void *cb_data);
454 + refs_for_each_cb fn, void *cb_data);
455
456 int refs_for_each_ref(struct ref_store *refs,
457 - each_ref_fn fn, void *cb_data);
457 + refs_for_each_cb fn, void *cb_data);
458 int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,
459 - each_ref_fn fn, void *cb_data);
459 + refs_for_each_cb fn, void *cb_data);
460 int refs_for_each_tag_ref(struct ref_store *refs,
461 - each_ref_fn fn, void *cb_data);
461 + refs_for_each_cb fn, void *cb_data);
462 int refs_for_each_branch_ref(struct ref_store *refs,
463 - each_ref_fn fn, void *cb_data);
463 + refs_for_each_cb fn, void *cb_data);
464 int refs_for_each_remote_ref(struct ref_store *refs,
465 - each_ref_fn fn, void *cb_data);
465 + refs_for_each_cb fn, void *cb_data);
466 int refs_for_each_replace_ref(struct ref_store *refs,
467 - each_ref_fn fn, void *cb_data);
467 + refs_for_each_cb fn, void *cb_data);
468
469 /*
470 * 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,
472 */
473 int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
474 const char **exclude_patterns,
475 - each_ref_fn fn, void *cb_data);
475 + refs_for_each_cb fn, void *cb_data);
476
477 /**
478 * 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,
487 const char *namespace,
488 const char **patterns,
489 const char **exclude_patterns,
490 - each_ref_fn fn, void *cb_data);
490 + refs_for_each_cb fn, void *cb_data);
491
492 /* iterates all refs that match the specified glob pattern. */
493 -int refs_for_each_glob_ref(struct ref_store *refs, each_ref_fn fn,
493 +int refs_for_each_glob_ref(struct ref_store *refs, refs_for_each_cb fn,
494 const char *pattern, void *cb_data);
495
496 -int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn,
496 +int refs_for_each_glob_ref_in(struct ref_store *refs, refs_for_each_cb fn,
497 const char *pattern, const char *prefix, void *cb_data);
498
499 /*
@@ -502,12 +502,12 @@ int refs_for_each_glob_ref_in(struct ref_store *refs, each_ref_fn fn,
502 */
503 int refs_for_each_namespaced_ref(struct ref_store *refs,
504 const char **exclude_patterns,
505 - each_ref_fn fn, void *cb_data);
505 + refs_for_each_cb fn, void *cb_data);
506
507 /* can be used to learn about broken ref and symref */
508 -int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data);
508 +int refs_for_each_rawref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data);
509 int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix,
510 - each_ref_fn fn, void *cb_data);
510 + refs_for_each_cb fn, void *cb_data);
511
512 /*
513 * Normalizes partial refs to their fully qualified form.
@@ -1421,6 +1421,6 @@ void ref_iterator_free(struct ref_iterator *ref_iterator);
1421 * iterator style.
1422 */
1423 int do_for_each_ref_iterator(struct ref_iterator *iter,
1424 - each_ref_fn fn, void *cb_data);
1424 + refs_for_each_cb fn, void *cb_data);
1425
1426 #endif /* REFS_H */
refs/iterator.c
+1 -1
@@ -423,7 +423,7 @@ struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0,
423 }
424
425 int do_for_each_ref_iterator(struct ref_iterator *iter,
426 - each_ref_fn fn, void *cb_data)
426 + refs_for_each_cb fn, void *cb_data)
427 {
428 int retval = 0, ok;
429
revision.c
+4 -4
@@ -1646,7 +1646,7 @@ static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs,
1646
1647 static void handle_refs(struct ref_store *refs,
1648 struct rev_info *revs, unsigned flags,
1649 - int (*for_each)(struct ref_store *, each_ref_fn, void *))
1649 + int (*for_each)(struct ref_store *, refs_for_each_cb, void *))
1650 {
1651 struct all_refs_cb cb;
1652
@@ -2728,7 +2728,7 @@ void revision_opts_finish(struct rev_info *revs)
2728 }
2729 }
2730
2731 -static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn,
2731 +static int for_each_bisect_ref(struct ref_store *refs, refs_for_each_cb fn,
2732 void *cb_data, const char *term)
2733 {
2734 struct strbuf bisect_refs = STRBUF_INIT;
@@ -2739,12 +2739,12 @@ static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn,
2739 return status;
2740 }
2741
2742 -static int for_each_bad_bisect_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
2742 +static int for_each_bad_bisect_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
2743 {
2744 return for_each_bisect_ref(refs, fn, cb_data, term_bad);
2745 }
2746
2747 -static int for_each_good_bisect_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
2747 +static int for_each_good_bisect_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
2748 {
2749 return for_each_bisect_ref(refs, fn, cb_data, term_good);
2750 }
submodule.c
+1 -1
@@ -101,7 +101,7 @@ int is_staging_gitmodules_ok(struct index_state *istate)
101 }
102
103 static int for_each_remote_ref_submodule(const char *submodule,
104 - each_ref_fn fn, void *cb_data)
104 + refs_for_each_cb fn, void *cb_data)
105 {
106 return refs_for_each_remote_ref(repo_get_submodule_ref_store(the_repository,
107 submodule),
upload-pack.c
+1 -1
@@ -607,7 +607,7 @@ static int allow_hidden_refs(enum allow_uor allow_uor)
607 return !(allow_uor & (ALLOW_TIP_SHA1 | ALLOW_REACHABLE_SHA1));
608 }
609
610 -static void for_each_namespaced_ref_1(each_ref_fn fn,
610 +static void for_each_namespaced_ref_1(refs_for_each_cb fn,
611 struct upload_pack_data *data)
612 {
613 const char **excludes = NULL;
worktree.c
+1 -1
@@ -575,7 +575,7 @@ void strbuf_worktree_ref(const struct worktree *wt,
575 strbuf_addstr(sb, refname);
576 }
577
578 -int other_head_refs(each_ref_fn fn, void *cb_data)
578 +int other_head_refs(refs_for_each_cb fn, void *cb_data)
579 {
580 struct worktree **worktrees, **p;
581 struct strbuf refname = STRBUF_INIT;
worktree.h
+1 -1
@@ -191,7 +191,7 @@ int is_shared_symref(const struct worktree *wt,
191 * Similar to head_ref() for all HEADs _except_ one from the current
192 * worktree, which is covered by head_ref().
193 */
194 -int other_head_refs(each_ref_fn fn, void *cb_data);
194 +int other_head_refs(refs_for_each_cb fn, void *cb_data);
195
196 int is_worktree_being_rebased(const struct worktree *wt, const char *target);
197 int is_worktree_being_bisected(const struct worktree *wt, const char *target);