FetchCommand: fix fetchSubmodules to work on a Ref to a blob

FetchCommand#fetchSubmodules assumed that FETCH_HEAD can always be
parsed as a tree. This isn't true if it refers to a Ref referring to a
BLOB. This is e.g. used in Gerrit for Refs like refs/sequences/changes
which are used to implement sequences stored in git.

Change-Id: I414f5b7d9f2184b2d7d53af1dfcd68cccb725ca4
This commit is contained in:
Matthias Sohn 2022-10-04 15:42:25 +02:00
parent 8040936f8a
commit 7650832002
1 changed files with 3 additions and 0 deletions

View File

@ -140,6 +140,9 @@ private void fetchSubmodules(FetchResult results)
if (fetchHead == null) {
return;
}
if (revWalk.parseAny(fetchHead).getType() == Constants.OBJ_BLOB) {
return;
}
walk.setTree(revWalk.parseTree(fetchHead));
while (walk.next()) {
try (Repository submoduleRepo = walk.getRepository()) {