]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: rename `do_for_each_ref_flags`
authorPatrick Steinhardt <ps@pks.im>
Mon, 23 Feb 2026 11:59:38 +0000 (12:59 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Feb 2026 21:21:18 +0000 (13:21 -0800)
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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ref-filter.c
refs.c
refs.h
refs/files-backend.c
refs/packed-backend.c
refs/reftable-backend.c

index 3917c4ccd9f73ab80f4e37209ba788e767ba2d5a..4bc54ebd9d97ef6df02abd6788041eba80e8d1fc 100644 (file)
@@ -2810,7 +2810,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
        if (filter->kind & FILTER_REFS_ROOT_REFS) {
                /* In this case, we want to print all refs including root refs. */
                return for_each_fullref_with_seek(filter, cb, cb_data,
-                                                 DO_FOR_EACH_INCLUDE_ROOT_REFS);
+                                                 REFS_FOR_EACH_INCLUDE_ROOT_REFS);
        }
 
        if (!filter->match_as_path) {
diff --git a/refs.c b/refs.c
index 466398494f7e9c58714852b25c77010cce30aa67..52a680797a7ca77cd2574e14b220222a36f61692 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1812,7 +1812,7 @@ struct ref_iterator *refs_ref_iterator_begin(
                const char *prefix,
                const char **exclude_patterns,
                int trim,
-               enum do_for_each_ref_flags flags)
+               enum refs_for_each_flag flags)
 {
        struct ref_iterator *iter;
        struct strvec normalized_exclude_patterns = STRVEC_INIT;
@@ -1834,14 +1834,14 @@ struct ref_iterator *refs_ref_iterator_begin(
                exclude_patterns = normalized_exclude_patterns.v;
        }
 
-       if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
+       if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN)) {
                static int ref_paranoia = -1;
 
                if (ref_paranoia < 0)
                        ref_paranoia = git_env_bool("GIT_REF_PARANOIA", 1);
                if (ref_paranoia) {
-                       flags |= DO_FOR_EACH_INCLUDE_BROKEN;
-                       flags |= DO_FOR_EACH_OMIT_DANGLING_SYMREFS;
+                       flags |= REFS_FOR_EACH_INCLUDE_BROKEN;
+                       flags |= REFS_FOR_EACH_OMIT_DANGLING_SYMREFS;
                }
        }
 
@@ -1861,7 +1861,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,
-                          enum do_for_each_ref_flags flags, void *cb_data)
+                          enum refs_for_each_flag flags, void *cb_data)
 {
        struct ref_iterator *iter;
 
@@ -1897,7 +1897,7 @@ int refs_for_each_replace_ref(struct ref_store *refs, each_ref_fn fn, void *cb_d
        const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
        return do_for_each_ref(refs, git_replace_ref_base, NULL, fn,
                               strlen(git_replace_ref_base),
-                              DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
+                              REFS_FOR_EACH_INCLUDE_BROKEN, cb_data);
 }
 
 int refs_for_each_namespaced_ref(struct ref_store *refs,
@@ -1929,7 +1929,7 @@ int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix,
                            each_ref_fn fn, void *cb_data)
 {
        return do_for_each_ref(refs, prefix, NULL, fn, 0,
-                              DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
+                              REFS_FOR_EACH_INCLUDE_BROKEN, cb_data);
 }
 
 static int qsort_strcmp(const void *va, const void *vb)
@@ -2741,7 +2741,7 @@ enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs
 
                        if (!iter)
                                iter = refs_ref_iterator_begin(refs, dirname.buf, NULL, 0,
-                                                              DO_FOR_EACH_INCLUDE_BROKEN);
+                                                              REFS_FOR_EACH_INCLUDE_BROKEN);
                        else if (ref_iterator_seek(iter, dirname.buf,
                                                   REF_ITERATOR_SEEK_SET_PREFIX) < 0)
                                goto cleanup;
@@ -3281,7 +3281,7 @@ int repo_migrate_ref_storage_format(struct repository *repo,
         * ensure that there are no concurrent writes.
         */
        ret = do_for_each_ref(old_refs, "", NULL, migrate_one_ref, 0,
-                             DO_FOR_EACH_INCLUDE_ROOT_REFS | DO_FOR_EACH_INCLUDE_BROKEN,
+                             REFS_FOR_EACH_INCLUDE_ROOT_REFS | REFS_FOR_EACH_INCLUDE_BROKEN,
                              &data);
        if (ret < 0)
                goto done;
diff --git a/refs.h b/refs.h
index 6fd7a706b5bdaa8e86521fb4adabd1db540f3779..2ae4a6e75b74c4bc5953b283b85e77eede46e011 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -406,7 +406,7 @@ typedef int each_ref_fn(const struct reference *ref, void *cb_data);
  * These flags are passed to refs_ref_iterator_begin() (and do_for_each_ref(),
  * which feeds it).
  */
-enum do_for_each_ref_flags {
+enum refs_for_each_flag {
        /*
         * Include broken references in a do_for_each_ref*() iteration, which
         * would normally be omitted. This includes both refs that point to
@@ -416,7 +416,7 @@ enum do_for_each_ref_flags {
         * ref; this is not a corruption, but as they have no valid oid, we
         * omit them from normal iteration results).
         */
-       DO_FOR_EACH_INCLUDE_BROKEN = (1 << 0),
+       REFS_FOR_EACH_INCLUDE_BROKEN = (1 << 0),
 
        /*
         * Only include per-worktree refs in a do_for_each_ref*() iteration.
@@ -424,19 +424,19 @@ enum do_for_each_ref_flags {
         * where all reference backends will presumably store their
         * per-worktree refs.
         */
-       DO_FOR_EACH_PER_WORKTREE_ONLY = (1 << 1),
+       REFS_FOR_EACH_PER_WORKTREE_ONLY = (1 << 1),
 
        /*
         * Omit dangling symrefs from output; this only has an effect with
         * INCLUDE_BROKEN, since they are otherwise not included at all.
         */
-       DO_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 << 2),
+       REFS_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 << 2),
 
        /*
         * Include root refs i.e. HEAD and pseudorefs along with the regular
         * refs.
         */
-       DO_FOR_EACH_INCLUDE_ROOT_REFS = (1 << 3),
+       REFS_FOR_EACH_INCLUDE_ROOT_REFS = (1 << 3),
 };
 
 /*
@@ -1372,7 +1372,7 @@ struct ref_iterator;
 struct ref_iterator *refs_ref_iterator_begin(
        struct ref_store *refs,
        const char *prefix, const char **exclude_patterns,
-       int trim, enum do_for_each_ref_flags flags);
+       int trim, enum refs_for_each_flag flags);
 
 /*
  * Advance the iterator to the first or next item and return ITER_OK.
index b1b13b41f6c7d1a3e624734b2f0c8170dd6f85ca..6c98e14414197bb52c887b1e27e8511cdfb682f1 100644 (file)
@@ -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);
 
index 59b3ecb9d647161e4afc0fa90fa723a5805fdd43..5ef4ae32b83f37a38efb6509747ce47c8cda1a90 100644 (file)
@@ -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;
index 5611808ad75a8b19b857f68d67fe51f41bf5e894..34bc074dd37a9b20006ca8eeaea058171a3382cc 100644 (file)
@@ -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");