From 9249f64cf4fdf7ca765179d49a3359ea70fd9eee Mon Sep 17 00:00:00 2001 From: "mcgrathr@chromium.org" Date: Mon, 3 Jun 2013 21:36:18 +0000 Subject: [PATCH] Pass --no-renames to git diff If ~/.gitconfig contains: [diff] renames = "true" then git diff --name-status will produce output that confuses the parsing in svm.GIT.CaptureStatus and git diff will produce output that confuses the patch command on trybots. Passing --no-renames explicitly counteracts this. Review URL: https://chromiumcodereview.appspot.com/16057018 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@203778 0039d316-1c4b-4281-b951-d872f2087c98 --- scm.py | 7 +++++-- tests/git_cl_test.py | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scm.py b/scm.py index 4e9c11c7c..7293f8334 100644 --- a/scm.py +++ b/scm.py @@ -113,7 +113,8 @@ class GIT(object): upstream_branch = GIT.GetUpstreamBranch(cwd) if upstream_branch is None: raise gclient_utils.Error('Cannot determine upstream branch') - command = ['diff', '--name-status', '-r', '%s...' % upstream_branch] + command = ['diff', '--name-status', '--no-renames', + '-r', '%s...' % upstream_branch] if not files: pass elif isinstance(files, basestring): @@ -346,7 +347,9 @@ class GIT(object): branch = GIT.GetUpstreamBranch(cwd) command = ['diff', '-p', '--no-color', '--no-prefix', '--no-ext-diff', branch + "..." + branch_head] - if not full_move: + if full_move: + command.append('--no-renames') + else: command.append('-C') # TODO(maruel): --binary support. if files: diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index ca1aff224..9535f9cc8 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -162,7 +162,7 @@ class TestGitCl(TestCase): ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ ((['git', '--no-pager', 'rev-parse', '--show-cdup'],), ''), ((['git', '--no-pager', 'rev-parse', 'HEAD'],), '12345'), - ((['git', '--no-pager', 'diff', '--name-status', '-r', + ((['git', '--no-pager', 'diff', '--name-status', '--no-renames', '-r', 'fake_ancestor_sha...', '.'],), 'M\t.gitignore\n'), ((['git', '--no-pager', 'config', 'branch.master.rietveldissue'],), ''), @@ -287,7 +287,7 @@ class TestGitCl(TestCase): ((['git', '--no-pager', 'rev-parse', 'HEAD'],), '00ff397798ea57439712ed7e04ab96e13969ef40'), ((['git', '--no-pager', - 'diff', '--name-status', '-r', 'fake_ancestor_sha...', + 'diff', '--name-status', '--no-renames', '-r', 'fake_ancestor_sha...', '.'],), 'M\tPRESUBMIT.py'), ((['git', '--no-pager', @@ -533,7 +533,8 @@ class TestGitCl(TestCase): ((['git', '--no-pager', 'rev-parse', '--show-cdup'],), ''), ((['git', '--no-pager', 'rev-parse', 'HEAD'],), '12345'), ((['git', '--no-pager', - 'diff', '--name-status', '-r', 'fake_ancestor_sha...', '.'],), + 'diff', '--name-status', '--no-renames', '-r', + 'fake_ancestor_sha...', '.'],), 'M\t.gitignore\n'), ((['git', '--no-pager', 'config', 'branch.master.rietveldissue'],), ''), ((['git', '--no-pager',