mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cloud storage
Use the credential helpers earlier in the source. This way we can use them for the push as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e81a67f9d3
commit
26cbc32495
1 changed files with 24 additions and 24 deletions
48
git-access.c
48
git-access.c
|
@ -101,6 +101,30 @@ static int reset_to_remote(git_repository *repo, git_reference *local, const git
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if USE_LIBGIT23_API
|
||||
int credential_ssh_cb(git_cred **out,
|
||||
const char *url,
|
||||
const char *username_from_url,
|
||||
unsigned int allowed_types,
|
||||
void *payload)
|
||||
{
|
||||
const char *priv_key = format_string("%s/%s", system_default_directory(), "ssrf_remote.key");
|
||||
const char *passphrase = prefs.cloud_storage_password ? strdup(prefs.cloud_storage_password) : strdup("");
|
||||
return git_cred_ssh_key_new(out, username_from_url, NULL, priv_key, passphrase);
|
||||
}
|
||||
|
||||
int credential_https_cb(git_cred **out,
|
||||
const char *url,
|
||||
const char *username_from_url,
|
||||
unsigned int allowed_types,
|
||||
void *payload)
|
||||
{
|
||||
const char *username = prefs.cloud_storage_email_encoded;
|
||||
const char *password = prefs.cloud_storage_password ? strdup(prefs.cloud_storage_password) : strdup("");
|
||||
return git_cred_userpass_plaintext_new(out, username, password);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int update_remote(git_repository *repo, git_remote *origin, git_reference *local, git_reference *remote, enum remote_type rt)
|
||||
{
|
||||
git_push_options opts = GIT_PUSH_OPTIONS_INIT;
|
||||
|
@ -168,30 +192,6 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference
|
|||
return report_error("Local and remote have diverged, need to merge");
|
||||
}
|
||||
|
||||
#if USE_LIBGIT23_API
|
||||
int credential_ssh_cb(git_cred **out,
|
||||
const char *url,
|
||||
const char *username_from_url,
|
||||
unsigned int allowed_types,
|
||||
void *payload)
|
||||
{
|
||||
const char *priv_key = format_string("%s/%s", system_default_directory(), "ssrf_remote.key");
|
||||
const char *passphrase = prefs.cloud_storage_password ? strdup(prefs.cloud_storage_password) : strdup("");
|
||||
return git_cred_ssh_key_new(out, username_from_url, NULL, priv_key, passphrase);
|
||||
}
|
||||
|
||||
int credential_https_cb(git_cred **out,
|
||||
const char *url,
|
||||
const char *username_from_url,
|
||||
unsigned int allowed_types,
|
||||
void *payload)
|
||||
{
|
||||
const char *username = prefs.cloud_storage_email_encoded;
|
||||
const char *password = prefs.cloud_storage_password ? strdup(prefs.cloud_storage_password) : strdup("");
|
||||
return git_cred_userpass_plaintext_new(out, username, password);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int check_remote_status(git_repository *repo, git_remote *origin, const char *branch, enum remote_type rt)
|
||||
{
|
||||
git_reference *local_ref, *remote_ref;
|
||||
|
|
Loading…
Add table
Reference in a new issue