Patrick Steinhardt [off-list ref] 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.
[snip]
The changes look good.