Warn when fsmonitor is enabled and git submodules are used

Change-Id: I181bf180f762282d5b4bc614d12a91125f56e063
Bug: 1475405
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4814429
Auto-Submit: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
changes/29/4814429/9
Aravind Vasudevan 2 years ago committed by LUCI CQ
parent bb14391a50
commit b8164180d2

@ -97,6 +97,7 @@ import urllib.parse
import detect_host_arch
import fix_encoding
import git_common
import gclient_eval
import gclient_paths
import gclient_scm
@ -2137,6 +2138,17 @@ it or fix the checkout.
patch_repo + '@' + patch_ref
for patch_repo, patch_ref in patch_refs.items())))
# TODO(crbug.com/1475405): Warn users if the project uses submodules and
# they have fsmonitor enabled.
if command == 'update':
# Check if any of the root dependency have submodules.
is_submoduled = any(
map(
lambda d: d.git_dependencies_state in
(gclient_eval.SUBMODULES, gclient_eval.SYNC), self.dependencies))
if is_submoduled:
git_common.warn_submodule()
# Once all the dependencies have been processed, it's now safe to write
# out the gn_args_file and run the hooks.
removed_cipd_entries = []

@ -4738,6 +4738,11 @@ def CMDupload(parser, args):
if opt.help != optparse.SUPPRESS_HELP))
return
# TODO(crbug.com/1475405): Warn users if the project uses submodules and
# they have fsmonitor enabled.
if os.path.isfile('.gitmodules'):
git_common.warn_submodule()
if git_common.is_dirty_git_tree('upload'):
return 1

@ -11,6 +11,9 @@ import threading
from multiprocessing.pool import IMapIterator
from third_party import colorama
def wrapper(func):
def wrap(self, timeout=None):
default_timeout = (1 << 31 if sys.version_info.major == 2 else
@ -410,6 +413,27 @@ def get_config_regexp(pattern):
return run('config', '--get-regexp', pattern).splitlines()
def is_fsmonitor_enabled():
"""Returns true if core.fsmonitor is enabled in git config."""
fsmonitor = get_config('core.fsmonitor', 'False')
return fsmonitor.strip().lower() == 'true'
def warn_submodule():
"""Print warnings for submodules."""
# TODO(crbug.com/1475405): Warn users if the project uses submodules and
# they have fsmonitor enabled.
if is_fsmonitor_enabled():
print(colorama.Fore.RED)
print('WARNING: You have fsmonitor enabled. There is a major issue '
'resulting in git diff-index returning wrong results. Please '
'disable it by running:')
print(' git config --global core.fsmonitor false')
print('We will remove this warning once https://crbug.com/1475405 is '
'fixed.')
print(colorama.Style.RESET_ALL)
def current_branch():
try:
return run('rev-parse', '--abbrev-ref', 'HEAD')

@ -731,7 +731,12 @@ class TestGitCl(unittest.TestCase):
custom_cl_base=None, short_hostname='chromium',
change_id=None, default_branch='main',
reset_issue=False):
calls = []
calls = [
(
(['os.path.isfile', '.gitmodules'], ),
'True',
),
]
if custom_cl_base:
ancestor_revision = custom_cl_base
else:

@ -454,6 +454,15 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
self.assertEqual('catfood', self.repo.run(self.gc.root))
self.repo.git('config', '--add', 'core.fsmonitor', 'true')
self.assertEqual(True, self.repo.run(self.gc.is_fsmonitor_enabled))
self.repo.git('config', '--add', 'core.fsmonitor', 't')
self.assertEqual(False, self.repo.run(self.gc.is_fsmonitor_enabled))
self.repo.git('config', '--add', 'core.fsmonitor', 'false')
self.assertEqual(False, self.repo.run(self.gc.is_fsmonitor_enabled))
def testRoot(self):
origin_schema = git_test_utils.GitRepoSchema("""
A B C

Loading…
Cancel
Save