From 8a73c75f1a68f2855d03e6d2ce45c95c414aa71a Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Mon, 26 May 2014 09:28:07 +0200 Subject: Keep a pointer to the repository in the objects and references Otherwise, the garbage collector might decide it's a good idea to throw away the repository instance while the C object still has a pointer to it. Hilarity ensues. --- branch.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'branch.go') diff --git a/branch.go b/branch.go index af21140..a179f75 100644 --- a/branch.go +++ b/branch.go @@ -57,7 +57,7 @@ func (i *BranchIterator) Next() (*Branch, BranchType, error) { return nil, BranchLocal, MakeGitError(ecode) } - branch := newReferenceFromC(refPtr).Branch() + branch := newReferenceFromC(refPtr, i.repo).Branch() return branch, BranchType(refType), nil } @@ -144,7 +144,7 @@ func (b *Branch) Move(newBranchName string, force bool, signature *Signature, ms if ret < 0 { return nil, MakeGitError(ret) } - return newReferenceFromC(ptr).Branch(), nil + return newReferenceFromC(ptr, b.repo).Branch(), nil } func (b *Branch) IsHead() (bool, error) { @@ -175,7 +175,7 @@ func (repo *Repository) LookupBranch(branchName string, bt BranchType) (*Branch, if ret < 0 { return nil, MakeGitError(ret) } - return newReferenceFromC(ptr).Branch(), nil + return newReferenceFromC(ptr, repo).Branch(), nil } func (b *Branch) Name() (string, error) { @@ -233,7 +233,7 @@ func (b *Branch) Upstream() (*Reference, error) { if ret < 0 { return nil, MakeGitError(ret) } - return newReferenceFromC(ptr), nil + return newReferenceFromC(ptr, b.repo), nil } func (repo *Repository) UpstreamName(canonicalBranchName string) (string, error) { -- cgit v1.2.3