summaryrefslogtreecommitdiff
path: root/midx-write.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-10-23 09:16:14 +0200
committerJunio C Hamano <gitster@pobox.com>2025-11-04 07:32:25 -0800
commitf89866163704528f1a6570e134853dbb99120e7c (patch)
tree33c9d1c9526a5e644b4a12c8a27ee8c932e3b426 /midx-write.c
parenteb2934d94b43388642ce4840994800310a6d3456 (diff)
refs: expose peeled object ID via the iterator
Both the "files" and "reftable" backend are able to store peeled values for tags in the respective formats. This allows for a more efficient lookup of the target object of such a tag without having to manually peel via the object database. The infrastructure to access these peeled object IDs is somewhat funky though. When iterating through objects, we store a pointer reference to the current iterator in a global variable. The callbacks invoked by that iterator are then expected to call `peel_iterated_oid()`, which checks whether the globally-stored iterator's current reference refers to the one handed into that function. If so, we ask the iterator to peel the object, otherwise we manually peel the object via the object database. Depending on global state like this is somewhat weird and also quite fragile. Introduce a new `struct reference::peeled_oid` field that can be populated by the reference backends. This field can be accessed via a new function `reference_get_peeled_oid()` that either uses that value, if set, or alternatively peels via the ODB. With this change we don't have to rely on global state anymore, but make the peeled object ID available to the callback functions directly. Adjust trivial callers that already have a `struct reference` available. Remaining callers will be adjusted in subsequent commits. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'midx-write.c')
-rw-r--r--midx-write.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/midx-write.c b/midx-write.c
index f4dd875747..23e61cb000 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -709,7 +709,7 @@ static int add_ref_to_pending(const struct reference *ref, void *cb_data)
return 0;
}
- if (!peel_iterated_oid(revs->repo, ref->oid, &peeled))
+ if (!reference_get_peeled_oid(revs->repo, ref, &peeled))
maybe_peeled = &peeled;
object = parse_object_or_die(revs->repo, maybe_peeled, ref->name);