From 1f0f2a415c740dd6da474697d7e5ecca6c70b1d8 Mon Sep 17 00:00:00 2001 From: Jesse van den Kieboom Date: Thu, 25 Dec 2014 12:12:10 +0100 Subject: [PATCH] Fix fallback for failed ssh public key auth --- libgitg/gitg-credentials-manager.vala | 2 +- libgitg/gitg-remote.vala | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libgitg/gitg-credentials-manager.vala b/libgitg/gitg-credentials-manager.vala index db2d8c1e..4e98d3e4 100644 --- a/libgitg/gitg-credentials-manager.vala +++ b/libgitg/gitg-credentials-manager.vala @@ -249,7 +249,7 @@ public class CredentialsManager string? username, Ggit.Credtype allowed_types) throws Error { - if (d_remote.authentication_error != null && (allowed_types & Ggit.Credtype.SSH_KEY) != 0) + if (d_remote.authentication_error == null && (allowed_types & Ggit.Credtype.SSH_KEY) != 0) { return new Ggit.CredSshKeyFromAgent(username); } diff --git a/libgitg/gitg-remote.vala b/libgitg/gitg-remote.vala index b04f1a9d..41ed34f0 100644 --- a/libgitg/gitg-remote.vala +++ b/libgitg/gitg-remote.vala @@ -113,8 +113,10 @@ public class Remote : Ggit.Remote catch (Error e) { // NOTE: need to check the message for now in case of failed - // http auth. - if (e.message == "Unexpected HTTP status code: 401") + // http or ssh auth. This is fragile and will likely break + // in future libgit2 releases. Please fix! + if (e.message == "Unexpected HTTP status code: 401" || + e.message == "error authenticating: Username/PublicKey combination invalid") { d_authentication_error = e; continue;