Fix FTBFS on $HOME managed with git.
authorBryan C. Mills <bcmills@google.com>
Fri, 13 Mar 2020 16:51:09 +0000 (12:51 -0400)
committerShengjing Zhu <zhsj@debian.org>
Fri, 3 Jul 2020 13:42:15 +0000 (14:42 +0100)
commit4f59bd15c0f426699121de1f6f16c22ecfe497cb
treee86e12fe1a04b39a122211c7c0d3420ae5167577
parentef5c3ac982951e38fe26aa79a1d0afeee5f6277f
Fix FTBFS on $HOME managed with git.

This is a cherry-pick of
https://github.com/golang/go/commit/e2a9ea035d73df84c813132417366e8e01777c8d

cmd/go/internal/modload: suppress the 'go mod init' hint for GOROOT more aggressively

Previously, we suppressed a `to create a module there, run: … go mod
init' warning only if the config file itself (such as .git/config) was
found in GOROOT. However, our release tarballs don't include the
.git/config, so that case was not encountered, and the warning could
occur based on a config file found in some parent directory (outside
of GOROOT entirely).

Instead, skip the directory walk completely if the working directory
is anywhere in GOROOT.

Fixes #34191

Change-Id: I9f774901bfbb53b700407c4882f37d6339d023fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/223340
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Gbp-Pq: Name 0003-Fix-FTBFS-on-HOME-managed-with-git.patch
src/cmd/go/internal/modload/init.go
src/cmd/go/testdata/script/mod_convert_git.txt