diff --git a/gclient_scm.py b/gclient_scm.py index 362c81b91..8bb1a20a3 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -559,6 +559,22 @@ class GitWrapper(SCMWrapper): (e.returncode, e.stderr.decode('utf-8'))) return True + def set_config(f): + def wrapper(*args): + return_val = f(*args) + if os.path.exists(os.path.join(args[0].checkout_path, '.git')): + # If diff.ignoreSubmodules is not already set, set it to `all`. + currentIgnore = subprocess2.capture( + ['git', 'config', '--get', 'diff.ignoreSubmodules'], + cwd=args[0].checkout_path).strip() + if not currentIgnore: + subprocess2.capture(['git', 'config', 'diff.ignoreSubmodules', 'all'], + cwd=args[0].checkout_path).strip() + return return_val + + return wrapper + + @set_config def update(self, options, args, file_list): """Runs git to update or transparently checkout the working copy. diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 8c8552083..06220ed8b 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -393,6 +393,8 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): self.assertEqual(file_list, expected_file_list) self.assertEqual(scm.revinfo(options, (), None), 'a7142dc9f0009350b96a11f372b6ea658592aa95') + self.assertEqual(scm._Capture(['config', '--get', 'diff.ignoreSubmodules']), + 'all') sys.stdout.close() def testUpdateMerge(self):