[git-cl] Ignore moved/copied/deleted files for formatting purposes
Bug: 737568
Change-Id: I9888d1b2c392503a1d98579445cda8eee97bd07f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4904205
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Arthur Eubanks <aeubanks@google.com>
Reviewed-by: Hans Wennborg <hans@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 05ff2f5..0a69eae 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -643,7 +643,10 @@
return {}
# Take the git diff and find the line ranges where there are changes.
- diff_cmd = BuildGitDiffCmd('-U0', upstream_commit, files, allow_prefix=True)
+ diff_cmd = BuildGitDiffCmd(['-U0'],
+ upstream_commit,
+ files,
+ allow_prefix=True)
diff_output = RunGit(diff_cmd)
pattern = r'(?:^diff --git a/(?:.*) b/(.*))|(?:^@@.*\+(.*) @@)'
@@ -6050,7 +6053,8 @@
else:
diff_cmd += ['--no-prefix']
- diff_cmd += [diff_type, upstream_commit, '--']
+ diff_cmd += diff_type
+ diff_cmd += [upstream_commit, '--']
if args:
for arg in args:
@@ -6103,7 +6107,7 @@
if not opts.dry_run and not opts.diff:
cmd.append('-i')
- diff_cmd = BuildGitDiffCmd('-U0', upstream_commit, clang_diff_files)
+ diff_cmd = BuildGitDiffCmd(['-U0'], upstream_commit, clang_diff_files)
diff_output = RunGit(diff_cmd).encode('utf-8')
env = os.environ.copy()
@@ -6466,11 +6470,11 @@
DieWithError('Could not find base commit for this branch. '
'Are you in detached state?')
- changed_files_cmd = BuildGitDiffCmd('--name-only', upstream_commit, args)
+ # Filter out copied/renamed/deleted files
+ changed_files_cmd = BuildGitDiffCmd(['--name-only', '--diff-filter=crd'],
+ upstream_commit, args)
diff_output = RunGit(changed_files_cmd)
diff_files = diff_output.splitlines()
- # Filter out files deleted by this CL
- diff_files = [x for x in diff_files if os.path.isfile(x)]
if opts.js:
clang_exts.extend(['.js', '.ts'])