diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-06-10 21:54:42 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-10 21:54:42 -0700 |
commit | 26cbc324958fb506e6e7afaa674017cf75f0d9f3 (patch) | |
tree | 71980a6286a30fd8f831b92424670fe706646bcb | |
parent | e81a67f9d3a23b3cc1edf0bd958fbbb9f8f4efe9 (diff) | |
download | subsurface-26cbc324958fb506e6e7afaa674017cf75f0d9f3.tar.gz |
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>
-rw-r--r-- | git-access.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/git-access.c b/git-access.c index a5304cb70..e2d7e1c03 100644 --- a/git-access.c +++ b/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; |