Revert "Fix semantics of git new-branch --upstream"

This reverts commit ba83229a73.

Reason for revert: After mail discussion we came to the conclusion that the old behavior makes more sense.

Original change's description:
> Fix semantics of git new-branch --upstream
> 
> Currently, the "--upstream A" option for new-branch behaves totally
> different than "--upstream_current". While "--upstream A" checks out
> branch A and then creates a new branch which tracks A,
> "--upstream_current" creates a new branch for the current HEAD and sets
> the upstream to the previously checked out branch.
> 
> As the documentation does not mention that any of the options changes
> the currently-checked-out commit (HEAD), this CL changes the semantics
> of "git new-branch --upstream A B" to be identical to "git checkout -b B
> && git branch --set-upstream-to A".
> 
> It also slightly extends the documentation to mention that in any case
> the new branch is based on HEAD.
> 
> R=​iannucci@chromium.org
> 
> Change-Id: Ic335d2caf27cb6afca1b8bc5a008424c0e880fca
> Reviewed-on: https://chromium-review.googlesource.com/c/1350748
> Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
> Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
> Auto-Submit: Clemens Hammacher <clemensh@chromium.org>

TBR=iannucci@chromium.org,tandrii@chromium.org,clemensh@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I7463935af172f0801c7da94d2de106a02fc4c42e
Reviewed-on: https://chromium-review.googlesource.com/c/1362972
Reviewed-by: Sergiy Belozorov <sergiyb@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
changes/72/1362972/2
Clemens Hammacher 7 years ago committed by Commit Bot
parent 687ca907fd
commit 19238fc343

@ -58,8 +58,7 @@ def main(args):
else: else:
# TODO(iannucci): Detect unclean workdir then stash+pop if we need to # TODO(iannucci): Detect unclean workdir then stash+pop if we need to
# teleport to a conflicting portion of history? # teleport to a conflicting portion of history?
run('checkout', '-b', opts.branch_name) run('checkout', '--track', opts.upstream, '-b', opts.branch_name)
run('branch', '--set-upstream-to', opts.upstream)
get_or_create_merge_base(opts.branch_name) get_or_create_merge_base(opts.branch_name)
except subprocess2.CalledProcessError as cpe: except subprocess2.CalledProcessError as cpe:
sys.stdout.write(cpe.stdout) sys.stdout.write(cpe.stdout)

@ -766,9 +766,9 @@ git-new-branch(1) Manual Page
<div class="sect1"> <div class="sect1">
<h2 id="_description">DESCRIPTION</h2> <h2 id="_description">DESCRIPTION</h2>
<div class="sectionbody"> <div class="sectionbody">
<div class="paragraph"><p>Creates a new branch for <strong>HEAD</strong>. By default the new branch will track the <div class="paragraph"><p>Creates a new branch. By default the new branch will track the configured
configured upstream for the repo (defaults to <em>origin/master</em>). If one of the upstream for the repo (defaults to <em>origin/master</em>). If one of the other options
other options is specified, it will track that other ref instead.</p></div> is specified, it will track that other ref instead.</p></div>
<div class="paragraph"><p>Conceptually, each branch in your repo represents one <em>Change List (CL)</em>. If you <div class="paragraph"><p>Conceptually, each branch in your repo represents one <em>Change List (CL)</em>. If you
have many independent CLs (i.e. the changes in one do not interact with/depend have many independent CLs (i.e. the changes in one do not interact with/depend
on the changes in another), then you should create them as new branches tracking on the changes in another), then you should create them as new branches tracking
@ -917,7 +917,7 @@ from <a href="https://chromium.googlesource.com/chromium/tools/depot_tools.git">
<div id="footnotes"><hr /></div> <div id="footnotes"><hr /></div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2018-11-26 13:37:45 CET Last updated 2016-12-15 15:36:52 PST
</div> </div>
</div> </div>
</body> </body>

@ -1,8 +1,8 @@
'\" t '\" t
.\" Title: git-new-branch .\" Title: git-new-branch
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 11/26/2018 .\" Date: 12/15/2016
.\" Manual: Chromium depot_tools Manual .\" Manual: Chromium depot_tools Manual
.\" Source: depot_tools f72f1ad .\" Source: depot_tools f72f1ad
.\" Language: English .\" Language: English
@ -40,7 +40,7 @@ git-new-branch \- Create a new branch with correct tracking information\&.
.sp .sp
.SH "DESCRIPTION" .SH "DESCRIPTION"
.sp .sp
Creates a new branch for \fBHEAD\fR\&. By default the new branch will track the configured upstream for the repo (defaults to \fIorigin/master\fR)\&. If one of the other options is specified, it will track that other ref instead\&. Creates a new branch\&. By default the new branch will track the configured upstream for the repo (defaults to \fIorigin/master\fR)\&. If one of the other options is specified, it will track that other ref instead\&.
.sp .sp
Conceptually, each branch in your repo represents one \fIChange List (CL)\fR\&. If you have many independent CLs (i\&.e\&. the changes in one do not interact with/depend on the changes in another), then you should create them as new branches tracking the default upstream (i\&.e\&. git new\-branch <branch_name>)\&. If you have features which depend on each other, you should create stacked branches using git new\-branch \-\-upstream_current <branch_name>\&. Conceptually, each branch in your repo represents one \fIChange List (CL)\fR\&. If you have many independent CLs (i\&.e\&. the changes in one do not interact with/depend on the changes in another), then you should create them as new branches tracking the default upstream (i\&.e\&. git new\-branch <branch_name>)\&. If you have features which depend on each other, you should create stacked branches using git new\-branch \-\-upstream_current <branch_name>\&.
.SH "OPTIONS" .SH "OPTIONS"

@ -17,9 +17,9 @@ SYNOPSIS
DESCRIPTION DESCRIPTION
----------- -----------
Creates a new branch for *HEAD*. By default the new branch will track the Creates a new branch. By default the new branch will track the configured
configured upstream for the repo (defaults to 'origin/master'). If one of the upstream for the repo (defaults to 'origin/master'). If one of the other options
other options is specified, it will track that other ref instead. is specified, it will track that other ref instead.
Conceptually, each branch in your repo represents one 'Change List (CL)'. If you Conceptually, each branch in your repo represents one 'Change List (CL)'. If you
have many independent CLs (i.e. the changes in one do not interact with/depend have many independent CLs (i.e. the changes in one do not interact with/depend

@ -69,7 +69,7 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
super(GitRebaseUpdateTest, self).tearDown() super(GitRebaseUpdateTest, self).tearDown()
def testRebaseUpdate(self): def testRebaseUpdate(self):
self.repo.git('checkout', 'origin/master') self.repo.git('checkout', 'branch_K')
self.repo.run(self.nb.main, ['foobar']) self.repo.run(self.nb.main, ['foobar'])
self.assertEqual(self.repo.git('rev-parse', 'HEAD').stdout, self.assertEqual(self.repo.git('rev-parse', 'HEAD').stdout,

Loading…
Cancel
Save