diff --git a/git_cl.py b/git_cl.py index 9dabe2088..f2f3434e3 100755 --- a/git_cl.py +++ b/git_cl.py @@ -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()] diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 65da4df98..9234fb20e 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -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^!'],), ''),