From d1b87efd96b30b8e1fc892a8c791e042676f9a38 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Mon, 27 Oct 2014 08:29:42 -0700 Subject: Add connect methods to Remote. --- remote.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'remote.go') diff --git a/remote.go b/remote.go index 139e71b..a3b4c6c 100644 --- a/remote.go +++ b/remote.go @@ -41,8 +41,8 @@ const ( RemoteCompletionDownload RemoteCompletion = C.GIT_REMOTE_COMPLETION_DOWNLOAD RemoteCompletionIndexing = C.GIT_REMOTE_COMPLETION_INDEXING RemoteCompletionError = C.GIT_REMOTE_COMPLETION_ERROR - - RemoteFetchDirection = C.GIT_DIRECTION_FETCH + RemoteDirectionFetch = C.GIT_DIRECTION_FETCH + RemoteDirectionPush = C.GIT_DIRECTION_PUSH ) type TransportMessageCallback func(str string) int @@ -564,10 +564,25 @@ func (o *Remote) Fetch(refspecs []string, sig *Signature, msg string) error { return nil } -func (o *Remote) Ls(filterRefs ...string) ([]RemoteHead, error) { - if ret := C.git_remote_connect(o.ptr, RemoteFetchDirection); ret != 0 { - return nil, MakeGitError(ret) +func (o *Remote) ConnectFetch() error { + return o.Connect(RemoteDirectionFetch) +} + +func (o *Remote) ConnectPush() error { + return o.Connect(RemoteDirectionPush) +} + +func (o *Remote) Connect(direction C.git_direction) error { + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + if ret := C.git_remote_connect(o.ptr, direction); ret != 0 { + return MakeGitError(ret) } + return nil +} + +func (o *Remote) Ls(filterRefs ...string) ([]RemoteHead, error) { var refs **C.git_remote_head var length C.size_t -- cgit v1.2.3