From b6811196e4f7728b25ab37ce2a0862aa74c22253 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Tue, 30 Jun 2015 19:08:29 +0200 Subject: Clone: test we clone something usable and fix constructor Clone was still trying to do its own initialisation, which was missing all of the namespacing changes. --- clone.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'clone.go') diff --git a/clone.go b/clone.go index f67f511..b5c5a5b 100644 --- a/clone.go +++ b/clone.go @@ -20,8 +20,6 @@ type CloneOptions struct { } func Clone(url string, path string, options *CloneOptions) (*Repository, error) { - repo := new(Repository) - curl := C.CString(url) defer C.free(unsafe.Pointer(curl)) @@ -37,7 +35,8 @@ func Clone(url string, path string, options *CloneOptions) (*Repository, error) runtime.LockOSThread() defer runtime.UnlockOSThread() - ret := C.git_clone(&repo.ptr, curl, cpath, copts) + var ptr *C.git_repository + ret := C.git_clone(&ptr, curl, cpath, copts) freeCheckoutOpts(&copts.checkout_opts) C.free(unsafe.Pointer(copts.checkout_branch)) C.free(unsafe.Pointer(copts)) @@ -46,8 +45,7 @@ func Clone(url string, path string, options *CloneOptions) (*Repository, error) return nil, MakeGitError(ret) } - runtime.SetFinalizer(repo, (*Repository).Free) - return repo, nil + return newRepositoryFromC(ptr), nil } func populateCloneOptions(ptr *C.git_clone_options, opts *CloneOptions) { -- cgit v1.2.3