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

Method Fetch

remote.go:1035–1066  ·  view source on GitHub ↗

Fetch performs a fetch operation. refspecs specifies which refspecs to use for this fetch, use an empty list to use the refspecs from the configuration; msg specifies what to use for the reflog entries. Leave "" to use defaults.

(refspecs []string, opts *FetchOptions, msg string)

Source from the content-addressed store, hash-verified

1033// the configuration; msg specifies what to use for the reflog
1034// entries. Leave "" to use defaults.
1035func (o *Remote) Fetch(refspecs []string, opts *FetchOptions, msg string) error {
1036 var cmsg *C.char = nil
1037 if msg != "" {
1038 cmsg = C.CString(msg)
1039 defer C.free(unsafe.Pointer(cmsg))
1040 }
1041
1042 var err error
1043 crefspecs := C.git_strarray{
1044 count: C.size_t(len(refspecs)),
1045 strings: makeCStringsFromStrings(refspecs),
1046 }
1047 defer freeStrarray(&crefspecs)
1048
1049 coptions := populateFetchOptions(&C.git_fetch_options{}, opts, &err)
1050 defer freeFetchOptions(coptions)
1051
1052 runtime.LockOSThread()
1053 defer runtime.UnlockOSThread()
1054
1055 ret := C.git_remote_fetch(o.ptr, &crefspecs, coptions, cmsg)
1056 runtime.KeepAlive(o)
1057
1058 if ret == C.int(ErrorCodeUser) && err != nil {
1059 return err
1060 }
1061 if ret < 0 {
1062 return MakeGitError(ret)
1063 }
1064
1065 return nil
1066}
1067
1068func (o *Remote) ConnectFetch(callbacks *RemoteCallbacks, proxyOpts *ProxyOptions, headers []string) error {
1069 return o.Connect(ConnectDirectionFetch, callbacks, proxyOpts, headers)

Callers 4

TestCertificateCheckFunction · 0.80
TestRemotePruneFunction · 0.80
TestRemoteSSHFunction · 0.80

Calls 6

makeCStringsFromStringsFunction · 0.85
freeStrarrayFunction · 0.85
populateFetchOptionsFunction · 0.85
freeFetchOptionsFunction · 0.85
MakeGitErrorFunction · 0.85
freeMethod · 0.80

Tested by 4

TestCertificateCheckFunction · 0.64
TestRemotePruneFunction · 0.64
TestRemoteSSHFunction · 0.64