summaryrefslogtreecommitdiff
path: root/refs/ref-cache.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-10-23 09:16:11 +0200
committerJunio C Hamano <gitster@pobox.com>2025-11-04 07:32:25 -0800
commit89baa52da612dde6da031acfa2cb957d4297d544 (patch)
treec79c6db691180cd9992d572b8ed7c524e8e15178 /refs/ref-cache.c
parentbdbebe5714b25dc9d215b48efbb80f410925d7dd (diff)
refs: introduce `.ref` field for the base iterator
The base iterator has a couple of fields that tracks the name, target, object ID and flags for the current reference. Due to this design we have to create a new `struct reference` whenever we want to hand over that reference to the callback function, which is tedious and not very efficient. Convert the structure to instead contain a `struct reference` as member. This member is expected to be populated by the implementations of the iterator and is handed over to the callback directly. While at it, simplify `should_pack_ref()` to take a `struct reference` directly instead of passing its respective fields. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/ref-cache.c')
-rw-r--r--refs/ref-cache.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/refs/ref-cache.c b/refs/ref-cache.c
index e5e5df16d8..f1abc39624 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -425,10 +425,10 @@ static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator)
level->prefix_state = entry_prefix_state;
level->index = -1;
} else {
- iter->base.refname = entry->name;
- iter->base.referent = entry->u.value.referent;
- iter->base.oid = &entry->u.value.oid;
- iter->base.flags = entry->flag;
+ iter->base.ref.name = entry->name;
+ iter->base.ref.target = entry->u.value.referent;
+ iter->base.ref.oid = &entry->u.value.oid;
+ iter->base.ref.flags = entry->flag;
return ITER_OK;
}
}
@@ -550,7 +550,7 @@ static int cache_ref_iterator_peel(struct ref_iterator *ref_iterator,
{
struct cache_ref_iterator *iter =
(struct cache_ref_iterator *)ref_iterator;
- return peel_object(iter->repo, ref_iterator->oid, peeled) ? -1 : 0;
+ return peel_object(iter->repo, ref_iterator->ref.oid, peeled) ? -1 : 0;
}
static void cache_ref_iterator_release(struct ref_iterator *ref_iterator)