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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Feb 23, 2026 at 12:59 UTC
8f0720a5a781562fb1f750b351e14129fc8930ea
6 files changed
+31
-31
ref-filter.c
+1
-1
@@ -2810,7 +2810,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
2810
if (filter->kind & FILTER_REFS_ROOT_REFS) {
2811
/* In this case, we want to print all refs including root refs. */
2812
return for_each_fullref_with_seek(filter, cb, cb_data,
2813
- DO_FOR_EACH_INCLUDE_ROOT_REFS);
2813
+ REFS_FOR_EACH_INCLUDE_ROOT_REFS);
2814
}
2815
2816
if (!filter->match_as_path) {
refs.c
+9
-9
@@ -1812,7 +1812,7 @@ struct ref_iterator *refs_ref_iterator_begin(
1812
const char *prefix,
1813
const char **exclude_patterns,
1814
int trim,
1815
- enum do_for_each_ref_flags flags)
1815
+ enum refs_for_each_flag flags)
1816
{
1817
struct ref_iterator *iter;
1818
struct strvec normalized_exclude_patterns = STRVEC_INIT;
@@ -1834,14 +1834,14 @@ struct ref_iterator *refs_ref_iterator_begin(
1834
exclude_patterns = normalized_exclude_patterns.v;
1835
}
1836
1837
- if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
1837
+ if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN)) {
1838
static int ref_paranoia = -1;
1839
1840
if (ref_paranoia < 0)
1841
ref_paranoia = git_env_bool("GIT_REF_PARANOIA", 1);
1842
if (ref_paranoia) {
1843
- flags |= DO_FOR_EACH_INCLUDE_BROKEN;
1844
- flags |= DO_FOR_EACH_OMIT_DANGLING_SYMREFS;
1843
+ flags |= REFS_FOR_EACH_INCLUDE_BROKEN;
1844
+ flags |= REFS_FOR_EACH_OMIT_DANGLING_SYMREFS;
1845
}
1846
}
1847
@@ -1861,7 +1861,7 @@ struct ref_iterator *refs_ref_iterator_begin(
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,
1864
- enum do_for_each_ref_flags flags, void *cb_data)
1864
+ enum refs_for_each_flag flags, void *cb_data)
1865
{
1866
struct ref_iterator *iter;
1867
@@ -1897,7 +1897,7 @@ int refs_for_each_replace_ref(struct ref_store *refs, each_ref_fn fn, void *cb_d
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,
1899
strlen(git_replace_ref_base),
1900
- DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
1900
+ REFS_FOR_EACH_INCLUDE_BROKEN, cb_data);
1901
}
1902
1903
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,
1929
each_ref_fn fn, void *cb_data)
1930
{
1931
return do_for_each_ref(refs, prefix, NULL, fn, 0,
1932
- DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
1932
+ REFS_FOR_EACH_INCLUDE_BROKEN, cb_data);
1933
}
1934
1935
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
2741
2742
if (!iter)
2743
iter = refs_ref_iterator_begin(refs, dirname.buf, NULL, 0,
2744
- DO_FOR_EACH_INCLUDE_BROKEN);
2744
+ REFS_FOR_EACH_INCLUDE_BROKEN);
2745
else if (ref_iterator_seek(iter, dirname.buf,
2746
REF_ITERATOR_SEEK_SET_PREFIX) < 0)
2747
goto cleanup;
@@ -3281,7 +3281,7 @@ int repo_migrate_ref_storage_format(struct repository *repo,
3281
* ensure that there are no concurrent writes.
3282
*/
3283
ret = do_for_each_ref(old_refs, "", NULL, migrate_one_ref, 0,
3284
- DO_FOR_EACH_INCLUDE_ROOT_REFS | DO_FOR_EACH_INCLUDE_BROKEN,
3284
+ REFS_FOR_EACH_INCLUDE_ROOT_REFS | REFS_FOR_EACH_INCLUDE_BROKEN,
3285
&data);
3286
if (ret < 0)
3287
goto done;
refs.h
+6
-6
@@ -406,7 +406,7 @@ typedef int each_ref_fn(const struct reference *ref, void *cb_data);
406
* These flags are passed to refs_ref_iterator_begin() (and do_for_each_ref(),
407
* which feeds it).
408
*/
409
-enum do_for_each_ref_flags {
409
+enum refs_for_each_flag {
410
/*
411
* Include broken references in a do_for_each_ref*() iteration, which
412
* would normally be omitted. This includes both refs that point to
@@ -416,7 +416,7 @@ enum do_for_each_ref_flags {
416
* ref; this is not a corruption, but as they have no valid oid, we
417
* omit them from normal iteration results).
418
*/
419
- DO_FOR_EACH_INCLUDE_BROKEN = (1 << 0),
419
+ REFS_FOR_EACH_INCLUDE_BROKEN = (1 << 0),
420
421
/*
422
* Only include per-worktree refs in a do_for_each_ref*() iteration.
@@ -424,19 +424,19 @@ enum do_for_each_ref_flags {
424
* where all reference backends will presumably store their
425
* per-worktree refs.
426
*/
427
- DO_FOR_EACH_PER_WORKTREE_ONLY = (1 << 1),
427
+ REFS_FOR_EACH_PER_WORKTREE_ONLY = (1 << 1),
428
429
/*
430
* Omit dangling symrefs from output; this only has an effect with
431
* INCLUDE_BROKEN, since they are otherwise not included at all.
432
*/
433
- DO_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 << 2),
433
+ REFS_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 << 2),
434
435
/*
436
* Include root refs i.e. HEAD and pseudorefs along with the regular
437
* refs.
438
*/
439
- DO_FOR_EACH_INCLUDE_ROOT_REFS = (1 << 3),
439
+ REFS_FOR_EACH_INCLUDE_ROOT_REFS = (1 << 3),
440
};
441
442
/*
@@ -1372,7 +1372,7 @@ struct ref_iterator;
1372
struct ref_iterator *refs_ref_iterator_begin(
1373
struct ref_store *refs,
1374
const char *prefix, const char **exclude_patterns,
1375
- int trim, enum do_for_each_ref_flags flags);
1375
+ int trim, enum refs_for_each_flag flags);
1376
1377
/*
1378
* Advance the iterator to the first or next item and return ITER_OK.
refs/files-backend.c
+6
-6
@@ -439,7 +439,7 @@ static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs,
439
440
dir = get_ref_dir(refs->loose->root);
441
442
- if (flags & DO_FOR_EACH_INCLUDE_ROOT_REFS)
442
+ if (flags & REFS_FOR_EACH_INCLUDE_ROOT_REFS)
443
add_root_refs(refs, dir);
444
445
/*
@@ -955,17 +955,17 @@ static int files_ref_iterator_advance(struct ref_iterator *ref_iterator)
955
int ok;
956
957
while ((ok = ref_iterator_advance(iter->iter0)) == ITER_OK) {
958
- if (iter->flags & DO_FOR_EACH_PER_WORKTREE_ONLY &&
958
+ if (iter->flags & REFS_FOR_EACH_PER_WORKTREE_ONLY &&
959
parse_worktree_ref(iter->iter0->ref.name, NULL, NULL,
960
NULL) != REF_WORKTREE_CURRENT)
961
continue;
962
963
- if ((iter->flags & DO_FOR_EACH_OMIT_DANGLING_SYMREFS) &&
963
+ if ((iter->flags & REFS_FOR_EACH_OMIT_DANGLING_SYMREFS) &&
964
(iter->iter0->ref.flags & REF_ISSYMREF) &&
965
(iter->iter0->ref.flags & REF_ISBROKEN))
966
continue;
967
968
- if (!(iter->flags & DO_FOR_EACH_INCLUDE_BROKEN) &&
968
+ if (!(iter->flags & REFS_FOR_EACH_INCLUDE_BROKEN) &&
969
!ref_resolves_to_object(iter->iter0->ref.name,
970
iter->repo,
971
iter->iter0->ref.oid,
@@ -1012,7 +1012,7 @@ static struct ref_iterator *files_ref_iterator_begin(
1012
struct ref_iterator *ref_iterator;
1013
unsigned int required_flags = REF_STORE_READ;
1014
1015
- if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN))
1015
+ if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN))
1016
required_flags |= REF_STORE_ODB;
1017
1018
refs = files_downcast(ref_store, required_flags, "ref_iterator_begin");
@@ -1050,7 +1050,7 @@ static struct ref_iterator *files_ref_iterator_begin(
1050
*/
1051
packed_iter = refs_ref_iterator_begin(
1052
refs->packed_ref_store, prefix, exclude_patterns, 0,
1053
- DO_FOR_EACH_INCLUDE_BROKEN);
1053
+ REFS_FOR_EACH_INCLUDE_BROKEN);
1054
1055
overlay_iter = overlay_ref_iterator_begin(loose_iter, packed_iter);
1056
refs/packed-backend.c
+4
-4
@@ -982,11 +982,11 @@ static int packed_ref_iterator_advance(struct ref_iterator *ref_iterator)
982
const char *refname = iter->base.ref.name;
983
const char *prefix = iter->prefix;
984
985
- if (iter->flags & DO_FOR_EACH_PER_WORKTREE_ONLY &&
985
+ if (iter->flags & REFS_FOR_EACH_PER_WORKTREE_ONLY &&
986
!is_per_worktree_ref(iter->base.ref.name))
987
continue;
988
989
- if (!(iter->flags & DO_FOR_EACH_INCLUDE_BROKEN) &&
989
+ if (!(iter->flags & REFS_FOR_EACH_INCLUDE_BROKEN) &&
990
!ref_resolves_to_object(iter->base.ref.name, iter->repo,
991
&iter->oid, iter->flags))
992
continue;
@@ -1159,7 +1159,7 @@ static struct ref_iterator *packed_ref_iterator_begin(
1159
struct ref_iterator *ref_iterator;
1160
unsigned int required_flags = REF_STORE_READ;
1161
1162
- if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN))
1162
+ if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN))
1163
required_flags |= REF_STORE_ODB;
1164
refs = packed_downcast(ref_store, required_flags, "ref_iterator_begin");
1165
@@ -1401,7 +1401,7 @@ static enum ref_transaction_error write_with_updates(struct packed_ref_store *re
1401
* of updates is exhausted, leave i set to updates->nr.
1402
*/
1403
iter = packed_ref_iterator_begin(&refs->base, "", NULL,
1404
- DO_FOR_EACH_INCLUDE_BROKEN);
1404
+ REFS_FOR_EACH_INCLUDE_BROKEN);
1405
if ((ok = ref_iterator_advance(iter)) != ITER_OK) {
1406
ref_iterator_free(iter);
1407
iter = NULL;
refs/reftable-backend.c
+5
-5
@@ -662,7 +662,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator)
662
* the root refs are to be included. We emulate the same behaviour here.
663
*/
664
if (!starts_with(iter->ref.refname, "refs/") &&
665
- !(iter->flags & DO_FOR_EACH_INCLUDE_ROOT_REFS &&
665
+ !(iter->flags & REFS_FOR_EACH_INCLUDE_ROOT_REFS &&
666
is_root_ref(iter->ref.refname))) {
667
continue;
668
}
@@ -676,7 +676,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator)
676
if (iter->exclude_patterns && should_exclude_current_ref(iter))
677
continue;
678
679
- if (iter->flags & DO_FOR_EACH_PER_WORKTREE_ONLY &&
679
+ if (iter->flags & REFS_FOR_EACH_PER_WORKTREE_ONLY &&
680
parse_worktree_ref(iter->ref.refname, NULL, NULL, NULL) !=
681
REF_WORKTREE_CURRENT)
682
continue;
@@ -714,12 +714,12 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator)
714
flags |= REF_BAD_NAME | REF_ISBROKEN;
715
}
716
717
- if (iter->flags & DO_FOR_EACH_OMIT_DANGLING_SYMREFS &&
717
+ if (iter->flags & REFS_FOR_EACH_OMIT_DANGLING_SYMREFS &&
718
flags & REF_ISSYMREF &&
719
flags & REF_ISBROKEN)
720
continue;
721
722
- if (!(iter->flags & DO_FOR_EACH_INCLUDE_BROKEN) &&
722
+ if (!(iter->flags & REFS_FOR_EACH_INCLUDE_BROKEN) &&
723
!ref_resolves_to_object(iter->ref.refname, refs->base.repo,
724
&iter->oid, flags))
725
continue;
@@ -871,7 +871,7 @@ static struct ref_iterator *reftable_be_iterator_begin(struct ref_store *ref_sto
871
struct reftable_ref_store *refs;
872
unsigned int required_flags = REF_STORE_READ;
873
874
- if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN))
874
+ if (!(flags & REFS_FOR_EACH_INCLUDE_BROKEN))
875
required_flags |= REF_STORE_ODB;
876
refs = reftable_be_downcast(ref_store, required_flags, "ref_iterator_begin");
877