Adjust to options changes

We can now use a git_buf to extract the search path.
This commit is contained in:
Carlos Martín Nieto
2014-04-01 19:56:10 +02:00
parent 55037c23a3
commit 114e300b08

View File

@@ -37,35 +37,16 @@ extern PyObject *GitError;
static PyObject * static PyObject *
get_search_path(long level) get_search_path(long level)
{ {
char *buf = NULL; git_buf buf = {NULL};
size_t len = 64;
PyObject *py_path; PyObject *py_path;
int error; int err;
do { err = git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, level, &buf);
len *= 2; if (err < 0)
char *tmp = realloc(buf, len); return Error_set(err);
if (!tmp) {
free(buf);
PyErr_NoMemory();
return NULL;
}
buf = tmp;
error = git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, level, buf, len); py_path = to_unicode(buf.ptr, NULL, NULL);
} while(error == GIT_EBUFS); git_buf_free(&buf);
if (error < 0) {
free(buf);
Error_set(error);
return NULL;
}
if (!buf)
return NULL;
py_path = to_unicode(buf, NULL, NULL);
free(buf);
if (!py_path) if (!py_path)
return NULL; return NULL;