errors: add GIT_EEOF to indicate early EOF

This can be used by tools to show mesages about failing to communicate
with the server. The error message in this case will often contain the
server's error message, as far as it managed to send anything.
This commit is contained in:
Carlos Martín Nieto 2015-05-18 16:04:55 +02:00
parent e3435673b8
commit 1396c38178
5 changed files with 15 additions and 4 deletions

View File

@ -93,6 +93,11 @@ support for HTTPS connections insead of OpenSSL.
* `git_stash_pop()` will apply a stashed state (like `git_stash_apply()`)
but will remove the stashed state after a successful application.
* A new error code `GIT_EEOF` indicates an early EOF from the
server. This typically indicates an error with the URL or
configuration of the server, and tools can use this to show messages
about failing to communicate with the server.
### API removals
* `git_remote_save()` and `git_remote_clear_refspecs()` has been

View File

@ -45,6 +45,7 @@ typedef enum {
GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */
GIT_EAPPLIED = -18, /**< Patch/merge has already been applied */
GIT_EPEEL = -19, /**< The requested peel operation is not possible */
GIT_EEOF = -20, /**< Unexpected EOF */
GIT_PASSTHROUGH = -30, /**< Internal only */
GIT_ITEROVER = -31, /**< Signals end of iteration with iterator */

View File

@ -55,6 +55,7 @@ static int ssl_set_error(SSL *ssl, int error)
break;
}
giterr_set(GITERR_NET, "SSL error: received early EOF");
return GIT_EEOF;
break;
case SSL_ERROR_SSL:
e = ERR_get_error();

View File

@ -52,7 +52,7 @@ int git_smart__store_refs(transport_smart *t, int flushes)
if (recvd == 0 && !flush) {
giterr_set(GITERR_NET, "early EOF");
return -1;
return GIT_EEOF;
}
continue;
@ -770,7 +770,7 @@ static int parse_report(transport_smart *transport, git_push *push)
if (recvd == 0) {
giterr_set(GITERR_NET, "early EOF");
return -1;
return GIT_EEOF;
}
continue;
}

View File

@ -129,10 +129,14 @@ static int ssh_stream_read(
return -1;
}
/* Having something in stderr is typically a not-found error */
/*
* If we can't get anything out of stdout, it's typically a
* not-found error, so read from stderr and signal EOF on
* stderr.
*/
if (rc == 0 && (rc = libssh2_channel_read_stderr(s->channel, buffer, buf_size)) > 0) {
giterr_set(GITERR_SSH, "%*s", rc, buffer);
return -1;
return GIT_EEOF;
}