From f69a57a82a05c161511cb4f651aa231dd6e05ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 27 May 2014 18:10:06 +0200 Subject: [PATCH] Index: make the file optional There is no obligation for an index to exist as a file at all. --- src/index.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.c b/src/index.c index 7269749..0cb8207 100644 --- a/src/index.c +++ b/src/index.c @@ -45,7 +45,7 @@ extern PyTypeObject RepositoryType; int Index_init(Index *self, PyObject *args, PyObject *kwds) { - char *path; + char *path = NULL; int err; if (kwds && PyDict_Size(kwds) > 0) { @@ -53,9 +53,10 @@ Index_init(Index *self, PyObject *args, PyObject *kwds) return -1; } - if (!PyArg_ParseTuple(args, "s", &path)) + if (!PyArg_ParseTuple(args, "|s", &path)) return -1; + self->repo = NULL; err = git_index_open(&self->index, path); if (err < 0) { Error_set_str(err, path);