mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
df255e2573
commit
7b7568b1ba
1 changed files with 16 additions and 0 deletions
16
git-access.c
16
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())
|
||||
|
|
Loading…
Add table
Reference in a new issue