From: Patrick Steinhardt Date: Thu, 05 Mar 2026 13:23:25 GMT Subject: Re: [PATCH 03/17] odb: embed base source in the "files" backend Message-ID: In-Reply-To: On Thu, Mar 05, 2026 at 10:45:07AM +0000, Karthik Nayak wrote: > Patrick Steinhardt writes: > > Refactor our "files" object database source to do the same and embed the > > `struct odb_source` in the `struct odb_source_files`. > > > > There are still a bunch of sites in our code base where we do have to > > access internals of the "files" backend. The intent is that those will > > go away over time, but this will certainly take a while. Meanwhile, > > provide a `odb_source_files_downcast()` function that can convert a > > generic source into a "files" source. > > > > As we only have a single source the downcast succeeds unconditionally > > for now. Eventually though the intent is to make the cast `BUG()` in > > case the caller requests to downcast a non-"files" backend to a "files" > > backend. > > > > Do we also plan to add read/write permissions check within the downcast > logic? Similar to the refs DB? Doesn't have to be in this patch, just > curious if that is something we plan to include. I didn't plan to. I guess we could have such a check eventually though to for example keep somebody from writing to secondary ODB sources. I don't have anything cooking here though. > > diff --git a/odb/source.c b/odb/source.c > > index 9d7fd19f45..d8b2176a94 100644 > > --- a/odb/source.c > > +++ b/odb/source.c > > @@ -1,5 +1,6 @@ > > #include "git-compat-util.h" > > #include "object-file.h" > > +#include "odb/source-files.h" > > #include "odb/source.h" > > #include "packfile.h" > > > > @@ -7,20 +8,31 @@ struct odb_source *odb_source_new(struct object_database *odb, > > const char *path, > > bool local) > > { > > - struct odb_source *source; > > + return &odb_source_files_new(odb, path, local)->base; > > +} > > > > Since we only have one source right now (files), we directly call the > internals of that source, I guess once we add more this would be more > modular. Yeah. This will eventually be handled via a new object storage extension, similar to how we do this for the reference backends. Patrick