summaryrefslogtreecommitdiff
path: root/git.go
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2021-09-05 16:39:07 -0700
committerGitHub <[email protected]>2021-09-05 16:39:07 -0700
commitb983e1daebf528443e2a3954cd595fa3664ec93f (patch)
tree51ed7f7c359c9548dad7afa1a445749380d59f66 /git.go
parentf1fa96c7b7f548389c7560d3a1a0bce83be56c9f (diff)
Add support for managed HTTP/S transports (#810)
This change uses the newly-exposed Transport interface to use Go's implementation of http.Client instead of httpclient via libgit2.
Diffstat (limited to 'git.go')
-rw-r--r--git.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/git.go b/git.go
index adf07ae..9ad1ffc 100644
--- a/git.go
+++ b/git.go
@@ -139,22 +139,28 @@ func initLibGit2() {
remotePointers = newRemotePointerList()
C.git_libgit2_init()
+ features := Features()
// Due to the multithreaded nature of Go and its interaction with
// calling C functions, we cannot work with a library that was not built
// with multi-threading support. The most likely outcome is a segfault
// or panic at an incomprehensible time, so let's make it easy by
// panicking right here.
- if Features()&FeatureThreads == 0 {
+ if features&FeatureThreads == 0 {
panic("libgit2 was not built with threading support")
}
- // This is not something we should be doing, as we may be
- // stomping all over someone else's setup. The user should do
- // this themselves or use some binding/wrapper which does it
- // in such a way that they can be sure they're the only ones
- // setting it up.
- C.git_openssl_set_locking()
+ if features&FeatureHTTPS == 0 {
+ if err := registerManagedHTTP(); err != nil {
+ panic(err)
+ }
+ } else {
+ // This is not something we should be doing, as we may be stomping all over
+ // someone else's setup. The user should do this themselves or use some
+ // binding/wrapper which does it in such a way that they can be sure
+ // they're the only ones setting it up.
+ C.git_openssl_set_locking()
+ }
}
// Shutdown frees all the resources acquired by libgit2. Make sure no