Repository: go
Issue: cmd/go: "fatal: git fetch-pack: expected shallow list" when retrieving earlier version of already installed package on CentOS 7.
Labels: NeedsInvestigation,modules

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.13.6 linux/amd64
</pre>

### Does this issue reproduce with the latest release?

Not sure, but this is the latest supported version for CentOS 7.

### What operating system and processor architecture are you using (`go env`)?

CentOS 7.

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/users/d00u3151/.cache/go-build"
GOENV="/users/d00u3151/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/users/d00u3151/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/users/d00u3151/tmp/go-build945266341=/tmp/go-build -gno-record-gcc-switches"
[d00u3151@pde-bsp3hq2 dan]$
</pre></details>

### What did you do?

Tried to build the latest unreleased version of reposurgeon (problem does not occur with reposurgeon release 4.5).

<pre>
$ git clone https://gitlab.com/esr/reposurgeon.git
Cloning into 'reposurgeon'...
remote: Enumerating objects: 1203, done.
remote: Counting objects: 100% (1203/1203), done.
remote: Compressing objects: 100% (456/456), done.
remote: Total 33416 (delta 890), reused 1009 (delta 739), pack-reused 32213
Receiving objects: 100% (33416/33416), 550.06 MiB | 11.28 MiB/s, done.
Resolving deltas: 100% (22980/22980), done.
$ cd reposurgeon
$ git checkout -q b392d176f30825d150b828c4df3d2d8e2b3166f7 # version as of April 10, 2020
$ make
asciidoctor -a nofooter -b manpage reposurgeon.adoc
asciidoctor -a nofooter -b manpage repocutter.adoc
asciidoctor -a nofooter -b manpage repomapper.adoc
asciidoctor -a nofooter -b manpage repotool.adoc
asciidoctor -a nofooter -b manpage repobench.adoc
asciidoctor -a webfonts! reposurgeon.adoc
asciidoctor -a webfonts! repocutter.adoc
asciidoctor -a webfonts! repomapper.adoc
asciidoctor -a webfonts! repotool.adoc
asciidoctor -a webfonts! repobench.adoc
asciidoctor -a webfonts! repository-editing.adoc
go build -gcflags '-N -l' -o repocutter ./cutter
go: github.com/go-delve/delve@v1.4.0 requires
        github.com/sirupsen/logrus@v0.0.0-20180523074243-ea8897e79973: invalid version: git fetch --unshallow -f origin in /users/d00u3151/go/pkg/mod/cache/vcs/020616345f7c7f88438c217f9d0e26744bce721c80e4a28f93399a8a4cd2acf1: exit status 128:
        fatal: git fetch-pack: expected shallow list
make: *** [build] Error 1
$ make
go build -gcflags '-N -l' -o repocutter ./cutter
go: github.com/go-delve/delve@v1.4.0 requires
        golang.org/x/arch@v0.0.0-20190927153633-4e8777c89be4: invalid version: git fetch --unshallow -f https://go.googlesource.com/arch in /users/d00u3151/go/pkg/mod/cache/vcs/a260a67b53c91dca287c34ff2bdee130be447c2ea411a64bf4489a69e886411b: exit status 128:
        fatal: git fetch-pack: expected shallow list
make: *** [build] Error 1
</pre>

### What did you expect to see?

A successful build.

### What did you see instead?

A cryptic error message.

This seems to occur when multiple versions of the same package are required. In this case, the go.mod contains <code>golang.org/x/arch v0.0.0-20200312215426-ff8b605520f4</code> and <code>github.com/go-delve/delve v1.4.0</code>, but delve v1.4.0 has a dependency on: <code>golang.org/x/arch@v0.0.0-20190927153633-4e8777c89be4</code>. It seems that trying to get the earlier version of arch when the later version has already been retrieved causes this error message.

In this case I was able to work around and successfully build by removing the reference to the later version of arch from go.mod.