From 19238fc343b2404d13550dfe30d99708e1df7716 Mon Sep 17 00:00:00 2001 From: Clemens Hammacher Date: Wed, 5 Dec 2018 10:47:05 +0000 Subject: [PATCH] Revert "Fix semantics of git new-branch --upstream" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ba83229a731721ff888374b0ba6eab8ec80fb652. 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 > Commit-Queue: Clemens Hammacher > Auto-Submit: Clemens Hammacher 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 Commit-Queue: Clemens Hammacher --- git_new_branch.py | 3 +-- man/html/git-new-branch.html | 8 ++++---- man/man1/git-new-branch.1 | 6 +++--- man/src/git-new-branch.txt | 6 +++--- tests/git_rebase_update_test.py | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/git_new_branch.py b/git_new_branch.py index 105da17d00..d61a42d790 100755 --- a/git_new_branch.py +++ b/git_new_branch.py @@ -58,8 +58,7 @@ def main(args): else: # TODO(iannucci): Detect unclean workdir then stash+pop if we need to # teleport to a conflicting portion of history? - run('checkout', '-b', opts.branch_name) - run('branch', '--set-upstream-to', opts.upstream) + run('checkout', '--track', opts.upstream, '-b', opts.branch_name) get_or_create_merge_base(opts.branch_name) except subprocess2.CalledProcessError as cpe: sys.stdout.write(cpe.stdout) diff --git a/man/html/git-new-branch.html b/man/html/git-new-branch.html index d4c645695b..4f11776820 100644 --- a/man/html/git-new-branch.html +++ b/man/html/git-new-branch.html @@ -766,9 +766,9 @@ git-new-branch(1) Manual Page

DESCRIPTION

-

Creates a new branch for HEAD. By default the new branch will track the -configured upstream for the repo (defaults to origin/master). 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 origin/master). If one of the other options +is specified, it will track that other ref instead.

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 on the changes in another), then you should create them as new branches tracking @@ -917,7 +917,7 @@ from


diff --git a/man/man1/git-new-branch.1 b/man/man1/git-new-branch.1 index 5d528f2031..14d50601ab 100644 --- a/man/man1/git-new-branch.1 +++ b/man/man1/git-new-branch.1 @@ -1,8 +1,8 @@ '\" t .\" Title: git-new-branch .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.79.1 -.\" Date: 11/26/2018 +.\" Generator: DocBook XSL Stylesheets v1.78.1 +.\" Date: 12/15/2016 .\" Manual: Chromium depot_tools Manual .\" Source: depot_tools f72f1ad .\" Language: English @@ -40,7 +40,7 @@ git-new-branch \- Create a new branch with correct tracking information\&. .sp .SH "DESCRIPTION" .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 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 )\&. If you have features which depend on each other, you should create stacked branches using git new\-branch \-\-upstream_current \&. .SH "OPTIONS" diff --git a/man/src/git-new-branch.txt b/man/src/git-new-branch.txt index 694fe9c21d..6d9bc72118 100644 --- a/man/src/git-new-branch.txt +++ b/man/src/git-new-branch.txt @@ -17,9 +17,9 @@ SYNOPSIS DESCRIPTION ----------- -Creates a new branch for *HEAD*. By default the new branch will track the -configured upstream for the repo (defaults to 'origin/master'). 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 'origin/master'). If one of the other options +is specified, it will track that other ref instead. 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 diff --git a/tests/git_rebase_update_test.py b/tests/git_rebase_update_test.py index 22d71022ce..e8d7d5f902 100755 --- a/tests/git_rebase_update_test.py +++ b/tests/git_rebase_update_test.py @@ -69,7 +69,7 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase): super(GitRebaseUpdateTest, self).tearDown() def testRebaseUpdate(self): - self.repo.git('checkout', 'origin/master') + self.repo.git('checkout', 'branch_K') self.repo.run(self.nb.main, ['foobar']) self.assertEqual(self.repo.git('rev-parse', 'HEAD').stdout,