Skip to content

Commit 74342b2

Browse files
committed
Address issue godotengine#172, to use public key path if present in preference
to using password.
1 parent 3c50df7 commit 74342b2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[submodule "libgit2"]
66
path = thirdparty/git2/libgit2
77
url = https://github.com/libgit2/libgit2
8+
ignore = untracked
89
[submodule "thirdparty/ssh2/libssh2"]
910
path = thirdparty/ssh2/libssh2
1011
url = https://github.com/libssh2/libssh2

godot-git-plugin/src/git_callbacks.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,20 @@ extern "C" int credentials_cb(git_cred **out, const char *url, const char *usern
8282

8383
godot::String proper_username = username_from_url ? username_from_url : creds->username;
8484

85+
if (!creds->ssh_public_key_path.is_empty()) {
86+
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
87+
return git_credential_ssh_key_new(out,
88+
CString(proper_username).data,
89+
CString(creds->ssh_public_key_path).data,
90+
CString(creds->ssh_private_key_path).data,
91+
CString(creds->ssh_passphrase).data);
92+
}
93+
}
94+
8595
if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
8696
return git_cred_userpass_plaintext_new(out, CString(proper_username).data, CString(creds->password).data);
8797
}
8898

89-
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
90-
return git_credential_ssh_key_new(out,
91-
CString(proper_username).data,
92-
CString(creds->ssh_public_key_path).data,
93-
CString(creds->ssh_private_key_path).data,
94-
CString(creds->ssh_passphrase).data);
95-
}
9699

97100
if (allowed_types & GIT_CREDENTIAL_USERNAME) {
98101
return git_credential_username_new(out, CString(proper_username).data);

0 commit comments

Comments
 (0)