summaryrefslogtreecommitdiff
path: root/branch.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2015-06-09 11:27:44 +0200
committerCarlos Martín Nieto <[email protected]>2015-06-09 11:27:44 +0200
commit53fd8ea011483ce70a16332d877d6efd5bafb369 (patch)
treec70f21fc2e3a99ad58cb1bfec112e7733fb1642a /branch.go
parentaefe85039e3a5c8d09d3ced41978dfcf088a6031 (diff)
parent830e1714632ad87a42008327badb9a481ff1c37e (diff)
Merge pull request #211 from shinningstar/master
Free reference resource allocated by libgit2 during go garbage collecting
Diffstat (limited to 'branch.go')
-rw-r--r--branch.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/branch.go b/branch.go
index 22b767e..42e1216 100644
--- a/branch.go
+++ b/branch.go
@@ -92,7 +92,7 @@ func (repo *Repository) NewBranchIterator(flags BranchType) (*BranchIterator, er
func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool, signature *Signature, msg string) (*Branch, error) {
- ref := new(Reference)
+ var ptr *C.git_reference
cBranchName := C.CString(branchName)
cForce := cbool(force)
@@ -113,11 +113,11 @@ func (repo *Repository) CreateBranch(branchName string, target *Commit, force bo
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- ret := C.git_branch_create(&ref.ptr, repo.ptr, cBranchName, target.cast_ptr, cForce, cSignature, cmsg)
+ ret := C.git_branch_create(&ptr, repo.ptr, cBranchName, target.cast_ptr, cForce, cSignature, cmsg)
if ret < 0 {
return nil, MakeGitError(ret)
}
- return ref.Branch(), nil
+ return newReferenceFromC(ptr, repo).Branch(), nil
}
func (b *Branch) Delete() error {