Commit 870e12d7 authored by LE Manh Cuong's avatar LE Manh Cuong Committed by Bryan C. Mills

cmd/go: fix go get fail when GIT_TRACE set

GIT_TRACE write message to stderr, while run1 merge both stdout and
stderr. So function which call run1 and rely on its output will failed
to parse the result when run1 success.

By using cmd.Output(), we ensure only cmd standard out is returned.

Fixes #19682

Change-Id: I7002df17fe68aea1860ddc7382c68cc23548bd90
Reviewed-on: https://go-review.googlesource.com/126735Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 5a720d22
......@@ -5,7 +5,6 @@
package get
import (
"bytes"
"encoding/json"
"errors"
"fmt"
......@@ -428,19 +427,18 @@ func (v *vcsCmd) run1(dir string, cmdline string, keyval []string, verbose bool)
fmt.Printf("cd %s\n", dir)
fmt.Printf("%s %s\n", v.cmd, strings.Join(args, " "))
}
var buf bytes.Buffer
cmd.Stdout = &buf
cmd.Stderr = &buf
err = cmd.Run()
out := buf.Bytes()
out, err := cmd.Output()
if err != nil {
if verbose || cfg.BuildV {
fmt.Fprintf(os.Stderr, "# cd %s; %s %s\n", dir, v.cmd, strings.Join(args, " "))
os.Stderr.Write(out)
if ee, ok := err.(*exec.ExitError); ok && len(ee.Stderr) > 0 {
os.Stderr.Write(ee.Stderr)
} else {
fmt.Fprintf(os.Stderr, err.Error())
}
return out, err
}
return out, nil
}
return out, err
}
// ping pings to determine scheme to use.
......
env GIT_TRACE=1
[!net] skip
[!exec:git] skip
# go get should be success when GIT_TRACE set
go get golang.org/x/text
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment