Open Baltoli opened 4 days ago
So it turns out that this is the source of my issues with being unable to init submodules in the k repo. Here's the problem:
.../llvm-backend
is a submodule of k
, and deps/pybind
is a submodule of .../llvm-backend
.k
I do git submodule update --init --recursive
, .../llvm-backend
is brought in, and HEAD
is set to the commit specified by the current commit of k
. Thus, HEAD
points to a commit, not a ref (or "branch name", as it's often called). Being a commit and not a ref, it can have no tracking ref (a ref updated from the remote, e.g. refs/remotes/origin/main
).git submodule
attempts to init deps/pybind11
in .../llvm-backend
it reads url = ../../pybind/pybind11
, determines that it's a relative URL (because it starts with ../
) and goes to look for an absolute URL for it to be relative to.git-submodule
manual page, "relative to the superproject’s repository." It normal attempts to retrieve the superproject's repo URL by looking at the tracking ref associated with HEAD
in the superproject..git/config
, it instead just guesses origin
as the remote name. This does not exist in my repo, because I have clone.defaultRemoteName = r
set in my ~/.gitconfig
. (I hate typing more than I have to.) I'd argue that this guess of origin
rather than guessing one of the remote names the repo is actually using is a bug in Git.t find the URL of a remote named
origin`, it falls back to a remote set to the relative path relative to the filesystem path in which llvm-backend is checked out.git submodule
doesn't recognise this, and considers the failure to fetch from it a temporary error. It tries again almost immediately, but that fails too, of course.
All the other URLs are absolute, so logically this one should match. Additionally, the relative URL will break if someone's main remote is not on GitHub.
Adopted PR from #1100 - thanks @0cjs!