Skip to content

Commit 2616da0

Browse files
committed
Only capture stderr of commands that don't have configured Stderr
1 parent dc0de14 commit 2616da0

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

git/git.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ func Dir() (string, error) {
3333

3434
func WorkdirName() (string, error) {
3535
toplevelCmd := exec.Command("git", "rev-parse", "--show-toplevel")
36-
toplevelCmd.Stderr = nil
3736
output, err := utils.PrepareCmd(toplevelCmd).Output()
3837
dir := firstLine(output)
3938
if dir == "" {

utils/prepare_cmd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func (c cmdWithStderr) Output() ([]byte, error) {
3838
if os.Getenv("DEBUG") != "" {
3939
fmt.Fprintf(os.Stderr, "%v\n", c.Cmd.Args)
4040
}
41+
if c.Cmd.Stderr != nil {
42+
return c.Cmd.Output()
43+
}
4144
errStream := &bytes.Buffer{}
4245
c.Cmd.Stderr = errStream
4346
out, err := c.Cmd.Output()
@@ -51,6 +54,9 @@ func (c cmdWithStderr) Run() error {
5154
if os.Getenv("DEBUG") != "" {
5255
fmt.Fprintf(os.Stderr, "%v\n", c.Cmd.Args)
5356
}
57+
if c.Cmd.Stderr != nil {
58+
return c.Cmd.Run()
59+
}
5460
errStream := &bytes.Buffer{}
5561
c.Cmd.Stderr = errStream
5662
err := c.Cmd.Run()

0 commit comments

Comments
 (0)