Update to latest changes in libgit2
Now Repository.index also works on bare repositories. Unit tests pass again. And fix a memory leak (add a call to git_index_free).
This commit is contained in:
28
pygit2.c
28
pygit2.c
@@ -548,24 +548,20 @@ Repository_get_index(Repository *self, void *closure)
|
|||||||
|
|
||||||
if (self->index == NULL) {
|
if (self->index == NULL) {
|
||||||
err = git_repository_index(&index, self->repo);
|
err = git_repository_index(&index, self->repo);
|
||||||
if (err == GIT_SUCCESS) {
|
if (err < 0)
|
||||||
py_index = PyObject_GC_New(Index, &IndexType);
|
|
||||||
if (!py_index)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
Py_INCREF(self);
|
|
||||||
py_index->repo = self;
|
|
||||||
py_index->index = index;
|
|
||||||
PyObject_GC_Track(py_index);
|
|
||||||
self->index = (PyObject*)py_index;
|
|
||||||
}
|
|
||||||
else if (err == GIT_EBAREINDEX) {
|
|
||||||
Py_INCREF(Py_None);
|
|
||||||
self->index = Py_None;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Error_set(err);
|
return Error_set(err);
|
||||||
|
|
||||||
|
py_index = PyObject_GC_New(Index, &IndexType);
|
||||||
|
if (!py_index) {
|
||||||
|
git_index_free(index);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Py_INCREF(self);
|
||||||
|
py_index->repo = self;
|
||||||
|
py_index->index = index;
|
||||||
|
PyObject_GC_Track(py_index);
|
||||||
|
self->index = (PyObject*)py_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(self->index);
|
Py_INCREF(self->index);
|
||||||
|
@@ -43,7 +43,8 @@ __author__ = 'jdavid@itaapy.com (J. David Ibáñez)'
|
|||||||
class IndexBareTest(utils.BareRepoTestCase):
|
class IndexBareTest(utils.BareRepoTestCase):
|
||||||
|
|
||||||
def test_bare(self):
|
def test_bare(self):
|
||||||
self.assertEqual(None, self.repo.index)
|
index = self.repo.index
|
||||||
|
self.assertEqual(len(index), 0)
|
||||||
|
|
||||||
|
|
||||||
class IndexTest(utils.RepoTestCase):
|
class IndexTest(utils.RepoTestCase):
|
||||||
|
Reference in New Issue
Block a user