Adjust to options changes
We can now use a git_buf to extract the search path.
This commit is contained in:
@@ -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;
|
||||||
|
Reference in New Issue
Block a user