Re: [PATCH 01/12] cache-tree: remove dependency on `the_repository`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 1, 2026, 22:03 UTC
- Message-ID
- <xmqqzey0ljcv.fsf@gitster.g>
- In-Reply-To
- <20260901-pks-odb-registering-in-memory-sources-v1-1-97a312d5fa25@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 11 quoted lines
> The "cache-tree" subsystem still depends on `the_repository`. Adapt it > to instead use repositories provided via the context, either as a new > parameter or the one passed in via `struct index_state`. > > Besides getting rid of `the_repository`, this also removes the last > dependency on registering submodule sources with the main object > database. When reading gitmodules from a submodule's index we implicitly > read that object via `the_repository`'s object database, which is of > course wrong. This works though because we would then register the > submodule's object database with the main object database, but a later > patch is going to get rid of that mechanism.
As "the_repository, " is quite a long string, many lines bust our usual ~70 column limit, but other than that the changes look quite straight-forward.
We probably should make the cache_tree_fully_valid() into file scope static. Your new cache_tree_fully_valid() that takes the repository and a cache_tree, which will be file-scope static, will gain a new thin wrapper around it, i.e.,
int has_valid_cache_tree(struct index_state *istate)
{
return cache_tree_fully_valid(istate->repo, istate->cache_tree);
}Migrate the callers outside cache_tree.c file to use it; outside the implementation, nobody has any business talking about a subdirectory of any cache-tree, or any cache-tree outside the context of the istate it belongs to.
Other than that, looking good.