Skip to content

Commit 1872c33

Browse files
hiduheschi
authored andcommitted
[release-branch.go1.18] cmd/go: pass --no-decorate when listing git tags for a commit
This avoids a parse error when the user's global .gitconfig sets log.decorate to true. Updates #51312. Fixes #53588. Change-Id: Ic47b0f604c0c3a404ec50d6e09f4e138045ac2f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/387835 Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> (cherry picked from commit a30f434) Reviewed-on: https://go-review.googlesource.com/c/go/+/414874
1 parent f86c6b9 commit 1872c33

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/cmd/go/internal/modfetch/codehost/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func (r *gitRepo) fetchRefsLocked() error {
447447
// statLocal returns a RevInfo describing rev in the local git repository.
448448
// It uses version as info.Version.
449449
func (r *gitRepo) statLocal(version, rev string) (*RevInfo, error) {
450-
out, err := Run(r.dir, "git", "-c", "log.showsignature=false", "log", "-n1", "--format=format:%H %ct %D", rev, "--")
450+
out, err := Run(r.dir, "git", "-c", "log.showsignature=false", "log", "--no-decorate", "-n1", "--format=format:%H %ct %D", rev, "--")
451451
if err != nil {
452452
return nil, &UnknownRevisionError{Rev: rev}
453453
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
env GO111MODULE=on
2+
3+
[!net] skip
4+
[!exec:git] skip
5+
6+
env GOPROXY=direct
7+
env HOME=$WORK/home/gopher
8+
9+
10+
go env GOPROXY
11+
stdout 'direct'
12+
13+
exec git config --get log.decorate
14+
stdout 'full'
15+
16+
# Test that Git log with user's global config '~/gitconfig' has log.decorate=full
17+
# go mod download has an error 'v1.x.y is not a tag'
18+
# with go1.16.14:
19+
# `go1.16.14 list -m vcs-test.golang.org/git/[email protected]`
20+
# will output with error:
21+
# go list -m: vcs-test.golang.org/git/[email protected]: invalid version: unknown revision v1.2.3
22+
# See golang/go#51312.
23+
go list -m vcs-test.golang.org/git/[email protected]
24+
stdout 'vcs-test.golang.org/git/gitrepo1.git v1.2.3'
25+
26+
-- $WORK/home/gopher/.gitconfig --
27+
[log]
28+
decorate = full

0 commit comments

Comments
 (0)