]> git.ipfire.org Git - thirdparty/git.git/commit
odb: lift object existence check out of the "loose" backend
authorPatrick Steinhardt <ps@pks.im>
Fri, 17 Jul 2026 09:32:12 +0000 (11:32 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 Jul 2026 02:03:48 +0000 (19:03 -0700)
commitb688086b8fd56e1bbab36e6bb26e12844e6e6965
tree512c4a24633c14f1191a1be9954863af7dcfa328
parent46a586a7199a78d2280ddb22368378693541fff0
odb: lift object existence check out of the "loose" backend

Before writing a new loose object we first check whether the object
already exists in any of the sources attached to the object database.
This results in a couple of issues:

  - We have a layering violation, where the source needs to be aware of
    objects stored in any of the other sources.

  - Every backend would have to reimplement this check, which feels
    somewhat pointless.

  - It is not possible to easily write an object into a source in case
    the same object already exists in another source.

Refactor the code and lift up the object existence check from the
"loose" backend into the generic ODB layer. No callers need adjustment
as none of them write via a specific source, but via the ODB layer.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb.c
odb/source-loose.c