git/odb
Patrick Steinhardt 2135b14863 odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` generically
When a lookup with `OBJECT_INFO_DIE_IF_CORRUPT` fails we want to die in
case the object exists, but cannot be read. This flag is handled in two
different spots right now:

  - `do_oid_object_info_extended()` calls `has_packed_and_bad()` to
    check whether the object is known to be corrupt in any packfile.
    This function reaches into the internals of the packed source and
    thus breaks the abstraction provided by our object sources.

  - The loose source handles the flag itself and dies directly in
    `read_object_info_from_path()`, which means that we die even in
    cases where another source may still have a good copy of the
    object.

Besides being inconsistent, it also ties us to the specific backend used
by the database sources because `has_packed_and_bad()` assumes that they
use the "files" backend. Any other backend will instead cause us to die
when calling `odb_source_files_downcast()`, even if the object was
simply nonexistent.

In the preceding commits we've carved out the infrastructure to make
this mechanism fully generic. On the one hand, all backends now tell us
whether the object is missing or corrupt via their return values. And
on the other hand, they have been taught to provide a readable error
message to the caller.

Adapt `do_oid_object_info_extended()` to use those new mechanisms. This
means that we won't die immediately anymore when a loose object is
corrupt, and we properly handle backends other than the "files" backend.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-19 10:23:02 -07:00
..
source-files.c odb/source: allow `read_object_info()` to bubble up error messages 2026-08-19 10:23:02 -07:00
source-files.h odb: make optimizations pluggable 2026-07-13 08:13:17 -07:00
source-inmemory.c odb/source: allow `read_object_info()` to bubble up error messages 2026-08-19 10:23:02 -07:00
source-inmemory.h odb/source-inmemory: convert to use oidtree 2026-05-15 04:50:45 +09:00
source-loose.c odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` generically 2026-08-19 10:23:02 -07:00
source-loose.h odb/source-loose: drop pointer to the "files" source 2026-06-01 18:47:19 +09:00
source-packed.c odb/source: allow `read_object_info()` to bubble up error messages 2026-08-19 10:23:02 -07:00
source-packed.h Merge branch 'ps/odb-generalize-prepare' 2026-07-13 08:27:28 -07:00
source.c odb/source: make `free()` function pluggable 2026-03-05 11:45:15 -08:00
source.h odb/source: allow `read_object_info()` to bubble up error messages 2026-08-19 10:23:02 -07:00
streaming.c odb: use size_t for object_info.sizep and the size APIs 2026-06-15 07:45:41 -07:00
streaming.h Merge branch 'ps/odb-in-memory' into ps/odb-source-loose 2026-05-21 22:34:55 +09:00
transaction.c odb/transaction: introduce ODB transaction flags 2026-07-10 13:21:53 -07:00
transaction.h odb/transaction: introduce ODB transaction flags 2026-07-10 13:21:53 -07:00