]> git.99rst.org Git - git.git/commit
odb: make backend-specific fields optional
authorPatrick Steinhardt <redacted>
Thu, 2 Jul 2026 12:02:00 +0000 (14:02 +0200)
committerJunio C Hamano <redacted>
Thu, 2 Jul 2026 16:52:32 +0000 (09:52 -0700)
commit126076b62f5164f9da6bbe454fc71c164ea5cb42
treed71c6366130b5a211ed57be2ed66e7274e2c3901
parent11c689b8730e0927ef9fc73eea59270318b3177d
odb: make backend-specific fields optional

The `struct object_info` carries two pieces of information
about how an object was looked up:

  - The `whence` enum identifying the backend.

  - The backend-tagged union `u` exposing backend-specific details
    (currently only the packed-source case, which records the owning
    pack, offset and packed object type).

The union is populated unconditionally, even though most callers don't
care about provenance at all.

Split the backend-specific union out into a new public type, `struct
object_info_source`, and make the object info structure carry it via
just another opt-in request pointer. As with all the other requestable
information, callers that need source info allocate a `struct
object_info_source` on the stack and point `sourcep` at it; callers that
don't care about it simply leave the field as a `NULL` pointer. Adapt
callers accordingly.

Note that the `whence` enum is strictly-speaking also backend-specific
information, so it would be another good candidate to be moved into the
`struct object_info_source`. For now though it is left alone, as it will
be replaced by a `struct odb_source` pointer in a subsequent commit.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
builtin/cat-file.c
builtin/index-pack.c
builtin/pack-objects.c
odb.c
odb.h
packfile.c
reachable.c
git clone https://git.99rst.org/PROJECT