Example #1
0
// 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; sig and msg specify what to use for the reflog
// entries. Leave nil and "" to use defaults.
func (o *Remote) Fetch(refspecs []string, sig *Signature, msg string) error {

	var csig *C.git_signature = nil
	if sig != nil {
		csig = sig.toC()
		defer C.free(unsafe.Pointer(csig))
	}

	var cmsg *C.char = nil
	if msg != "" {
		cmsg = C.CString(msg)
		defer C.free(unsafe.Pointer(cmsg))
	}

	crefspecs := C.git_strarray{}
	crefspecs.count = C.size_t(len(refspecs))
	crefspecs.strings = makeCStringsFromStrings(refspecs)
	defer freeStrarray(&crefspecs)

	ret := C.git_remote_fetch(o.ptr, &crefspecs, csig, cmsg)
	if ret < 0 {
		return MakeGitError(ret)
	}
	return nil
}
Example #2
0
// 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.
func (o *Remote) Fetch(refspecs []string, opts *FetchOptions, msg string) error {
	var cmsg *C.char = nil
	if msg != "" {
		cmsg = C.CString(msg)
		defer C.free(unsafe.Pointer(cmsg))
	}

	crefspecs := C.git_strarray{}
	crefspecs.count = C.size_t(len(refspecs))
	crefspecs.strings = makeCStringsFromStrings(refspecs)
	defer freeStrarray(&crefspecs)

	var coptions C.git_fetch_options
	populateFetchOptions(&coptions, opts)
	defer untrackCalbacksPayload(&coptions.callbacks)

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_remote_fetch(o.ptr, &crefspecs, &coptions, cmsg)
	if ret < 0 {
		return MakeGitError(ret)
	}
	return nil
}
Example #3
0
func (o *Remote) Fetch(sig *Signature, msg string) error {

	var csig *C.git_signature = nil
	if sig != nil {
		csig = sig.toC()
		defer C.free(unsafe.Pointer(csig))
	}

	var cmsg *C.char
	if msg == "" {
		cmsg = nil
	} else {
		cmsg = C.CString(msg)
		defer C.free(unsafe.Pointer(cmsg))
	}
	ret := C.git_remote_fetch(o.ptr, csig, cmsg)
	if ret < 0 {
		return MakeGitError(ret)
	}
	return nil
}