refs: replace `refs_for_each_rawref()`
Replace calls to `refs_for_each_rawref()` with the newly introduced `refs_for_each_ref_ext()` function. 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
67034081adc956c4dc8b51f59a9b70b8861c4642
6 files changed
+30
-17
builtin/describe.c
+5
-2
@@ -641,6 +641,9 @@ int cmd_describe(int argc,
641
const char *prefix,
642
struct repository *repo UNUSED )
643
{
644
+ struct refs_for_each_ref_options for_each_ref_opts = {
645
+ .flags = REFS_FOR_EACH_INCLUDE_BROKEN,
646
+ };
647
int contains = 0;
648
struct option options[] = {
649
OPT_BOOL(0, "contains", &contains, N_("find the tag that comes after the commit")),
@@ -738,8 +741,8 @@ int cmd_describe(int argc,
741
}
742
743
hashmap_init(&names, commit_name_neq, NULL, 0);
741
- refs_for_each_rawref(get_main_ref_store(the_repository), get_name,
742
- NULL);
744
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
745
+ get_name, NULL, &for_each_ref_opts);
746
if (!hashmap_get_size(&names) && !always)
747
die(_("No names found, cannot describe anything."));
748
builtin/fsck.c
+5
-2
@@ -598,6 +598,9 @@ static int fsck_handle_ref(const struct reference *ref, void *cb_data UNUSED)
598
599
static void snapshot_refs(struct snapshot *snap, int argc, const char **argv)
600
{
601
+ struct refs_for_each_ref_options opts = {
602
+ .flags = REFS_FOR_EACH_INCLUDE_BROKEN,
603
+ };
604
struct worktree **worktrees, **p;
605
const char *head_points_at;
606
struct object_id head_oid;
@@ -623,8 +626,8 @@ static void snapshot_refs(struct snapshot *snap, int argc, const char **argv)
626
return;
627
}
628
626
- refs_for_each_rawref(get_main_ref_store(the_repository),
627
- snapshot_ref, snap);
629
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
630
+ snapshot_ref, snap, &opts);
631
632
worktrees = get_worktrees();
633
for (p = worktrees; *p; p++) {
fetch-pack.c
+11
-4
@@ -292,11 +292,14 @@ static int next_flush(int stateless_rpc, int count)
292
static void mark_tips(struct fetch_negotiator *negotiator,
293
const struct oid_array *negotiation_tips)
294
{
295
+ struct refs_for_each_ref_options opts = {
296
+ .flags = REFS_FOR_EACH_INCLUDE_BROKEN,
297
+ };
298
int i;
299
300
if (!negotiation_tips) {
298
- refs_for_each_rawref(get_main_ref_store(the_repository),
299
- rev_list_insert_ref_oid, negotiator);
301
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
302
+ rev_list_insert_ref_oid, negotiator, &opts);
303
return;
304
}
305
@@ -792,8 +795,12 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
795
*/
796
trace2_region_enter("fetch-pack", "mark_complete_local_refs", NULL);
797
if (!args->deepen) {
795
- refs_for_each_rawref(get_main_ref_store(the_repository),
796
- mark_complete_oid, NULL);
798
+ struct refs_for_each_ref_options opts = {
799
+ .flags = REFS_FOR_EACH_INCLUDE_BROKEN,
800
+ };
801
+
802
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
803
+ mark_complete_oid, NULL, &opts);
804
for_each_cached_alternate(NULL, mark_alternate_complete);
805
if (cutoff)
806
mark_recent_complete_commits(args, cutoff);
refs.c
+4
-6
@@ -526,7 +526,10 @@ void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp,
526
.indent = indent,
527
.dry_run = dry_run,
528
};
529
- refs_for_each_rawref(refs, warn_if_dangling_symref, &data);
529
+ struct refs_for_each_ref_options opts = {
530
+ .flags = REFS_FOR_EACH_INCLUDE_BROKEN,
531
+ };
532
+ refs_for_each_ref_ext(refs, warn_if_dangling_symref, &data, &opts);
533
}
534
535
int refs_for_each_tag_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data)
@@ -1979,11 +1982,6 @@ int refs_for_each_namespaced_ref(struct ref_store *refs,
1982
return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
1983
}
1984
1982
-int refs_for_each_rawref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
1983
-{
1984
- return refs_for_each_rawref_in(refs, "", fn, cb_data);
1985
-}
1986
-
1985
int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix,
1986
refs_for_each_cb cb, void *cb_data)
1987
{
refs.h
-1
@@ -543,7 +543,6 @@ int refs_for_each_namespaced_ref(struct ref_store *refs,
543
refs_for_each_cb fn, void *cb_data);
544
545
/* can be used to learn about broken ref and symref */
546
-int refs_for_each_rawref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data);
546
int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix,
547
refs_for_each_cb fn, void *cb_data);
548
refs/files-backend.c
+5
-2
@@ -3149,6 +3149,9 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
3149
struct ref_transaction *transaction,
3150
struct strbuf *err)
3151
{
3152
+ struct refs_for_each_ref_options opts = {
3153
+ .flags = REFS_FOR_EACH_INCLUDE_BROKEN,
3154
+ };
3155
size_t i;
3156
int ret = 0;
3157
struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
@@ -3173,8 +3176,8 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
3176
* so here we really only check that none of the references
3177
* that we are creating already exists.
3178
*/
3176
- if (refs_for_each_rawref(&refs->base, ref_present,
3177
- &transaction->refnames))
3179
+ if (refs_for_each_ref_ext(&refs->base, ref_present,
3180
+ &transaction->refnames, &opts))
3181
BUG("initial ref transaction called with existing refs");
3182
3183
packed_transaction = ref_store_transaction_begin(refs->packed_ref_store,