summaryrefslogtreecommitdiff
path: root/clone.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2015-06-28 01:32:13 +0200
committerCarlos Martín Nieto <[email protected]>2015-06-28 01:32:13 +0200
commite50203a2531209d32fab9d9b5fea3ff55c873c86 (patch)
tree782cd6f6816aec27707f2b84df4471e9a6983440 /clone.go
parent70c95a7655eddffda4cd8fddd87536c5580136fe (diff)
parent2488de286c0f73b31e95820835767adc3d2ee101 (diff)
Merge remote-tracking branch 'upstream/master' into next
Conflicts: branch.go
Diffstat (limited to 'clone.go')
-rw-r--r--clone.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/clone.go b/clone.go
index 233300d..f67f511 100644
--- a/clone.go
+++ b/clone.go
@@ -28,18 +28,20 @@ func Clone(url string, path string, options *CloneOptions) (*Repository, error)
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
- var copts C.git_clone_options
- populateCloneOptions(&copts, options)
- defer freeCheckoutOpts(&copts.checkout_opts)
+ copts := (*C.git_clone_options)(C.calloc(1, C.size_t(unsafe.Sizeof(C.git_clone_options{}))))
+ populateCloneOptions(copts, options)
if len(options.CheckoutBranch) != 0 {
copts.checkout_branch = C.CString(options.CheckoutBranch)
- defer C.free(unsafe.Pointer(copts.checkout_branch))
}
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- ret := C.git_clone(&repo.ptr, curl, cpath, &copts)
+ ret := C.git_clone(&repo.ptr, curl, cpath, copts)
+ freeCheckoutOpts(&copts.checkout_opts)
+ C.free(unsafe.Pointer(copts.checkout_branch))
+ C.free(unsafe.Pointer(copts))
+
if ret < 0 {
return nil, MakeGitError(ret)
}