Example #1
0
func (v *Reference) Rename(name string, force bool, sig *Signature, msg string) (*Reference, error) {
	var ptr *C.git_reference
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))

	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))
	}

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_reference_rename(&ptr, v.ptr, cname, cbool(force), csig, cmsg)

	if ret < 0 {
		return nil, MakeGitError(ret)
	}

	return newReferenceFromC(ptr), nil
}
Example #2
0
func (v *Reference) Rename(name string, force bool) (*Reference, error) {
	var ptr *C.git_reference
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))

	ret := C.git_reference_rename(&ptr, v.ptr, cname, cbool(force))

	if ret < 0 {
		return nil, LastError()
	}

	return newReferenceFromC(ptr), nil
}
Example #3
0
func (ref *Reference) Rename(newName string, force bool) error {
	cnewName := C.CString(newName)
	defer C.free(unsafe.Pointer(cnewName))
	cforce := C.int(c_FALSE)
	if force {
		cforce = C.int(c_TRUE)
	}
	ecode := C.git_reference_rename(ref.git_reference, cnewName, cforce)
	if ecode != git_SUCCESS {
		return gitError()
	}
	return nil
}