From cfd971520ed11096aaa11f6bd1ee99b307f3146c Mon Sep 17 00:00:00 2001 From: John Cai Date: Fri, 9 Aug 2024 15:37:49 +0000 Subject: refs: keep track of unresolved reference value in iterators Since ref iterators do not hold onto the direct value of a reference without resolving it, the only way to get ahold of a direct value of a symbolic ref is to make a separate call to refs_read_symbolic_ref. To make accessing the direct value of a symbolic ref more efficient, let's save the direct value of the ref in the iterators for both the files backend and the reftable backend. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- refs/iterator.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'refs/iterator.c') diff --git a/refs/iterator.c b/refs/iterator.c index d355ebf0d5..75fbe5d72a 100644 --- a/refs/iterator.c +++ b/refs/iterator.c @@ -29,6 +29,7 @@ void base_ref_iterator_init(struct ref_iterator *iter, { iter->vtable = vtable; iter->refname = NULL; + iter->referent = NULL; iter->oid = NULL; iter->flags = 0; } @@ -199,6 +200,7 @@ static int merge_ref_iterator_advance(struct ref_iterator *ref_iterator) } if (selection & ITER_YIELD_CURRENT) { + iter->base.referent = (*iter->current)->referent; iter->base.refname = (*iter->current)->refname; iter->base.oid = (*iter->current)->oid; iter->base.flags = (*iter->current)->flags; -- cgit v1.2.3