Description
I was unable to have the godot-git-plugin properly communicate with my remote repository which was specified as an SSH connection. In my case the access to the repository was through SSH key (not user/password). I specified the Version Control parameters as specified below.
I was unable to do a push or fetch from within the editor.
The error was a -16 (EAUTH).
After digging around in the code I determined that the credentials_cb method in git_callbacks.cpp would always use the GIT_CREDENTIAL_USERPASS_PLAINTEXT option since the allowed_types included that option and GIT_CREDENTIAL_USERPASS_PLAINTEXT was specified before the GIT_CREDENTIAL_SSH_KEY option.
Of course I didn't have a password for the user (it only supports SSH key - no password allowed), so it never worked.
I think the correct operation should be to use GIT_CREDENTIAL_SSH_KEY as the preferred credential type if the Credentials class includes an ssh_public_key_path and the allowed_types includes GIT_CREDENTIAL_SSH_KEY.
Here would be a candidate implementation:
extern "C" int credentials_cb(git_cred **out, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload) {
Credentials *creds = (Credentials *)payload;
godot::String proper_username = username_from_url ? username_from_url : creds->username;
if (!creds->ssh_public_key_path.is_empty()) {
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
return git_credential_ssh_key_new(out,
CString(proper_username).data,
CString(creds->ssh_public_key_path).data,
CString(creds->ssh_private_key_path).data,
CString(creds->ssh_passphrase).data);
}
if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
return git_cred_userpass_plaintext_new(out, CString(proper_username).data, CString(creds->password).data);
}
if (allowed_types & GIT_CREDENTIAL_USERNAME) {
return git_credential_username_new(out, CString(proper_username).data);
}
return GIT_EUSER;
}