MCPcopy Create free account
hub / github.com/libgit2/git2go / CreateBranch

Method CreateBranch

branch.go:101–118  ·  view source on GitHub ↗
(branchName string, target *Commit, force bool)

Source from the content-addressed store, hash-verified

99}
100
101func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool) (*Branch, error) {
102
103 var ptr *C.git_reference
104 cBranchName := C.CString(branchName)
105 defer C.free(unsafe.Pointer(cBranchName))
106 cForce := cbool(force)
107
108 runtime.LockOSThread()
109 defer runtime.UnlockOSThread()
110
111 ret := C.git_branch_create(&ptr, repo.ptr, cBranchName, target.cast_ptr, cForce)
112 runtime.KeepAlive(repo)
113 runtime.KeepAlive(target)
114 if ret < 0 {
115 return nil, MakeGitError(ret)
116 }
117 return newReferenceFromC(ptr, repo).Branch(), nil
118}
119
120func (b *Branch) Delete() error {
121

Callers 3

TestRemotePruneFunction · 0.80
createBranchFunction · 0.80
TestDescribeCommitFunction · 0.80

Calls 5

cboolFunction · 0.85
MakeGitErrorFunction · 0.85
newReferenceFromCFunction · 0.85
freeMethod · 0.80
BranchMethod · 0.80

Tested by 3

TestRemotePruneFunction · 0.64
createBranchFunction · 0.64
TestDescribeCommitFunction · 0.64