summaryrefslogtreecommitdiffstats
path: root/pre_commit/git.py
diff options
context:
space:
mode:
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: