parent
9cd1d129bc
commit
b3a160b0f8
12
remote.go
12
remote.go
|
@ -38,14 +38,14 @@ const (
|
||||||
RemoteCompletionError = C.GIT_REMOTE_COMPLETION_ERROR
|
RemoteCompletionError = C.GIT_REMOTE_COMPLETION_ERROR
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProgressCallback func(str string) int
|
type TransportMessageCallback func(str string) int
|
||||||
type CompletionCallback func(RemoteCompletion) int
|
type CompletionCallback func(RemoteCompletion) int
|
||||||
type CredentialsCallback func(url string, username_from_url string, allowed_types CredType) (int, *Cred)
|
type CredentialsCallback func(url string, username_from_url string, allowed_types CredType) (int, *Cred)
|
||||||
type TransferProgressCallback func(stats TransferProgress) int
|
type TransferProgressCallback func(stats TransferProgress) int
|
||||||
type UpdateTipsCallback func(refname string, a *Oid, b *Oid) int
|
type UpdateTipsCallback func(refname string, a *Oid, b *Oid) int
|
||||||
|
|
||||||
type RemoteCallbacks struct {
|
type RemoteCallbacks struct {
|
||||||
ProgressCallback
|
SidebandProgressCallback TransportMessageCallback
|
||||||
CompletionCallback
|
CompletionCallback
|
||||||
CredentialsCallback
|
CredentialsCallback
|
||||||
TransferProgressCallback
|
TransferProgressCallback
|
||||||
|
@ -65,14 +65,14 @@ func populateRemoteCallbacks(ptr *C.git_remote_callbacks, callbacks *RemoteCallb
|
||||||
ptr.payload = unsafe.Pointer(callbacks)
|
ptr.payload = unsafe.Pointer(callbacks)
|
||||||
}
|
}
|
||||||
|
|
||||||
//export progressCallback
|
//export sidebandProgressCallback
|
||||||
func progressCallback(_str *C.char, _len C.int, data unsafe.Pointer) int {
|
func sidebandProgressCallback(_str *C.char, _len C.int, data unsafe.Pointer) int {
|
||||||
callbacks := (*RemoteCallbacks)(data)
|
callbacks := (*RemoteCallbacks)(data)
|
||||||
if callbacks.ProgressCallback == nil {
|
if callbacks.SidebandProgressCallback == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
str := C.GoStringN(_str, _len)
|
str := C.GoStringN(_str, _len)
|
||||||
return callbacks.ProgressCallback(str)
|
return callbacks.SidebandProgressCallback(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
//export completionCallback
|
//export completionCallback
|
||||||
|
|
|
@ -26,12 +26,11 @@ int _go_git_odb_foreach(git_odb *db, void *payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
void _go_git_setup_callbacks(git_remote_callbacks *callbacks) {
|
void _go_git_setup_callbacks(git_remote_callbacks *callbacks) {
|
||||||
typedef int (*progress_cb)(const char *str, int len, void *data);
|
|
||||||
typedef int (*completion_cb)(git_remote_completion_type type, void *data);
|
typedef int (*completion_cb)(git_remote_completion_type type, void *data);
|
||||||
typedef int (*credentials_cb)(git_cred **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *data);
|
typedef int (*credentials_cb)(git_cred **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *data);
|
||||||
typedef int (*transfer_progress_cb)(const git_transfer_progress *stats, void *data);
|
typedef int (*transfer_progress_cb)(const git_transfer_progress *stats, void *data);
|
||||||
typedef int (*update_tips_cb)(const char *refname, const git_oid *a, const git_oid *b, void *data);
|
typedef int (*update_tips_cb)(const char *refname, const git_oid *a, const git_oid *b, void *data);
|
||||||
callbacks->progress = (progress_cb)progressCallback;
|
callbacks->sideband_progress = (git_transport_message_cb)sidebandProgressCallback;
|
||||||
callbacks->completion = (completion_cb)completionCallback;
|
callbacks->completion = (completion_cb)completionCallback;
|
||||||
callbacks->credentials = (credentials_cb)credentialsCallback;
|
callbacks->credentials = (credentials_cb)credentialsCallback;
|
||||||
callbacks->transfer_progress = (transfer_progress_cb)transferProgressCallback;
|
callbacks->transfer_progress = (transfer_progress_cb)transferProgressCallback;
|
||||||
|
|
Loading…
Reference in New Issue