Drop Remote_init.
This commit is contained in:
50
src/remote.c
50
src/remote.c
@@ -461,45 +461,6 @@ update_tips_cb(const char *refname, const git_oid *a, const git_oid *b, void *da
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
|
||||||
Remote_init(Remote *self, PyObject *args, PyObject *kwds)
|
|
||||||
{
|
|
||||||
Repository* py_repo = NULL;
|
|
||||||
char *name = NULL;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O!s", &RepositoryType, &py_repo, &name))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
self->repo = py_repo;
|
|
||||||
Py_INCREF(self->repo);
|
|
||||||
err = git_remote_load(&self->remote, py_repo->repo, name);
|
|
||||||
|
|
||||||
if (err < 0)
|
|
||||||
return Error_set(err);
|
|
||||||
|
|
||||||
self->progress = NULL;
|
|
||||||
self->transfer_progress = NULL;
|
|
||||||
self->update_tips = NULL;
|
|
||||||
|
|
||||||
Remote_set_callbacks(self);
|
|
||||||
return (PyObject*) self;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Remote_set_callbacks(Remote *self)
|
|
||||||
{
|
|
||||||
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
|
||||||
|
|
||||||
self->progress = NULL;
|
|
||||||
|
|
||||||
callbacks.progress = progress_cb;
|
|
||||||
callbacks.transfer_progress = transfer_progress_cb;
|
|
||||||
callbacks.update_tips = update_tips_cb;
|
|
||||||
callbacks.payload = self;
|
|
||||||
git_remote_set_callbacks(self->remote, &callbacks);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Remote_dealloc(Remote *self)
|
Remote_dealloc(Remote *self)
|
||||||
{
|
{
|
||||||
@@ -1077,7 +1038,7 @@ PyTypeObject RemoteType = {
|
|||||||
0, /* tp_descr_get */
|
0, /* tp_descr_get */
|
||||||
0, /* tp_descr_set */
|
0, /* tp_descr_set */
|
||||||
0, /* tp_dictoffset */
|
0, /* tp_dictoffset */
|
||||||
(initproc)Remote_init, /* tp_init */
|
0, /* tp_init */
|
||||||
0, /* tp_alloc */
|
0, /* tp_alloc */
|
||||||
0, /* tp_new */
|
0, /* tp_new */
|
||||||
};
|
};
|
||||||
@@ -1086,6 +1047,8 @@ PyObject *
|
|||||||
wrap_remote(git_remote *c_remote, Repository *repo)
|
wrap_remote(git_remote *c_remote, Repository *repo)
|
||||||
{
|
{
|
||||||
Remote *py_remote = NULL;
|
Remote *py_remote = NULL;
|
||||||
|
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
||||||
|
|
||||||
py_remote = PyObject_New(Remote, &RemoteType);
|
py_remote = PyObject_New(Remote, &RemoteType);
|
||||||
if (py_remote) {
|
if (py_remote) {
|
||||||
Py_INCREF(repo);
|
Py_INCREF(repo);
|
||||||
@@ -1094,7 +1057,12 @@ wrap_remote(git_remote *c_remote, Repository *repo)
|
|||||||
py_remote->progress = NULL;
|
py_remote->progress = NULL;
|
||||||
py_remote->transfer_progress = NULL;
|
py_remote->transfer_progress = NULL;
|
||||||
py_remote->update_tips = NULL;
|
py_remote->update_tips = NULL;
|
||||||
Remote_set_callbacks(py_remote);
|
|
||||||
|
callbacks.progress = progress_cb;
|
||||||
|
callbacks.transfer_progress = transfer_progress_cb;
|
||||||
|
callbacks.update_tips = update_tips_cb;
|
||||||
|
callbacks.payload = py_remote;
|
||||||
|
git_remote_set_callbacks(c_remote, &callbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (PyObject *)py_remote;
|
return (PyObject *)py_remote;
|
||||||
|
@@ -33,7 +33,6 @@
|
|||||||
#include <git2.h>
|
#include <git2.h>
|
||||||
#include <git2/remote.h>
|
#include <git2/remote.h>
|
||||||
|
|
||||||
PyObject* Remote_init(Remote *self, PyObject *args, PyObject *kwds);
|
|
||||||
PyObject* Remote_fetch(Remote *self, PyObject *args);
|
PyObject* Remote_fetch(Remote *self, PyObject *args);
|
||||||
|
|
||||||
void Remote_set_callbacks(Remote *self);
|
void Remote_set_callbacks(Remote *self);
|
||||||
|
@@ -1301,7 +1301,8 @@ Repository_remotes__get__(Repository *self)
|
|||||||
{
|
{
|
||||||
git_strarray remotes;
|
git_strarray remotes;
|
||||||
git_remote *remote = NULL;
|
git_remote *remote = NULL;
|
||||||
PyObject* py_list = NULL, *py_args = NULL;
|
PyObject *py_list = NULL;
|
||||||
|
PyObject *py_remote = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@@ -1311,13 +1312,23 @@ Repository_remotes__get__(Repository *self)
|
|||||||
for (i=0; i < remotes.count; ++i) {
|
for (i=0; i < remotes.count; ++i) {
|
||||||
err = git_remote_load(&remote, self->repo, remotes.strings[i]);
|
err = git_remote_load(&remote, self->repo, remotes.strings[i]);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return Error_set(err);
|
goto cleanup;
|
||||||
PyList_SetItem(py_list, i, wrap_remote(remote, self));
|
py_remote = wrap_remote(remote, self);
|
||||||
|
if (py_remote == NULL)
|
||||||
|
goto cleanup;
|
||||||
|
PyList_SetItem(py_list, i, py_remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
git_strarray_free(&remotes);
|
git_strarray_free(&remotes);
|
||||||
|
|
||||||
return (PyObject*) py_list;
|
return (PyObject*) py_list;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
git_strarray_free(&remotes);
|
||||||
|
if (py_list)
|
||||||
|
Py_DECREF(py_list);
|
||||||
|
if (err < 0)
|
||||||
|
return Error_set(err);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(Repository_default_signature__doc__, "Return the signature according to the repository's configuration");
|
PyDoc_STRVAR(Repository_default_signature__doc__, "Return the signature according to the repository's configuration");
|
||||||
|
Reference in New Issue
Block a user