Abort `git cl push` if pushing into a local branch.

R=agable@chromium.org, szager@chromium.org
BUG=338102

Review URL: https://codereview.chromium.org/224863006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@263202 0039d316-1c4b-4281-b951-d872f2087c98
changes/01/332501/1
iannucci@chromium.org 11 years ago
parent 21980029dc
commit 5724c961f6

@ -1744,7 +1744,7 @@ def IsSubmoduleMergeCommit(ref):
def SendUpstream(parser, args, cmd):
"""Common code for CmdPush and CmdDCommit
Squashed commit into a single.
Squashes branch into a single commit.
Updates changelog with metadata (e.g. pointer to review).
Pushes/dcommits the code upstream.
Updates review and closes.
@ -1763,6 +1763,21 @@ def SendUpstream(parser, args, cmd):
(options, args) = parser.parse_args(args)
cl = Changelist()
current = cl.GetBranch()
remote, upstream_branch = cl.FetchUpstreamTuple(cl.GetBranch())
if not settings.GetIsGitSvn() and remote == '.':
print
print 'Attempting to push branch %r into another local branch!' % current
print
print 'Either reparent this branch on top of origin/master:'
print ' git reparent-branch --root'
print
print 'OR run `git rebase-update` if you think the parent branch is already'
print 'committed.'
print
print ' Current parent: %r' % upstream_branch
return 1
if not args or cmd == 'push':
# Default to merging against our best guess of the upstream branch.
args = [cl.GetUpstreamBranch()]

@ -270,6 +270,9 @@ class TestGitCl(TestCase):
((['git',
'config', 'branch.working.merge'],), 'refs/heads/master'),
((['git', 'config', 'branch.working.remote'],), 'origin'),
((['git', 'config', 'branch.working.merge'],),
'refs/heads/master'),
((['git', 'config', 'branch.working.remote'],), 'origin'),
((['git', 'rev-list', '--merges',
'--grep=^SVN changes up to revision [0-9]*$',
'refs/remotes/origin/master^!'],), ''),

Loading…
Cancel
Save