Subject: Re: [PATCH 09/17] odb/source: make `read_object_info()` function pluggable

From: Justin Tobler <[email-masked]>
Date: Wed, 4 Mar 2026 15:33:58 -0600

On 26/02/23 05:18PM, Patrick Steinhardt wrote:
> Introduce a new callback function in `struct odb_source` to make the
> function pluggable.
> 
> Note that this function is a bit less straight-forward to convert
> compared to the other functions. The reason here is that the logic to
> read an object is:
> 
>   1. We try to read the object. If it exists we return it.
> 
>   2. If the object does not exist we reprepare the object database
>      source.
> 
>   3. We then try reading the object info a second time in case the
>      reprepare caused it to appear.
> 
> The second read is only supposed to happen for the packfile store
> though, as reading loose objects is not impacted by repreparing the
> object database.
> 
> Ideally, we'd just move this whole logic into the ODB source. But that's
> not easily possible because we try to avoid the reprepare unless really
> required, which is after we have found out that no other ODB source
> contains the object, either. So the logic spans across multiple ODB
> sources, and consequently we cannot move it into an individual source.

Ok, I think gives a bit more context around one of my question in a
previous patch. So IIUC, when reading objects, that the object could
have been repacked and thus no longer discoverable from the current Git
process. We could just reprepare the ODB source immediately, but it
could be that the object exists in another ODB source so we should check
other sources first. Only if the object can't be found in other sources,
then we should attempt to reprepare the ODB sources in search of the
object.

> Instead, introduce a new flag `OBJECT_INFO_SECOND_READ` that tells the
> backend that we already tried to look up the object once, and that this
> time around the ODB source should try to find any new objects that may
> have surfaced due to an on-disk change.

Ok, now that the "files" ODB source combines the loose and packed
sources, we need a way to differentiate between first and second time
reads to void reading loose objects again. Makes sense.

-Justin