Include proxy in Git configuration

Follows the suggestion from there: https://www.klayout.de/forum/discussion/2404.
Using $KLAYOUT_GIT_HTTP_PROXY so it does not interfere with curl.
This commit is contained in:
Matthias Koefferlein 2023-12-05 21:13:03 +01:00
parent ea039bf4bb
commit ce77909c3f
1 changed files with 11 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include "tlProgress.h"
#include "tlStaticObjects.h"
#include "tlLog.h"
#include "tlEnv.h"
#include <git2.h>
#include <cstdio>
@ -314,6 +315,16 @@ GitObject::read (const std::string &org_url, const std::string &org_filter, cons
fetch_opts.callbacks.credentials = &credentials_cb;
fetch_opts.callbacks.payload = (void *) &progress;
// get proxy configuration from environment variable if available
// (see https://www.klayout.de/forum/discussion/2404)
std::string http_proxy = tl::get_env ("KLAYOUT_GIT_HTTP_PROXY");
if (! http_proxy.empty ()) {
fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED;
fetch_opts.proxy_opts.url = http_proxy.c_str ();
}
// build refspecs in case they are needed
char *refs[] = { (char *) branch.c_str () };