cmd/go: git worktrees with gitdir ending in /.git no longer compile for some repos
sharnoff opened this issue · 2 comments
What version of Go are you using (go version)?
$ go version go version go1.20.2 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/[redacted]/.cache/go-build" GOENV="/home/[redacted]/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/[redacted]/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/[redacted]/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/lib/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.20.2" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/[redacted]/temp/buildvcs-fail/main/go.mod" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4197836122=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Upgraded to the latest Go compiler.
This does not reproduce on all repos, but I noticed it while working on github.com/neondatabase/autoscaling. Replicating the error can be done with:
# enter a fresh, empty directory, then:
git clone --bare git@github.com:neondatabase/autoscaling .git
git worktree add main
cd main
go build ./... # fails!(for posterity, the latest commit on the repo above is 0b082ec262, at time of writing)
Doing the above with any Go 1.19 compiler does not fail.
What did you expect to see?
After upgrading from 1.19 to 1.20, the repo should continue to compile with the git worktree structure as shown.
What did you see instead?
It did not compile, failing with:
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
I am aware that I can fix this problem by adding flags. However, it is a breaking change for a new version to require flags where it didn't before.
Please also note that this is not some sort of degenerate case of using git worktrees; this is the way that I typically structure my local files when working on multiple branches, and has specific unique advantages.
Duplicate of #58218
@seankhliao This is not a duplicate. #58218 was about VCS info not being included with worktrees (but still compiling). This issue is reporting that sometimes valid worktrees do not compile.