Skip to content

Commit

Permalink
Expose MWINDOW_FILE_LIMIT options from libgit2
Browse files Browse the repository at this point in the history
  • Loading branch information
victor committed Jul 30, 2024
1 parent 01d8296 commit e19ea4d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
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

0 comments on commit e19ea4d

Please sign in to comment.