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
...
Review URL: https://chromiumcodereview.appspot.com/10412027
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@140314 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 2c63d73..d2f4b31 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1019,7 +1019,10 @@
upload_args.extend(['--base_url', remote_url])
try:
- issue, patchset = upload.RealMain(['upload'] + upload_args + args)
+ # upload uses '-C' by default when generating the diff for upload.
+ # Add another '-C' to trigger --find-copies-harder.
+ issue, patchset = upload.RealMain(['upload'] + upload_args + args +
+ ['--', '-C'])
except KeyboardInterrupt:
sys.exit(1)
except:
@@ -1112,7 +1115,7 @@
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', '-C', '-C'] + args, env=env)
if settings.GetIsGerrit():
return GerritUpload(options, args, cl)