Problem with multiples levels of submodules
From: Jeppe Øland <hidden>
Date: 2024-06-25 22:54:39
Hi there,
I'm seeing a strange thing with multi-level submodules.
Not sure what's going on, but it feels like a bug.
(I'm doing this on git "2.45.2.windows.1").
For a while, I've been globally setting the recursive and active config options:
git config --global submodule.recurse true
git config --global submodule.active .
This has the benefit that I don't need to "git submodule init" new
modules since everything is active.
The weirdness happens when there are submodules within a submodule.
I can reproduce it by just creating 3 git repositories (I have only
tried with GH hosted repos, maybe its different if done locally).
Each repo has a directory within it, and that directory is a submodule
of the next one.
top -> middle -> bottom
Now, if I don't set the global config above, I can:
"git clone --recurse-submodules <PATH>" to get everything.
Or:
"git clone <PATH>", "cd", "git submodule init", "git pull" etc. to
again get everything.
But if I set the global options, I can do:
"git clone <PATH>" to clone the top level.
"cd top" to go in there.
"git pull" to update everything, including submodules.
But while cloning "middle", it gives me an error:
fatal: not a git repository: ../../.git/modules/middle/modules/bottom
Something is getting confused and thinks there are worktrees involved:
".git/modules/middle/config" has "worktree" line in the [core]
section (this appears to be normal).
".git/modules/middle/modules/bottom/config" is not a repository,
but just a "[core] worktree" section (definitely not normal).
This all works fine if there is only one level of submodules (top->middle).
Any ideas?
Regards,
-Jeppe