MCPcopy Create free account
hub / github.com/libgit2/git2go / Connect

Method Connect

remote.go:1083–1109  ·  view source on GitHub ↗

Connect opens a connection to a remote. The transport is selected based on the URL. The direction argument is due to a limitation of the git protocol (over TCP or SSH) which starts up a specific binary which can only do the one or the other. 'headers' are extra HTTP headers to use in this connecti

(direction ConnectDirection, callbacks *RemoteCallbacks, proxyOpts *ProxyOptions, headers []string)

Source from the content-addressed store, hash-verified

1081//
1082// 'headers' are extra HTTP headers to use in this connection.
1083func (o *Remote) Connect(direction ConnectDirection, callbacks *RemoteCallbacks, proxyOpts *ProxyOptions, headers []string) error {
1084 var err error
1085 ccallbacks := populateRemoteCallbacks(&C.git_remote_callbacks{}, callbacks, &err)
1086 defer untrackCallbacksPayload(ccallbacks)
1087
1088 cproxy := populateProxyOptions(&C.git_proxy_options{}, proxyOpts)
1089 defer freeProxyOptions(cproxy)
1090
1091 cheaders := C.git_strarray{
1092 count: C.size_t(len(headers)),
1093 strings: makeCStringsFromStrings(headers),
1094 }
1095 defer freeStrarray(&cheaders)
1096
1097 runtime.LockOSThread()
1098 defer runtime.UnlockOSThread()
1099
1100 ret := C.git_remote_connect(o.ptr, C.git_direction(direction), ccallbacks, cproxy, &cheaders)
1101 runtime.KeepAlive(o)
1102 if ret == C.int(ErrorCodeUser) && err != nil {
1103 return err
1104 }
1105 if ret != 0 {
1106 return MakeGitError(ret)
1107 }
1108 return nil
1109}
1110
1111func (o *Remote) Disconnect() {
1112 runtime.LockOSThread()

Callers 2

ConnectFetchMethod · 0.95
ConnectPushMethod · 0.95

Calls 7

populateRemoteCallbacksFunction · 0.85
untrackCallbacksPayloadFunction · 0.85
populateProxyOptionsFunction · 0.85
freeProxyOptionsFunction · 0.85
makeCStringsFromStringsFunction · 0.85
freeStrarrayFunction · 0.85
MakeGitErrorFunction · 0.85

Tested by

no test coverage detected