Skip to content
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

Support for new option 'GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS' to skip checking for '.keep' files #908

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 12 additions & 0 deletions pygit2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from _pygit2 import GIT_OPT_ENABLE_CACHING
from _pygit2 import GIT_OPT_SET_CACHE_MAX_SIZE
from _pygit2 import GIT_OPT_SET_SSL_CERT_LOCATIONS
from _pygit2 import GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS

from .errors import GitError

Expand Down Expand Up @@ -166,3 +167,14 @@ def set_ssl_cert_locations(self, ssl_cert_file, ssl_cert_dir):
option(GIT_OPT_SET_SSL_CERT_LOCATIONS, ssl_cert_file, ssl_cert_dir)
self._ssl_cert_file = ssl_cert_file
self._ssl_cert_dir = ssl_cert_dir

def disable_pack_keep_file_check(self, value=True):
"""Disable check to existence of '.keep'

Situations were retaining pack files is not required, we can
avoid the check for files that convey the intent to retain pack
files during GC. This is aimed to improve performance accessing
repositories over network filesystems
"""
return option(GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS, value)

19 changes: 18 additions & 1 deletion src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,24 @@ option(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}

case GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS:
{
PyObject *py_flag;
py_flag = PyTuple_GetItem(args, 1);

if (!PyBool_Check(py_flag))
return Error_type_error("flag should be boolean, got %.200s",
py_flag);

error = git_libgit2_opts(GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS,
(Py_True == py_flag));

if (error < 0)
return Error_set(error);

Py_RETURN_NONE;
}

// Not implemented
case GIT_OPT_GET_TEMPLATE_PATH:
case GIT_OPT_SET_TEMPLATE_PATH:
Expand All @@ -326,7 +344,6 @@ option(PyObject *self, PyObject *args)
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}

}

PyErr_SetString(PyExc_ValueError, "unknown/unsupported option value");
Expand Down
1 change: 1 addition & 0 deletions src/pygit2.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ moduleinit(PyObject* m)
ADD_CONSTANT_INT(m, GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY);
ADD_CONSTANT_INT(m, GIT_OPT_GET_PACK_MAX_OBJECTS);
ADD_CONSTANT_INT(m, GIT_OPT_SET_PACK_MAX_OBJECTS);
ADD_CONSTANT_INT(m, GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS);

/* Errors */
GitError = PyErr_NewException("_pygit2.GitError", NULL, NULL);
Expand Down