Subject: Re: [PATCH 05/17] odb/source: introduce source type for robustness

From: Patrick Steinhardt <[email-masked]>
Date: Thu, 5 Mar 2026 14:07:34 +0100

On Wed, Mar 04, 2026 at 02:46:38PM -0600, Justin Tobler wrote:
> 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.

> > 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