summaryrefslogtreecommitdiff
path: root/reference.go
diff options
context:
space:
mode:
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