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)
| 1033 | // the configuration; msg specifies what to use for the reflog |
| 1034 | // entries. Leave "" to use defaults. |
| 1035 | func (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 | |
| 1068 | func (o *Remote) ConnectFetch(callbacks *RemoteCallbacks, proxyOpts *ProxyOptions, headers []string) error { |
| 1069 | return o.Connect(ConnectDirectionFetch, callbacks, proxyOpts, headers) |