Re: [PATCH 2/8] odb: resolve relative alternative paths when parsing
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Dec 9, 2025, 18:06 UTC
- Message-ID
- <5lkaw3kfqzjt45jhomeb34cqu6nxigapmobtqrzpyoq7mh6655@3zgqsyfui23j>
- In-Reply-To
- <aTfYBGr-0SIDinYF@pks.im>
On 25/12/09 09:04AM, Patrick Steinhardt wrote:
Show 22 quoted lines
> On Mon, Dec 08, 2025 at 08:09:30PM -0600, Justin Tobler wrote: > > On 25/12/08 09:04AM, Patrick Steinhardt wrote: > > > Parsing alternates and resolving potential relative paths is currently > > > handled in two separate steps. This has the effect that the logic to > > > retrieve alternates is not entirely self-contained. We want it to be > > > just that though so that we can eventually move the logic to list > > > alternates into the `struct odb_source`. > > > > Naive question: is the intent here to eventually move alternate ODB > > sources under the primary ODB source? Or just to record the alternate > > dir info in the ODB source? > > Not only the primary ODB source, but into ODB sources in general as > alternates are recursive by nature. > > The problem I am trying to solve is that ODB sources may not even have a > filesystem-local directory, but the way we use alternates recursively > very much assumes they do. I don't want to treat "files" sources > specially though and only recursively add their alternates. Instead, I > want to move the logic of enumerating alternates into the source so that > every source can have a different way of enumerating them that may or > may not use the filesystem.
Ah, that makes more sense now. Thanks for the explaination. :)
Show 20 quoted lines
> > > Move the logic to resolve relative alternative paths into > > > `parse_alternates()`. Besides bringing us a step closer towards the > > > above goal, it also neatly separates concerns of generating the list of > > > alternatives and linking them into the object database. > > > > > > Note that we ignore any errors when the relative path cannot be > > > resolved. This isn't really a change in behaviour though: if the path > > > cannot be resolved to a directory then `alt_odb_usable()` still knows to > > > bail out. > > > > > > While at it, rename the function to `odb_add_source()` to more clearly > > > indicate what its intent is and to align it with modern terminology. > > > > Alternates are indeed just additional ODB sources appended to the > > sources list. IIUC though, doesn't this function only add alternate > > sources? If so, maybe it would be better to use > > `odb_add_alternate_source()`? > > Hm, yeah, I think you're right. We still have the recursive nature at > the end of this series, so let's call it accordingly.
On a semi-related note, part of me thinks it would be nice if alternate sources were a bit more first class in `struct object_database`. IOW, explicitly defining the primary and list of alternate sources separately. From the perspective of reading objects, having a single list of sources is nice, but when writing objects only the first source is used. This isn't too big of a deal, but certain operations like ODB trasactions will reorder the source list to change where objects get written to which feels a bit fragile to me. I guess another way to resolve this concern could be to change ODB transactions to use a separate mechanism though.
-Justin