From dbf468b2ecb2b66db19f4bfdbaa208dfc8e1c924 Mon Sep 17 00:00:00 2001 From: Nico von Geyso Date: Tue, 20 Nov 2012 21:02:08 +0100 Subject: [PATCH] correct error handling for errors other than GIT_ENOTFOUND --- src/pygit2/config.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/pygit2/config.c b/src/pygit2/config.c index 16a3713..24e98ac 100644 --- a/src/pygit2/config.c +++ b/src/pygit2/config.c @@ -50,18 +50,23 @@ Config_init(Config *self, PyObject *args, PyObject *kwds) if (!PyArg_ParseTuple(args, "s", &path)) { return -1; } + err = git_config_open_ondisk(&self->config, path); - if (err < 0) { - Error_set_exc(PyExc_IOError); - return -1; - } + } else { err = git_config_new(&self->config); - if (err < 0) { - Error_set(err); - return -1; - } } + + if (err < 0) { + if (err == GIT_ENOTFOUND) { + Error_set_exc(PyExc_IOError); + } else { + Error_set(err); + } + + return -1; + } + return 0; }