Skip to content

Commit 6423ffb

Browse files
authored
Merge pull request libgit2#6802 from libgit2/ethomson/cb_err
transport: provide a useful error message during cancellation
2 parents 85d42ea + ffd881e commit 6423ffb

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/libgit2/transports/local.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ static int local_push(
458458
default:
459459
last = git_error_last();
460460

461-
if (last && last->message)
461+
if (last->klass != GIT_ERROR_NONE)
462462
status->msg = git__strdup(last->message);
463463
else
464464
status->msg = git__strdup("Unspecified error encountered");

src/libgit2/transports/ssh_libssh2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ static int _git_ssh_authenticate_session(
375375
return GIT_EAUTH;
376376

377377
if (rc != LIBSSH2_ERROR_NONE) {
378-
if (!git_error_last())
379-
ssh_error(session, "Failed to authenticate SSH session");
378+
if (git_error_last()->klass == GIT_ERROR_NONE)
379+
ssh_error(session, "failed to authenticate SSH session");
380380
return -1;
381381
}
382382

src/libgit2/transports/winhttp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static int certificate_check(winhttp_stream *s, int valid)
293293

294294
/* If there is no override, we should fail if WinHTTP doesn't think it's fine */
295295
if (t->owner->connect_opts.callbacks.certificate_check == NULL && !valid) {
296-
if (!git_error_last())
296+
if (git_error_last()->klass == GIT_ERROR_NONE)
297297
git_error_set(GIT_ERROR_HTTP, "unknown certificate check failure");
298298

299299
return GIT_ECERTIFICATE;
@@ -317,7 +317,7 @@ static int certificate_check(winhttp_stream *s, int valid)
317317
if (error == GIT_PASSTHROUGH)
318318
error = valid ? 0 : GIT_ECERTIFICATE;
319319

320-
if (error < 0 && !git_error_last())
320+
if (error < 0 && git_error_last()->klass == GIT_ERROR_NONE)
321321
git_error_set(GIT_ERROR_HTTP, "user cancelled certificate check");
322322

323323
return error;
@@ -961,7 +961,7 @@ static int send_request(winhttp_stream *s, size_t len, bool chunked)
961961
(!request_failed && s->status_sending_request_reached)) {
962962
git_error_clear();
963963
if ((error = certificate_check(s, cert_valid)) < 0) {
964-
if (!git_error_last())
964+
if (git_error_last()->klass == GIT_ERROR_NONE)
965965
git_error_set(GIT_ERROR_OS, "user cancelled certificate check");
966966

967967
return error;

0 commit comments

Comments
 (0)