export remoteCreateCallback
( out **C.git_remote, crepo *C.git_repository, cname, curl *C.char, handle unsafe.Pointer, )
| 54 | |
| 55 | //export remoteCreateCallback |
| 56 | func 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 | |
| 93 | type cloneCallbackData struct { |
| 94 | options *CloneOptions |
nothing calls this directly
no test coverage detected
searching dependent graphs…