diff options
author | Jay Conrod <jayconrod@google.com> | 2019-06-06 17:00:27 -0400 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2019-06-13 14:14:02 +0000 |
commit | 55d31e16c12c38d36811bdee65ac1f7772148250 (patch) | |
tree | 0223997410f0f3dc11f5ee87fb9dfd2e133e0980 /src/cmd/go/internal/modfetch/codehost/git.go | |
parent | b388d6868fba8a0764d4dbd940a0bd249133923f (diff) | |
download | go-55d31e16c12c38d36811bdee65ac1f7772148250.tar.gz go-55d31e16c12c38d36811bdee65ac1f7772148250.zip |
cmd/go: add '--' before repository names when invoking vcs tools
Also, in 'go get' in GOPATH mode, report an error for package paths
that start with '-'.
Change-Id: Ic2575381aa2d093ba15c53b893bf2eaded8b6066
Reviewed-on: https://go-review.googlesource.com/c/go/+/181237
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/modfetch/codehost/git.go')
-rw-r--r-- | src/cmd/go/internal/modfetch/codehost/git.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/cmd/go/internal/modfetch/codehost/git.go b/src/cmd/go/internal/modfetch/codehost/git.go index 272eadcb23..a1d451d61a 100644 --- a/src/cmd/go/internal/modfetch/codehost/git.go +++ b/src/cmd/go/internal/modfetch/codehost/git.go @@ -80,7 +80,7 @@ func newGitRepo(remote string, localOK bool) (Repo, error) { // but this lets us say git fetch origin instead, which // is a little nicer. More importantly, using a named remote // avoids a problem with Git LFS. See golang.org/issue/25605. - if _, err := Run(r.dir, "git", "remote", "add", "origin", r.remote); err != nil { + if _, err := Run(r.dir, "git", "remote", "add", "origin", "--", r.remote); err != nil { os.RemoveAll(r.dir) return nil, err } @@ -123,8 +123,10 @@ type gitRepo struct { statCache par.Cache refsOnce sync.Once - refs map[string]string - refsErr error + // refs maps branch and tag refs (e.g., "HEAD", "refs/heads/master") + // to commits (e.g., "37ffd2e798afde829a34e8955b716ab730b2a6d6") + refs map[string]string + refsErr error localTagsOnce sync.Once localTags map[string]bool @@ -407,7 +409,7 @@ func (r *gitRepo) fetchUnshallow(refSpecs ...string) error { // statLocal returns a RevInfo describing rev in the local git repository. // It uses version as info.Version. func (r *gitRepo) statLocal(version, rev string) (*RevInfo, error) { - out, err := Run(r.dir, "git", "-c", "log.showsignature=false", "log", "-n1", "--format=format:%H %ct %D", rev) + out, err := Run(r.dir, "git", "-c", "log.showsignature=false", "log", "-n1", "--format=format:%H %ct %D", rev, "--") if err != nil { return nil, fmt.Errorf("unknown revision %s", rev) } |