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:
J. David Ibáñez 2012-01-02 19:42:49 +01:00
parent 4a33c7f806
commit 35ed84cf44
2 changed files with 14 additions and 17 deletions

@ -548,24 +548,20 @@ Repository_get_index(Repository *self, void *closure)
if (self->index == NULL) {
err = git_repository_index(&index, self->repo);
if (err == GIT_SUCCESS) {
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 {
if (err < 0)
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);

@ -43,7 +43,8 @@ __author__ = 'jdavid@itaapy.com (J. David Ibáñez)'
class IndexBareTest(utils.BareRepoTestCase):
def test_bare(self):
self.assertEqual(None, self.repo.index)
index = self.repo.index
self.assertEqual(len(index), 0)
class IndexTest(utils.RepoTestCase):