summaryrefslogtreecommitdiffstats
path: root/git-access.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-31 17:15:58 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-31 17:15:58 -0700
commit97ef9d0ee81f9037e7d71041bfb326c304888283 (patch)
treef4146928d77c49f12724e942cc94b9bb1c5b7068 /git-access.c
parent96cffe88e72cefa29c13dd839332b0cc7ce42ed2 (diff)
downloadsubsurface-97ef9d0ee81f9037e7d71041bfb326c304888283.tar.gz
Cloud storage: add support for https based remote
This will make it easier to access the remote storage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'git-access.c')
-rw-r--r--git-access.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/git-access.c b/git-access.c
index 60607fa7b..c0e1a7710 100644
--- a/git-access.c
+++ b/git-access.c
@@ -70,7 +70,7 @@ static int try_to_update(git_repository *rep, git_reference *local, git_referenc
}
#if USE_LIBGIT23_API
-int credential_cb(git_cred **out,
+int credential_ssh_cb(git_cred **out,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
@@ -80,6 +80,17 @@ int credential_cb(git_cred **out,
const char *passphrase = copy_string(prefs.passphrase);
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 = "ssrftest";
+ const char *password = copy_string(prefs.passphrase);
+ return git_cred_userpass_plaintext_new(out, username, password);
+}
#endif
static git_repository *update_local_repo(const char *localdir, const char *remote, const char *branch)
@@ -111,7 +122,9 @@ static git_repository *update_local_repo(const char *localdir, const char *remot
#if USE_LIBGIT23_API
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
if (strncmp(remote, "ssh://", 6) == 0)
- opts.callbacks.credentials = credential_cb;
+ opts.callbacks.credentials = credential_ssh_cb;
+ else if (strncmp(remote, "https://", 8) == 0)
+ opts.callbacks.credentials = credential_https_cb;
error = git_remote_fetch(origin, NULL, &opts, NULL);
#else
error = git_remote_fetch(origin, NULL, NULL, NULL);
@@ -151,7 +164,9 @@ static git_repository *create_local_repo(const char *localdir, const char *remot
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
#if USE_LIBGIT23_API
if (strncmp(remote, "ssh://", 6) == 0)
- opts.fetch_opts.callbacks.credentials = credential_cb;
+ opts.fetch_opts.callbacks.credentials = credential_ssh_cb;
+ else if (strncmp(remote, "https://", 8) == 0)
+ opts.fetch_opts.callbacks.credentials = credential_https_cb;
#endif
opts.checkout_branch = branch;
error = git_clone(&cloned_repo, remote, localdir, &opts);