diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-18 15:51:55 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-20 15:08:39 +0200 |
commit | e3435673b8ed862266b5351b9e18cb55ed55d335 (patch) | |
tree | 7c8e63f011948c4817bd923ef5e123deca9d8ea4 /src | |
parent | acc573cba3212c637d02520fb520326b36dcdd39 (diff) | |
download | libgit2-e3435673b8ed862266b5351b9e18cb55ed55d335.tar.gz |
ssh: read from stderr if stdout is empty
When we fail to read from stdout, it's typically because the URL was
wrong and the server process has sent some output over its stderr
output.
Read that output and set the error message to whatever we read from it.
Diffstat (limited to 'src')
-rw-r--r-- | src/transports/ssh.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/transports/ssh.c b/src/transports/ssh.c index c5b081151..0d179e715 100644 --- a/src/transports/ssh.c +++ b/src/transports/ssh.c @@ -125,10 +125,17 @@ static int ssh_stream_read( return -1; if ((rc = libssh2_channel_read(s->channel, buffer, buf_size)) < LIBSSH2_ERROR_NONE) { - ssh_error(s->session, "SSH could not read data");; + ssh_error(s->session, "SSH could not read data"); return -1; } + /* Having something in stderr is typically a not-found error */ + if (rc == 0 && (rc = libssh2_channel_read_stderr(s->channel, buffer, buf_size)) > 0) { + giterr_set(GITERR_SSH, "%*s", rc, buffer); + return -1; + } + + *bytes_read = rc; return 0; |