Skip to content

Commit 4c47eba

Browse files
committed
Index: adjust to index_read() force flag
1 parent 12ea3d2 commit 4c47eba

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/index.c

+13-6
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,24 @@ Index__find(Index *self, PyObject *py_path)
222222

223223

224224
PyDoc_STRVAR(Index_read__doc__,
225-
"read()\n"
225+
"read(force=True)\n"
226226
"\n"
227227
"Update the contents of an existing index object in memory by reading from\n"
228-
"the hard disk.");
228+
"the hard disk."
229+
"Arguments:\n"
230+
"\n"
231+
"force: if True (the default) allways reload. If False, only if the file has changed"
232+
);
229233

230234
PyObject *
231-
Index_read(Index *self)
235+
Index_read(Index *self, PyObject *args)
232236
{
233-
int err;
237+
int err, force = 1;
238+
239+
if (!PyArg_ParseTuple(args, "|i", &force))
240+
return NULL;
234241

235-
err = git_index_read(self->index);
242+
err = git_index_read(self->index, force);
236243
if (err < GIT_OK)
237244
return Error_set(err);
238245

@@ -427,7 +434,7 @@ PyMethodDef Index_methods[] = {
427434
METHOD(Index, diff_to_workdir, METH_VARARGS),
428435
METHOD(Index, diff_to_tree, METH_VARARGS),
429436
METHOD(Index, _find, METH_O),
430-
METHOD(Index, read, METH_NOARGS),
437+
METHOD(Index, read, METH_VARARGS),
431438
METHOD(Index, write, METH_NOARGS),
432439
METHOD(Index, read_tree, METH_O),
433440
METHOD(Index, write_tree, METH_NOARGS),

src/index.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
PyObject* Index_add(Index *self, PyObject *args);
3636
PyObject* Index_clear(Index *self);
3737
PyObject* Index_find(Index *self, PyObject *py_path);
38-
PyObject* Index_read(Index *self);
38+
PyObject* Index_read(Index *self, PyObject *args);
3939
PyObject* Index_write(Index *self);
4040
PyObject* Index_iter(Index *self);
4141
PyObject* Index_getitem(Index *self, PyObject *value);

0 commit comments

Comments
 (0)