MCPcopy Create free account
hub / github.com/libgit2/git2go / Clone

Function Clone

clone.go:24–53  ·  view source on GitHub ↗
(url string, path string, options *CloneOptions)

Source from the content-addressed store, hash-verified

22}
23
24func Clone(url string, path string, options *CloneOptions) (*Repository, error) {
25 curl := C.CString(url)
26 defer C.free(unsafe.Pointer(curl))
27
28 cpath := C.CString(path)
29 defer C.free(unsafe.Pointer(cpath))
30
31 var err error
32 cOptions := populateCloneOptions(&C.git_clone_options{}, options, &err)
33 defer freeCloneOptions(cOptions)
34
35 if len(options.CheckoutBranch) != 0 {
36 cOptions.checkout_branch = C.CString(options.CheckoutBranch)
37 }
38
39 runtime.LockOSThread()
40 defer runtime.UnlockOSThread()
41
42 var ptr *C.git_repository
43 ret := C.git_clone(&ptr, curl, cpath, cOptions)
44
45 if ret == C.int(ErrorCodeUser) && err != nil {
46 return nil, err
47 }
48 if ret < 0 {
49 return nil, MakeGitError(ret)
50 }
51
52 return newRepositoryFromC(ptr), nil
53}
54
55//export remoteCreateCallback
56func remoteCreateCallback(

Callers 3

TestCloneFunction · 0.85
TestCloneWithCallbackFunction · 0.85

Calls 5

populateCloneOptionsFunction · 0.85
freeCloneOptionsFunction · 0.85
MakeGitErrorFunction · 0.85
newRepositoryFromCFunction · 0.85
freeMethod · 0.80

Tested by 3

TestCloneFunction · 0.68
TestCloneWithCallbackFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…