From 5cf7022b80eb493d792b2917bd4a31e9f5ce0049 Mon Sep 17 00:00:00 2001 From: "cmp@chromium.org" Date: Tue, 12 Jun 2012 18:20:13 +0000 Subject: [PATCH] Turn on git diff copy detection for git-cl upload. Enable copy detection for git-cl upload. This makes it possible to copy a directory containing many files, add+commit the new path, and then upload a patch to Rietveld that shows the files were copied. In my tests, -C -C was needed to pick up a basic file copy. -C was not enough. I'm not sure why exactly. The output generated in the diff looks like: sh$ git diff -C -C HEAD~1..HEAD diff --git a/slave/Makefile b/slave2/Makefile similarity index 100% copy from slave/Makefile copy to slave2/Makefile ... (This change requires r141676 / https://chromiumcodereview.appspot.com/10543116/ which updates upload.py to use --find-copies-harder.) R=maruel@chromium.org Review URL: https://chromiumcodereview.appspot.com/10545107 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@141689 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl.py | 3 ++- tests/git_cl_test.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/git_cl.py b/git_cl.py index 194a81784..114ab1a81 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1128,7 +1128,8 @@ def CMDupload(parser, args): if 'GIT_EXTERNAL_DIFF' in env: del env['GIT_EXTERNAL_DIFF'] subprocess2.call( - ['git', 'diff', '--no-ext-diff', '--stat', '-M'] + args, env=env) + ['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder'] + args, + env=env) if settings.GetIsGerrit(): return GerritUpload(options, args, cl) diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index e0705fad6..7c9eb425f 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -114,7 +114,8 @@ class TestGitCl(TestCase): ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), ((['git', 'config', 'user.email'],), 'me@example.com'), - ((['git', 'diff', '--no-ext-diff', '--stat', '-M', 'master...'],), + ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', + 'master...'],), '+dat'), ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), 'desc\n'), ] @@ -347,7 +348,8 @@ class TestGitCl(TestCase): ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), ((['git', 'config', 'user.email'],), 'me@example.com'), - ((['git', 'diff', '--no-ext-diff', '--stat', '-M', 'master...'],), + ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', + 'master...'],), '+dat'), ]