Re: [PATCH v2 07/17] odb/source-packed: wire up `reprepare()` callback
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Jun 16, 2026, 21:53 UTC
- Message-ID
- <ajHDm_pG3Ckca4mp@denethor>
- In-Reply-To
- <20260609-pks-odb-source-packed-v2-7-839089132c8b@pks.im>
On 26/06/09 10:51AM, Patrick Steinhardt wrote:
Show 7 quoted lines
> Move the logic to prepare and reprepare the "packed" source into > "odb/source-packed.c" and wire it up as the `reprepare()` callback. > > Note that "preparing" a source is not yet generic. Eventually, it would > probably make sense to turn the existing `reprepare()` callback into a > `prepare()` callback with an optional flag to force re-preparing. But > this step will be handled in a separate patch series.
I do find the prepare vs reprepare semantics a bit confusing. The mentioned change above would be nice to see in the future. :)
> Signed-off-by: Patrick Steinhardt <ps@pks.im> > ---
[snip]
Show 8 quoted lines
> static void odb_source_packed_reparent(const char *name UNUSED, > const char *old_cwd, > const char *new_cwd, > @@ -58,6 +214,7 @@ struct odb_source_packed *odb_source_packed_new(struct odb_source_files *parent) > > packed->base.free = odb_source_packed_free; > packed->base.close = odb_source_packed_close; > + packed->base.reprepare = odb_source_packed_reprepare;
We moved `packfile_store_reprepare()` logic into "odb/source-packed.c" and setup the callback making it accessible via `odb_source_reprepare()` instead. Makes sense.
Show 18 quoted lines
> if (!is_absolute_path(parent->base.path)) > chdir_notify_register(NULL, odb_source_packed_reparent, packed); > diff --git a/odb/source-packed.h b/odb/source-packed.h > index 68e64cabab..9d4796261a 100644 > --- a/odb/source-packed.h > +++ b/odb/source-packed.h > @@ -81,4 +81,13 @@ static inline struct odb_source_packed *odb_source_packed_downcast(struct odb_so > return container_of(source, struct odb_source_packed, base); > } > > +/* > + * Prepare the source by loading packfiles and multi-pack indices for > + * all alternates. This becomes a no-op if the source is already prepared. > + * > + * It shouldn't typically be necessary to call this function directly, as > + * functions that access the source know to prepare it. > + */ > +void odb_source_packed_prepare(struct odb_source_packed *source);
The logic for `packfile_store_prepare()` is also moved into "odb/source-packed.c" and made accessible this function since there isn't a matching callback.
The other changes are mostly 1:1 moves of associated logic and callsite updates. Looks good.
-Justin