Commit 5e07e060 authored by sbc@chromium.org's avatar sbc@chromium.org

git cl upload now diffs HEAD rather than working tree

BUG=179131
TEST=./tests/git_cl_test.py


Review URL: https://chromiumcodereview.appspot.com/12388027

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@185366 0039d316-1c4b-4281-b951-d872f2087c98
parent dbf8b4ed
...@@ -1272,7 +1272,7 @@ def CMDupload(parser, args): ...@@ -1272,7 +1272,7 @@ def CMDupload(parser, args):
else: else:
# Default to diffing against common ancestor of upstream branch # Default to diffing against common ancestor of upstream branch
base_branch = RunGit(['merge-base', cl.GetUpstreamBranch(), 'HEAD']).strip() base_branch = RunGit(['merge-base', cl.GetUpstreamBranch(), 'HEAD']).strip()
args = [base_branch] args = [base_branch, 'HEAD']
if not options.bypass_hooks: if not options.bypass_hooks:
hook_results = cl.RunHook(committing=False, upstream_branch=base_branch, hook_results = cl.RunHook(committing=False, upstream_branch=base_branch,
......
...@@ -120,10 +120,10 @@ class TestGitCl(TestCase): ...@@ -120,10 +120,10 @@ class TestGitCl(TestCase):
if find_copies: if find_copies:
stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', stat_call = ((['git', 'diff', '--no-ext-diff', '--stat',
'--find-copies-harder', '-l100000', '-C'+similarity, '--find-copies-harder', '-l100000', '-C'+similarity,
'fake_ancestor_sha'],), '+dat') 'fake_ancestor_sha', 'HEAD'],), '+dat')
else: else:
stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', stat_call = ((['git', 'diff', '--no-ext-diff', '--stat',
'-M'+similarity, 'fake_ancestor_sha'],), '+dat') '-M'+similarity, 'fake_ancestor_sha', 'HEAD'],), '+dat')
return [ return [
((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'),
...@@ -149,7 +149,7 @@ class TestGitCl(TestCase): ...@@ -149,7 +149,7 @@ class TestGitCl(TestCase):
((['git', 'config', 'user.email'],), 'me@example.com'), ((['git', 'config', 'user.email'],), 'me@example.com'),
stat_call, stat_call,
((['git', 'config', 'gerrit.host'],), ''), ((['git', 'config', 'gerrit.host'],), ''),
((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..HEAD'],),
'desc\n'), 'desc\n'),
] ]
...@@ -287,7 +287,7 @@ class TestGitCl(TestCase): ...@@ -287,7 +287,7 @@ class TestGitCl(TestCase):
'--cc', 'joe@example.com', '--cc', 'joe@example.com',
'--git_similarity', similarity or '50' '--git_similarity', similarity or '50'
] + (['--git_no_find_copies'] if find_copies == False else []) + [ ] + (['--git_no_find_copies'] if find_copies == False else []) + [
'fake_ancestor_sha' 'fake_ancestor_sha', 'HEAD'
] ]
def _run_reviewer_test( def _run_reviewer_test(
...@@ -457,7 +457,7 @@ class TestGitCl(TestCase): ...@@ -457,7 +457,7 @@ class TestGitCl(TestCase):
'foo'), 'foo'),
((['git', 'config', 'user.email'],), 'me@example.com'), ((['git', 'config', 'user.email'],), 'me@example.com'),
((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder',
'-l100000', '-C50', 'fake_ancestor_sha'],), '-l100000', '-C50', 'fake_ancestor_sha', 'HEAD'],),
'+dat'), '+dat'),
] ]
...@@ -465,16 +465,19 @@ class TestGitCl(TestCase): ...@@ -465,16 +465,19 @@ class TestGitCl(TestCase):
def _gerrit_upload_calls(description, reviewers): def _gerrit_upload_calls(description, reviewers):
calls = [ calls = [
((['git', 'config', 'gerrit.host'],), 'gerrit.example.com'), ((['git', 'config', 'gerrit.host'],), 'gerrit.example.com'),
((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), ((['git', 'log', '--pretty=format:%s\n\n%b',
'fake_ancestor_sha..HEAD'],),
description) description)
] ]
if git_cl.CHANGE_ID not in description: if git_cl.CHANGE_ID not in description:
calls += [ calls += [
((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), ((['git', 'log', '--pretty=format:%s\n\n%b',
'fake_ancestor_sha..HEAD'],),
description), description),
((['git', 'commit', '--amend', '-m', description],), ((['git', 'commit', '--amend', '-m', description],),
''), ''),
((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), ((['git', 'log', '--pretty=format:%s\n\n%b',
'fake_ancestor_sha..HEAD'],),
description) description)
] ]
calls += [ calls += [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment