Go version

go version devel go1.23-58052fe8 Thu Mar 7 05:27:04 2024 +0000 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/usr/local/google/home/bcmills/.cache/go-build'
GOENV='/usr/local/google/home/bcmills/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/usr/local/google/home/bcmills/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/usr/local/google/home/bcmills'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/google/home/bcmills/sdk/gotip'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/google/home/bcmills/sdk/gotip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.23-58052fe8 Thu Mar 7 05:27:04 2024 +0000'
GODEBUG=''
GCCGO='/usr/bin/gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/usr/local/google/home/bcmills/x/build/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 -ffile-prefix-map=/tmp/go-build1970418467=/tmp/go-build -gno-record-gcc-switches'

What did you do?

~/x/build$ go test ./cmd/gitmirror -v

What did you see happen?

~/x/build$ go test ./cmd/gitmirror -v
=== RUN   TestHomepage
    gitmirror_test.go:161: git config user.name Gopher: exit status 128
        fatal: not in a git directory
--- FAIL: TestHomepage (0.04s)
=== RUN   TestDebugWatcher
    gitmirror_test.go:161: git config user.name Gopher: exit status 128
        fatal: not in a git directory
--- FAIL: TestDebugWatcher (0.04s)
=== RUN   TestArchive
    gitmirror_test.go:161: git config user.name Gopher: exit status 128
        fatal: not in a git directory
--- FAIL: TestArchive (0.04s)
=== RUN   TestMirror
    gitmirror_test.go:161: git config user.name Gopher: exit status 128
        fatal: not in a git directory
--- FAIL: TestMirror (0.04s)
=== RUN   TestMirrorInitiallyEmpty
    gitmirror_test.go:161: git config user.name Gopher: exit status 128
        fatal: not in a git directory
--- FAIL: TestMirrorInitiallyEmpty (0.04s)
FAIL
FAIL    golang.org/x/build/cmd/gitmirror        0.257s
FAIL

What did you expect to see?

All tests passing.

Comment From: bcmills

I believe that Google's build of git has a different default for the safe.bareRepository setting, which may require setting GIT_DIR explicitly for certain commands. (Compare https://go.dev/cl/489915.)

Comment From: mknyszek

CC @dmitshur maybe? (When he gets back.)

Comment From: gopherbot

Change https://go.dev/cl/605976 mentions this issue: cmd/gitmirror: explicitly specify GIT_DIR