threads / bug / 58244

Bug in git submodule update --depth

Subject: Bug in git submodule update --depth

## tl;dr

One message between Jul 29, 2022 and Jul 29, 2022.

replies: 0people: 1as markdown or json

Jesse Rittner· Jul 29, 2022, 15:20 UTC · lore

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

← back to recent threads