Re: [PATCH 05/17] odb/source: introduce source type for robustness
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Mar 5, 2026, 13:07 UTC
- Message-ID
- <aamAFv0kEU-plSE_@pks.im>
- In-Reply-To
- <aaiZTjrK2oHpqmVQ@denethor>
On Wed, Mar 04, 2026 at 02:46:38PM -0600, Justin Tobler wrote:
Show 10 quoted lines
> On 26/02/23 05:17PM, Patrick Steinhardt wrote: > > When a caller holds a `struct odb_source`, they have no way of telling > > what type the source is. This doesn't really cause any problems in the > > current status quo as we only have a single type anyway, "files". But > > going forward we expect to add more types, and if so it will become > > necessary to tell the sources apart. > > In this patch, it looks like are only using the ODB source "type" to > know to properly BUG() out when downcasting. Do we anticipate other uses > here?
Yup. There are sites in Git that simply need to know the type of the source because of functionality that is deeply entangled with the files backend. And in such cases we'll have to determine the type of a specific ODB source so that we can act accordingly.
The number of such callsites should be low, and they should decrease over time. But some simply won't go away.
Show 5 quoted lines
> > Introduce a new enum to cover this use case and assert that the given > > source actually matches the target source when performing the downcast. > > Does these mean all future source types would be required to have their > own enum value defined?
Yes. In an integration branch I have four different backends: "files", "loose", "packed" and "inmemory".
Patrick