(url string, path string, options *CloneOptions)
| 22 | } |
| 23 | |
| 24 | func 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 |
| 56 | func remoteCreateCallback( |
searching dependent graphs…