Automatically update submodule config entries on sync.
The effect of this is to preserve the behavior of `git status`,
i.e., only changes in the top-level repository will be reported.
Updated test expectations; I have no idea what I'm doing.
Review URL: https://chromiumcodereview.appspot.com/10454088
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@140396 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_scm.py b/gclient_scm.py
index 618c371..82947e4 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -194,6 +194,21 @@
cwd=self.checkout_path,
filter_fn=GitDiffFilterer(self.relpath).Filter)
+ def UpdateSubmoduleConfig(self):
+ submod_cmd = ['git', 'config', '-f', '$toplevel/.git/config',
+ 'submodule.$name.ignore', '||',
+ 'git', 'config', '-f', '$toplevel/.git/config',
+ 'submodule.$name.ignore', 'dirty']
+ cmd = ['git', 'submodule', '--quiet', 'foreach', ' '.join(submod_cmd)]
+ try:
+ gclient_utils.CheckCallAndFilter(
+ cmd, cwd=self.checkout_path, print_stdout=False,
+ filter_fn=lambda x: None)
+ except subprocess2.CalledProcessError:
+ # Not a fatal error, or even very interesting in a non-git-submodule
+ # world. So just keep it quiet.
+ pass
+
def update(self, options, args, file_list):
"""Runs git to update or transparently checkout the working copy.
@@ -254,6 +269,7 @@
not os.listdir(self.checkout_path)):
gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path))
self._Clone(revision, url, options)
+ self.UpdateSubmoduleConfig()
files = self._Capture(['ls-files']).splitlines()
file_list.extend([os.path.join(self.checkout_path, f) for f in files])
if not verbose:
@@ -290,6 +306,7 @@
quiet = ['--quiet']
self._Run(['fetch', 'origin', '--prune'] + quiet, options)
self._Run(['reset', '--hard', 'origin/master'] + quiet, options)
+ self.UpdateSubmoduleConfig()
files = self._Capture(['ls-files']).splitlines()
file_list.extend([os.path.join(self.checkout_path, f) for f in files])
return
@@ -461,6 +478,7 @@
# whitespace between projects when syncing.
print('')
+ self.UpdateSubmoduleConfig()
file_list.extend([os.path.join(self.checkout_path, f) for f in files])
# If the rebase generated a conflict, abort and ask user to fix
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
index d7425c5..1767f520 100755
--- a/tests/gclient_scm_test.py
+++ b/tests/gclient_scm_test.py
@@ -785,6 +785,7 @@
'cleanup',
'diff',
'pack',
+ 'UpdateSubmoduleConfig',
'relpath',
'revert',
'revinfo',