Пример #1
0
func (b *Branch) Move(newBranchName string, force bool, signature *Signature, msg string) (*Branch, error) {
	var ptr *C.git_reference
	cNewBranchName := C.CString(newBranchName)
	cForce := cbool(force)

	cSignature, err := signature.toC()
	if err != nil {
		return nil, err
	}
	defer C.git_signature_free(cSignature)

	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_branch_move(&ptr, b.Reference.ptr, cNewBranchName, cForce, cSignature, cmsg)
	if ret < 0 {
		return nil, MakeGitError(ret)
	}
	return newReferenceFromC(ptr, b.repo).Branch(), nil
}
Пример #2
0
func (b *Branch) Move(newBranchName string, force bool, signature *Signature, msg string) (*Branch, error) {
	newBranch := new(Branch)
	cNewBranchName := C.CString(newBranchName)
	cForce := cbool(force)

	cSignature := signature.toC()
	defer C.git_signature_free(cSignature)

	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_branch_move(&newBranch.ptr, b.ptr, cNewBranchName, cForce, cSignature, cmsg)
	if ret < 0 {
		return nil, MakeGitError(ret)
	}
	return newBranch, nil
}
Пример #3
0
func (b *Branch) Move(newBranchName string, force bool) (*Branch, error) {
	var ptr *C.git_reference
	cNewBranchName := C.CString(newBranchName)
	defer C.free(unsafe.Pointer(cNewBranchName))
	cForce := cbool(force)

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_branch_move(&ptr, b.Reference.ptr, cNewBranchName, cForce)
	if ret < 0 {
		return nil, MakeGitError(ret)
	}
	return newReferenceFromC(ptr, b.repo).Branch(), nil
}
Пример #4
0
func (repo *Repository) MoveBranch(oldName, newName string, force bool) error {
	coldName := C.CString(oldName)
	defer C.free(unsafe.Pointer(coldName))
	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_branch_move(repo.git_repository, coldName, cnewName, cforce)
	if ecode != git_SUCCESS {
		return gitError()
	}
	return nil
}