summaryrefslogtreecommitdiffstats
path: root/git-access.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-13 09:13:08 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-13 09:14:48 -0700
commit7b7568b1ba536d37263dd8d2b395828ac0a2fd41 (patch)
tree09fc8bd87f2eaa4008115abf337637b26b5fad08 /git-access.c
parentdf255e257316c277c51fb5fab5ca5168f0cae631 (diff)
downloadsubsurface-7b7568b1ba536d37263dd8d2b395828ac0a2fd41.tar.gz
Cloud storage: setup proxy before cloning new repository
If we don't have a repository yet, we can't setup the proxy option before calling into libgit2. Instead we use a callback. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'git-access.c')
-rw-r--r--git-access.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/git-access.c b/git-access.c
index 60e369bfb..061f8ec27 100644
--- a/git-access.c
+++ b/git-access.c
@@ -278,6 +278,21 @@ static git_repository *update_local_repo(const char *localdir, const char *remot
return repo;
}
+static int repository_create_cb(git_repository **out, const char *path, int bare, void *payload)
+{
+ char *proxy_string;
+ git_config *conf;
+
+ int ret = git_repository_init(out, path, bare);
+
+ if (getProxyString(&proxy_string)) {
+ git_repository_config(&conf, *out);
+ git_config_set_string(conf, "http.proxy", proxy_string);
+ free(proxy_string);
+ }
+ return ret;
+}
+
static git_repository *create_local_repo(const char *localdir, const char *remote, const char *branch, enum remote_transport rt)
{
int error;
@@ -288,6 +303,7 @@ static git_repository *create_local_repo(const char *localdir, const char *remot
opts.fetch_opts.callbacks.credentials = credential_ssh_cb;
else if (strncmp(remote, "https://", 8) == 0)
opts.fetch_opts.callbacks.credentials = credential_https_cb;
+ opts.repository_cb = repository_create_cb;
#endif
opts.checkout_branch = branch;
if (rt == RT_HTTPS && !canReachCloudServer())