From: Patrick Steinhardt Date: Mon, 07 Sep 2026 07:49:56 GMT Subject: Re: [PATCH v2 02/13] cache-tree: remove dependency on `the_repository` Message-ID: In-Reply-To: On Fri, Sep 04, 2026 at 03:28:07PM -0700, Karthik Nayak wrote: > Patrick Steinhardt writes: > > > 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. > > > > You can verify that we indeed no longer depend on this mechanism by > > running tests with `GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=true`. Without > > this patch we fail in t1092, with this patch we never register submodule > > object databases anymore. > > > > Interesting, to sum up if I understand correctly, somewhere in the call > chain of looking up the gitmodules from the submodules index, we end up > using 'the_repository' instead of the submodule's repo structure. > > This is of course wrong, because we use the wrong repo, the consequence > is that the lookup fails, but we have a last ditch effort of adding all > submodules as alternates and retrying the object read, this succeeds. > > So this patch fixes the repository being correctly passed down. Meaning > we no longer need to add the submodules as an alternate. Yup, exactly this. Patrick