summaryrefslogtreecommitdiffstats
path: root/pre_commit/git.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-04 03:57:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-04 03:57:49 +0000
commitd6cacb1f6ae346ce54a5116d76a7d087bb6381a5 (patch)
treefdb6f1b1b847180a234439c3f39ce5d93da8e84e /pre_commit/git.py
parentAdding upstream version 2.15.0. (diff)
downloadpre-commit-d6cacb1f6ae346ce54a5116d76a7d087bb6381a5.tar.xz
pre-commit-d6cacb1f6ae346ce54a5116d76a7d087bb6381a5.zip
Adding upstream version 2.16.0.upstream/2.16.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/git.py')
-rw-r--r--pre_commit/git.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/pre_commit/git.py b/pre_commit/git.py
index 6264529..e9ec601 100644
--- a/pre_commit/git.py
+++ b/pre_commit/git.py
@@ -12,9 +12,11 @@ from pre_commit.util import CalledProcessError
from pre_commit.util import cmd_output
from pre_commit.util import cmd_output_b
-
logger = logging.getLogger(__name__)
+# see #2046
+NO_FS_MONITOR = ('-c', 'core.useBuiltinFSMonitor=false')
+
def zsplit(s: str) -> List[str]:
s = s.strip('\0')
@@ -39,9 +41,10 @@ def no_git_env(
return {
k: v for k, v in _env.items()
if not k.startswith('GIT_') or
+ k.startswith(('GIT_CONFIG_KEY_', 'GIT_CONFIG_VALUE_')) or
k in {
'GIT_EXEC_PATH', 'GIT_SSH', 'GIT_SSH_COMMAND', 'GIT_SSL_CAINFO',
- 'GIT_SSL_NO_VERIFY',
+ 'GIT_SSL_NO_VERIFY', 'GIT_CONFIG_COUNT',
}
}
@@ -185,10 +188,11 @@ def init_repo(path: str, remote: str) -> None:
if os.path.isdir(remote):
remote = os.path.abspath(remote)
+ git = ('git', *NO_FS_MONITOR)
env = no_git_env()
# avoid the user's template so that hooks do not recurse
- cmd_output_b('git', 'init', '--template=', path, env=env)
- cmd_output_b('git', 'remote', 'add', 'origin', remote, cwd=path, env=env)
+ cmd_output_b(*git, 'init', '--template=', path, env=env)
+ cmd_output_b(*git, 'remote', 'add', 'origin', remote, cwd=path, env=env)
def commit(repo: str = '.') -> None: