lfsapi: pass stderr through when filling credentials

When git credential invokes a credential helper, it passes through
standard error to the credential helper.  This is helpful because if an
error occurs, it’s printed to the same place other errors go: either the
terminal, or to a log file.

However, Git LFS does not pass standard error through.  We originally
read it git credential to propagate up, but stopped doing so due to a
problem where buffering caused the credential helper to hang.  However,
when we made that change, we unintentionally redirected standard error
to /dev/null.

In addition to being unhelpful to the end user, this also causes
problems in our CI environment when credential failures happen: we end
up with failures that are nearly impossible to troubleshoot because we
lack the full debugging information that would come from standard error
output.  For all of these reasons, wire up git credential's standard
error to os.Stderr.
This commit is contained in:
brian m. carlson 2018-09-18 19:14:24 +00:00
parent 7e7c39e642
commit 6df606c19e

@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"net/url"
"os"
"os/exec"
"strings"
"sync"
@ -230,13 +231,16 @@ func (h *commandCredentialHelper) exec(subcommand string, input Creds) (Creds, e
cmd.Stdin = bufferCreds(input)
cmd.Stdout = output
/*
There is a reason we don't hook up stderr here:
There is a reason we don't read from stderr here:
Git's credential cache daemon helper does not close its stderr, so if this
process is the process that fires up the daemon, it will wait forever
(until the daemon exits, really) trying to read from stderr.
Instead, we simply pass it through to our stderr.
See https://github.com/git-lfs/git-lfs/issues/117 for more details.
*/
cmd.Stderr = os.Stderr
err := cmd.Start()
if err == nil {