Skip to content

Commit

Permalink
ssh: read from stderr if stdout is empty
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
carlosmn committed Jun 22, 2015
1 parent c760654 commit 1fcdcb4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/transports/ssh.c
Expand Up @@ -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;
Expand Down

0 comments on commit 1fcdcb4

Please sign in to comment.