예제 #1
0
파일: branch.go 프로젝트: jezell/git2go
func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool, signature *Signature, msg string) (*Branch, error) {

	ref := new(Reference)
	cBranchName := C.CString(branchName)
	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_create(&ref.ptr, repo.ptr, cBranchName, target.cast_ptr, cForce, cSignature, cmsg)
	if ret < 0 {
		return nil, MakeGitError(ret)
	}
	return ref.Branch(), nil
}
예제 #2
0
파일: branch.go 프로젝트: jgrocho/go-git2
func (repo *Repository) CreateBranch(name string, target *Object, force bool) (*Oid, error) {
	oid := new(Oid)
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	cforce := C.int(c_FALSE)
	if force {
		cforce = C.int(c_TRUE)
	}
	ecode := C.git_branch_create(oid.git_oid, repo.git_repository, cname, target.git_object, cforce)
	if ecode != git_SUCCESS {
		return nil, gitError()
	}
	return oid, nil
}
예제 #3
0
파일: branch.go 프로젝트: wid/git2go
func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool) (*Branch, error) {

	var ptr *C.git_reference
	cBranchName := C.CString(branchName)
	defer C.free(unsafe.Pointer(cBranchName))
	cForce := cbool(force)

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_branch_create(&ptr, repo.ptr, cBranchName, target.cast_ptr, cForce)
	if ret < 0 {
		return nil, MakeGitError(ret)
	}
	return newReferenceFromC(ptr, repo).Branch(), nil
}