diff options
| author | Carlos MartÃn Nieto <[email protected]> | 2016-10-31 20:04:35 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-10-31 20:04:35 +0100 |
| commit | 3cc21263002095c9f9093439e46f124dd7b7e3de (patch) | |
| tree | 3672a96a0097bf52a99c8cdc8846d14d48b061c5 /remote.go | |
| parent | 42a90d4e68177eb2caad5eb4eed94bf01db308c2 (diff) | |
| parent | 4567e4f7fa621df30e84ee643a27998776919b26 (diff) | |
Merge pull request #319 from netnose/remote-refinements
Remote Refinements
Diffstat (limited to 'remote.go')
| -rw-r--r-- | remote.go | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -215,7 +215,7 @@ func completionCallback(completion_type C.git_remote_completion_type, data unsaf func credentialsCallback(_cred **C.git_cred, _url *C.char, _username_from_url *C.char, allowed_types uint, data unsafe.Pointer) int { callbacks, _ := pointerHandles.Get(data).(*RemoteCallbacks) if callbacks.CredentialsCallback == nil { - return 0 + return C.GIT_PASSTHROUGH } url := C.GoString(_url) username_from_url := C.GoString(_username_from_url) @@ -454,6 +454,26 @@ func (o *Remote) PushUrl() string { return C.GoString(C.git_remote_pushurl(o.ptr)) } +func (c *RemoteCollection) Rename(remote, newname string) ([]string, error) { + cproblems := C.git_strarray{} + defer freeStrarray(&cproblems) + cnewname := C.CString(newname) + defer C.free(unsafe.Pointer(cnewname)) + cremote := C.CString(remote) + defer C.free(unsafe.Pointer(cremote)) + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + ret := C.git_remote_rename(&cproblems, c.repo.ptr, cremote, cnewname) + if ret < 0 { + return []string{}, MakeGitError(ret) + } + + problems := makeStringsFromCStrings(cproblems.strings, int(cproblems.count)) + return problems, nil +} + func (c *RemoteCollection) SetUrl(remote, url string) error { curl := C.CString(url) defer C.free(unsafe.Pointer(curl)) @@ -687,6 +707,13 @@ func (o *Remote) Connect(direction ConnectDirection, callbacks *RemoteCallbacks, return nil } +func (o *Remote) Disconnect() { + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + C.git_remote_disconnect(o.ptr) +} + func (o *Remote) Ls(filterRefs ...string) ([]RemoteHead, error) { var refs **C.git_remote_head |
