Bug in git submodule update --depth
- From
- Jesse Rittner <rittneje@gmail.com>
- Date
- Jul 29, 2022, 15:20 UTC
- Message-ID
- <CA+SRSSGkgLrmy0ATj+1OOL6=jR6J0SE+0Orbwh+=C5KcVp82kA@mail.gmail.com>
We have a repository with a submodule. The submodule is on some fairly old commit. Under git 2.27.0, the following worked without issue
`git submodule update --init --recursive --depth=1 [path]`
(This did a shallow clone of the specific submodule commit.)
However, in git 2.31.1, it fails. The same failure is observed in git 2.37.1. I am unsure when the bug was introduced.
git submodule update --init --recursive --depth=1 [submodule] Submodule '[submodule]' (ssh://git@[redacted].git) registered for path '[submodule]’ Cloning into '[repository]/[submodule]'... remote: Total 0 (delta 0), reused 0 (delta 0) remote: Total 0 (delta 0), reused 0 (delta 0) fatal: bad object e6f1975700c8d6fec2c3812277e3260194cb5379 error: remote did not send all necessary objects fatal: Fetched in submodule path '[submodule]', but it did not contain e6f1975700c8d6fec2c3812277e3260194cb5379. Direct fetching of that commit failed.
From testing, it seems that git is incorrectly doing a shallow clone of the branch instead of the submodule commit.
Your assistance in this matter is greatly appreciated.
Thanks, Jesse Rittner