diff options
Diffstat (limited to 'remote.go')
| -rw-r--r-- | remote.go | 32 |
1 files changed, 26 insertions, 6 deletions
@@ -38,14 +38,14 @@ const ( RemoteCompletionError = C.GIT_REMOTE_COMPLETION_ERROR ) -type ProgressCallback func(str string) int +type TransportMessageCallback func(str string) int type CompletionCallback func(RemoteCompletion) int type CredentialsCallback func(url string, username_from_url string, allowed_types CredType) (int, *Cred) type TransferProgressCallback func(stats TransferProgress) int type UpdateTipsCallback func(refname string, a *Oid, b *Oid) int type RemoteCallbacks struct { - ProgressCallback + SidebandProgressCallback TransportMessageCallback CompletionCallback CredentialsCallback TransferProgressCallback @@ -65,14 +65,14 @@ func populateRemoteCallbacks(ptr *C.git_remote_callbacks, callbacks *RemoteCallb ptr.payload = unsafe.Pointer(callbacks) } -//export progressCallback -func progressCallback(_str *C.char, _len C.int, data unsafe.Pointer) int { +//export sidebandProgressCallback +func sidebandProgressCallback(_str *C.char, _len C.int, data unsafe.Pointer) int { callbacks := (*RemoteCallbacks)(data) - if callbacks.ProgressCallback == nil { + if callbacks.SidebandProgressCallback == nil { return 0 } str := C.GoStringN(_str, _len) - return callbacks.ProgressCallback(str) + return callbacks.SidebandProgressCallback(str) } //export completionCallback @@ -127,6 +127,26 @@ func RemoteIsValidName(name string) bool { return false } +func (r *Remote) SetCheckCert(check bool) { + C.git_remote_check_cert(r.ptr, cbool(check)) +} + +func (r *Remote) SetCallbacks(callbacks *RemoteCallbacks) error { + var ccallbacks C.git_remote_callbacks + + populateRemoteCallbacks(&ccallbacks, callbacks) + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + ecode := C.git_remote_set_callbacks(r.ptr, &ccallbacks) + if ecode < 0 { + return MakeGitError(ecode) + } + + return nil +} + func (r *Remote) Free() { runtime.SetFinalizer(r, nil) C.git_remote_free(r.ptr) |
