diff --git a/src/index.c b/src/index.c index bd7a763..ce47f13 100644 --- a/src/index.c +++ b/src/index.c @@ -222,17 +222,24 @@ Index__find(Index *self, PyObject *py_path) PyDoc_STRVAR(Index_read__doc__, - "read()\n" + "read(force=True)\n" "\n" "Update the contents of an existing index object in memory by reading from\n" - "the hard disk."); + "the hard disk." + "Arguments:\n" + "\n" + "force: if True (the default) allways reload. If False, only if the file has changed" +); PyObject * -Index_read(Index *self) +Index_read(Index *self, PyObject *args) { - int err; + int err, force = 1; - err = git_index_read(self->index); + if (!PyArg_ParseTuple(args, "|i", &force)) + return NULL; + + err = git_index_read(self->index, force); if (err < GIT_OK) return Error_set(err); @@ -427,7 +434,7 @@ PyMethodDef Index_methods[] = { METHOD(Index, diff_to_workdir, METH_VARARGS), METHOD(Index, diff_to_tree, METH_VARARGS), METHOD(Index, _find, METH_O), - METHOD(Index, read, METH_NOARGS), + METHOD(Index, read, METH_VARARGS), METHOD(Index, write, METH_NOARGS), METHOD(Index, read_tree, METH_O), METHOD(Index, write_tree, METH_NOARGS), diff --git a/src/index.h b/src/index.h index 7c63c1c..f38cb4a 100644 --- a/src/index.h +++ b/src/index.h @@ -35,7 +35,7 @@ PyObject* Index_add(Index *self, PyObject *args); PyObject* Index_clear(Index *self); PyObject* Index_find(Index *self, PyObject *py_path); -PyObject* Index_read(Index *self); +PyObject* Index_read(Index *self, PyObject *args); PyObject* Index_write(Index *self); PyObject* Index_iter(Index *self); PyObject* Index_getitem(Index *self, PyObject *value);