Skip to content

Commit 5b1915e

Browse files
committed
Merge pull request git-lfs#718 from bozaro/stderr
Use separate buffers for stdout and stderr on executing git-lfs-authenticate
2 parents cf7b715 + c5376d1 commit 5b1915e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lfs/ssh.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os/exec"
66
"path/filepath"
77
"strings"
8+
"bytes"
89

910
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
1011
)
@@ -37,12 +38,22 @@ func sshAuthenticate(endpoint Endpoint, operation, oid string) (sshAuthResponse,
3738

3839
cmd := exec.Command(exe, args...)
3940

40-
out, err := cmd.CombinedOutput()
41+
// Save stdout and stderr in separate buffers
42+
var outbuf, errbuf bytes.Buffer
43+
cmd.Stdout = &outbuf
44+
cmd.Stderr = &errbuf
4145

46+
// Execute command
47+
err := cmd.Start()
48+
if err == nil {
49+
err = cmd.Wait()
50+
}
51+
52+
// Processing result
4253
if err != nil {
43-
res.Message = string(out)
54+
res.Message = errbuf.String()
4455
} else {
45-
err = json.Unmarshal(out, &res)
56+
err = json.Unmarshal(outbuf.Bytes(), &res)
4657
}
4758

4859
return res, err

0 commit comments

Comments
 (0)