summaryrefslogtreecommitdiff
path: root/reference.go
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2020-12-10 05:35:40 -0800
committerGitHub <[email protected]>2020-12-10 05:35:40 -0800
commite28cce87c7551bffa1f4602ff492348f9a8cba60 (patch)
tree17cda66f878bd6285f24d0867c444e9ca2e191e6 /reference.go
parentabf02bc7d79dfb7b0bbcd404ebecb202cff2a18e (diff)
Ensure that no pointer handles leak during the test (#712)
This change makes sure that pointer handles are correctly cleaned up during tests.
Diffstat (limited to 'reference.go')
-rw-r--r--reference.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/reference.go b/reference.go
index 524d7bb..e0c7cad 100644
--- a/reference.go
+++ b/reference.go
@@ -293,12 +293,14 @@ func (v *Reference) Peel(t ObjectType) (*Object, error) {
return allocObject(cobj, v.repo), nil
}
-// Owner returns a weak reference to the repository which owns this
-// reference.
+// Owner returns a weak reference to the repository which owns this reference.
+// This won't keep the underlying repository alive, but it should still be
+// Freed.
func (v *Reference) Owner() *Repository {
- return &Repository{
- ptr: C.git_reference_owner(v.ptr),
- }
+ repo := newRepositoryFromC(C.git_reference_owner(v.ptr))
+ runtime.KeepAlive(v)
+ repo.weak = true
+ return repo
}
// Cmp compares v to ref2. It returns 0 on equality, otherwise a