Make pygit2 build against new libgit2 API
Now Tree.add_entry returns the created entry.
This commit is contained in:
11
pygit2.c
11
pygit2.c
@@ -933,23 +933,24 @@ Tree_delitem(Tree *self, PyObject *name, PyObject *value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static TreeEntry *
|
||||||
Tree_add_entry(Tree *self, PyObject *args) {
|
Tree_add_entry(Tree *self, PyObject *args) {
|
||||||
PyObject *py_sha;
|
PyObject *py_sha;
|
||||||
char *name;
|
char *name;
|
||||||
int attributes, err;
|
int attributes, err;
|
||||||
git_oid oid;
|
git_oid oid;
|
||||||
|
git_tree_entry *entry = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "Osi", &py_sha, &name, &attributes))
|
if (!PyArg_ParseTuple(args, "Osi", &py_sha, &name, &attributes))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
err = py_str_to_git_oid(py_sha, &oid);
|
err = py_str_to_git_oid(py_sha, &oid);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return Error_set_py_obj(err, py_sha);
|
return (TreeEntry*)Error_set_py_obj(err, py_sha);
|
||||||
|
|
||||||
if (git_tree_add_entry(self->tree, &oid, name, attributes) < 0)
|
if (git_tree_add_entry(&entry, self->tree, &oid, name, attributes) < 0)
|
||||||
return PyErr_NoMemory();
|
return (TreeEntry*)PyErr_NoMemory();
|
||||||
Py_RETURN_NONE;
|
return wrap_tree_entry(entry, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef Tree_methods[] = {
|
static PyMethodDef Tree_methods[] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user