From 2942e18d056d725aa847d77492a75391a670de5f Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Sun, 25 May 2014 09:06:18 +0200 Subject: Give Object and Reference an Onwer accessor This reduces the need to carry around a pointer to the repository as well as the objects. --- reference.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'reference.go') diff --git a/reference.go b/reference.go index 8c8b282..9a2a8e5 100644 --- a/reference.go +++ b/reference.go @@ -161,6 +161,14 @@ func (v *Reference) Peel(t ObjectType) (Object, error) { return allocObject(cobj), nil } +// Owner returns a weak reference to the repository which owns this +// reference. +func (v *Reference) Owner() *Repository { + return &Repository{ + ptr: C.git_reference_owner(v.ptr), + } +} + // Cmp compares both references, retursn 0 on equality, otherwise a // stable sorting. func (v *Reference) Cmp(ref2 *Reference) int { -- cgit v1.2.3