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

Function remoteCreateCallback

clone.go:56–91  ·  view source on GitHub ↗

export remoteCreateCallback

(
	out **C.git_remote,
	crepo *C.git_repository,
	cname, curl *C.char,
	handle unsafe.Pointer,
)

Source from the content-addressed store, hash-verified

54
55//export remoteCreateCallback
56func remoteCreateCallback(
57 out **C.git_remote,
58 crepo *C.git_repository,
59 cname, curl *C.char,
60 handle unsafe.Pointer,
61) C.int {
62 name := C.GoString(cname)
63 url := C.GoString(curl)
64 repo := newRepositoryFromC(crepo)
65 repo.weak = true
66 defer repo.Free()
67
68 data, ok := pointerHandles.Get(handle).(*cloneCallbackData)
69 if !ok {
70 panic("invalid remote create callback")
71 }
72
73 remote, err := data.options.RemoteCreateCallback(repo, name, url)
74
75 if err != nil {
76 *data.errorTarget = err
77 return C.int(ErrorCodeUser)
78 }
79 if remote == nil {
80 panic("no remote created by callback")
81 }
82
83 *out = remote.ptr
84
85 // clear finalizer as the calling C function will
86 // free the remote itself
87 runtime.SetFinalizer(remote, nil)
88 remote.repo.Remotes.untrackRemote(remote)
89
90 return C.int(ErrorCodeOK)
91}
92
93type cloneCallbackData struct {
94 options *CloneOptions

Callers

nothing calls this directly

Calls 4

newRepositoryFromCFunction · 0.85
GetMethod · 0.80
untrackRemoteMethod · 0.80
FreeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…