Subject: Re: [PATCH 01/10] packfile: create store via its owning source

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 16 Dec 2025 09:36:05 +0100

On Mon, Dec 15, 2025 at 03:30:44PM -0600, Justin Tobler wrote:
> On 25/12/15 08:36AM, Patrick Steinhardt wrote:
> > diff --git a/packfile.c b/packfile.c
> > index c88bd92619..0a05a10daa 100644
> > --- a/packfile.c
> > +++ b/packfile.c
> > @@ -876,7 +876,7 @@ struct packed_git *packfile_store_load_pack(struct packfile_store *store,
> >  
> >  	p = strmap_get(&store->packs_by_path, key.buf);
> >  	if (!p) {
> > -		p = add_packed_git(store->odb->repo, idx_path,
> > +		p = add_packed_git(store->source->odb->repo, idx_path,
> >  				   strlen(idx_path), local);
> >  		if (p)
> >  			packfile_store_add_pack(store, p);
> > @@ -1068,8 +1068,8 @@ void packfile_store_prepare(struct packfile_store *store)
> >  	if (store->initialized)
> >  		return;
> >  
> > -	odb_prepare_alternates(store->odb);
> > -	for (source = store->odb->sources; source; source = source->next) {
> > +	odb_prepare_alternates(store->source->odb);
> > +	for (source = store->source->odb->sources; source; source = source->next) {
> 
> huh so IIUC, even though there is a packfile store per ODB source, we
> will add the alternate sources to the same packfile store? 

Not quite -- what we're doing here is that whenever we prepare a
packfile source, we'll implicitly also prepare all the other packfile
sources part of the same ODB. They will still be separate packfile
sources, but regardless of that this logic is of course still quite
flawed.

> This is feels very awkward, but is maybe part of the "weird in-between
> state" you mentioned in the commit message.

It very much is, yes. It gets cleaned up at a later point in this patch
series, but I'm not a huge fan of this intermediate step where we are in
this in-between state. I have been pondering over it for quite a while
though and wasn't able to figure out a better way to structure the
series to avoid this :/

Patrick