Skip to content

Add bindings for MWINDOW_FILE_LIMIT options from libgit2 #1312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pygit2/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,8 @@ class Option(IntEnum):
SET_PACK_MAX_OBJECTS = _pygit2.GIT_OPT_SET_PACK_MAX_OBJECTS
DISABLE_PACK_KEEP_FILE_CHECKS = _pygit2.GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS
# ENABLE_HTTP_EXPECT_CONTINUE = _pygit2.GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE
# GET_MWINDOW_FILE_LIMIT = _pygit2.GIT_OPT_GET_MWINDOW_FILE_LIMIT
# SET_MWINDOW_FILE_LIMIT = _pygit2.GIT_OPT_SET_MWINDOW_FILE_LIMIT
GET_MWINDOW_FILE_LIMIT = _pygit2.GIT_OPT_GET_MWINDOW_FILE_LIMIT
SET_MWINDOW_FILE_LIMIT = _pygit2.GIT_OPT_SET_MWINDOW_FILE_LIMIT
# SET_ODB_PACKED_PRIORITY = _pygit2.GIT_OPT_SET_ODB_PACKED_PRIORITY
# SET_ODB_LOOSE_PRIORITY = _pygit2.GIT_OPT_SET_ODB_LOOSE_PRIORITY
# GET_EXTENSIONS = _pygit2.GIT_OPT_GET_EXTENSIONS
Expand Down
32 changes: 32 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,38 @@ option(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}

case GIT_OPT_GET_MWINDOW_FILE_LIMIT:
{
size_t limit;

error = git_libgit2_opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, &limit);
if (error < 0)
return Error_set(error);

return PyLong_FromSize_t(limit);
}

case GIT_OPT_SET_MWINDOW_FILE_LIMIT:
{
size_t limit;
PyObject *py_limit;

py_limit = PyTuple_GetItem(args, 1);
if (!py_limit)
return NULL;

if (!PyLong_Check(py_limit))
return Error_type_error(
"size should be an integer, got %.200s", py_limit);

limit = PyLong_AsSize_t(py_limit);
error = git_libgit2_opts(GIT_OPT_SET_MWINDOW_SIZE, limit);
if (error < 0)
return Error_set(error);

Py_RETURN_NONE;
}

case GIT_OPT_GET_SEARCH_PATH:
{
PyObject *py_level;
Expand Down
6 changes: 6 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ PyDoc_STRVAR(option__doc__,
"GIT_OPT_SET_MWINDOW_SIZE, size\n"
" Set the maximum mmap window size.\n"
"\n"
"GIT_OPT_GET_MWINDOW_FILE_LIMIT\n"
" Get the maximum number of files that will be mapped at any time by the library.\n"
"\n"
"GIT_OPT_SET_MWINDOW_FILE_LIMIT, size\n"
" Set the maximum number of files that can be mapped at any time by the library. The default (0) is unlimited.\n"
"\n"
"GIT_OPT_GET_OWNER_VALIDATION\n"
" Gets the owner validation setting for repository directories.\n"
"\n"
Expand Down
2 changes: 2 additions & 0 deletions src/pygit2.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ PyInit__pygit2(void)
ADD_CONSTANT_INT(m, GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS);
ADD_CONSTANT_INT(m, GIT_OPT_GET_OWNER_VALIDATION);
ADD_CONSTANT_INT(m, GIT_OPT_SET_OWNER_VALIDATION);
ADD_CONSTANT_INT(m, GIT_OPT_GET_MWINDOW_FILE_LIMIT);
ADD_CONSTANT_INT(m, GIT_OPT_SET_MWINDOW_FILE_LIMIT);

/* Exceptions */
ADD_EXC(m, GitError, NULL);
Expand Down