]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: rename `each_ref_fn`
authorPatrick Steinhardt <ps@pks.im>
Mon, 23 Feb 2026 11:59:39 +0000 (12:59 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Feb 2026 21:21:18 +0000 (13:21 -0800)
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>
pack-bitmap.c
pack-bitmap.h
ref-filter.c
refs.c
refs.h
refs/iterator.c
revision.c
submodule.c
upload-pack.c
worktree.c
worktree.h

index 1c93871484a24f56c1b9f31ecf802fe6509fdd52..efef7081e6a00444ee53f8e9b0d8ecc9a27b7749 100644 (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;
index d0611d0481301014b805c1c1c714a06e4036ac87..a95e1c2d115a31d45473758852806c3a1186b9a8 100644 (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"
index 4bc54ebd9d97ef6df02abd6788041eba80e8d1fc..049e845a1909fe075a59ec36aeea881ed5d0e6d1 100644 (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;
diff --git a/refs.c b/refs.c
index 52a680797a7ca77cd2574e14b220222a36f61692..a45cc612111840d63145ba32f11c509b4fe1981b 100644 (file)
--- 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 2ae4a6e75b74c4bc5953b283b85e77eede46e011..5190e98b2c6e1d3437fb2e6aa6ec359390d43df1 100644 (file)
--- 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 */
index d79aa5ec82dc6fa0e129247533056e81d10d8b35..d5cacde51bf87ac15ff1a41a0d3868ade2af32c8 100644 (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;
 
index 29972c3a19887ad1e002914cb4529c19e5f6b4fe..8c206830d5e4a6fc208e70ba73923a73fcf4ffba 100644 (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);
 }
index 508938e4da505854a293d4d5ced13997024295a8..4f9aaa2c75679b8420bd2e16f98ab4976ffbf344 100644 (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),
index 2d2b70cbf2dd0b57bbdbf50031a44fe4b148778f..7fe397b0d09bb3f2ac34b880d263c5eb1807ae36 100644 (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;
index 9308389cb6f0296b1cc21c33b95427211f840649..bf8c54c04d530dd7c6774932a20ad484f7346b70 100644 (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;
index e4bcccdc0aef5acdda732a0e24da667f7b2f99b7..12484a91a7f835bb31b34d15c4b6f38531a49c83 100644 (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);