Skip to content

Commit 178cec2

Browse files
imbuedhopewebknjaz
authored andcommitted
Add hooks for GIT_OPT_SET_SSL_CERT_LOCATIONS in C
Bind them to git_libgit2_opts
1 parent f483622 commit 178cec2

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/options.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,36 @@ option(PyObject *self, PyObject *args)
272272
return tup;
273273
}
274274

275+
case GIT_OPT_SET_SSL_CERT_LOCATIONS:
276+
{
277+
PyObject *py_file, *py_dir;
278+
const char *file_path, *dir_path;
279+
int err;
280+
281+
py_file = PyTuple_GetItem(args, 1);
282+
py_dir = PyTuple_GetItem(args, 2);
283+
284+
/* py_file and py_dir are only valid if they are strings */
285+
if (PyUnicode_Check(py_file) || PyBytes_Check(py_file)) {
286+
file_path = py_str_to_c_str(py_file, Py_FileSystemDefaultEncoding);
287+
} else {
288+
file_path = NULL;
289+
}
290+
291+
if (PyUnicode_Check(py_dir) || PyBytes_Check(py_dir)) {
292+
dir_path = py_str_to_c_str(py_dir, Py_FileSystemDefaultEncoding);
293+
} else {
294+
dir_path = NULL;
295+
}
296+
297+
err = git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, file_path, dir_path);
298+
299+
if (err < 0)
300+
return Error_set(err);
301+
302+
Py_RETURN_NONE;
303+
}
304+
275305
}
276306

277307
PyErr_SetString(PyExc_ValueError, "unknown/unsupported option value");

src/pygit2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ moduleinit(PyObject* m)
242242
ADD_CONSTANT_INT(m, GIT_OPT_GET_CACHED_MEMORY);
243243
ADD_CONSTANT_INT(m, GIT_OPT_ENABLE_CACHING);
244244
ADD_CONSTANT_INT(m, GIT_OPT_SET_CACHE_MAX_SIZE);
245+
ADD_CONSTANT_INT(m, GIT_OPT_SET_SSL_CERT_LOCATIONS);
245246

246247
/* Errors */
247248
GitError = PyErr_NewException("_pygit2.GitError", NULL, NULL);

0 commit comments

Comments
 (0)