From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Sahil Dua <sahildua2305@gmail.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH/RFC v4 3/3] branch: add copy branch feature implementation
Date: Tue, 6 Jun 2017 09:39:32 +0200 [thread overview]
Message-ID: <CACBZZX5OS_cz_mo4rpd+=DGtyN4SfipGrOXwVHJisv3CywoFaw@mail.gmail.com> (raw)
In-Reply-To: <xmqqlgp69ds9.fsf@gitster.mtv.corp.google.com>
On Tue, Jun 6, 2017 at 2:10 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Sahil Dua <sahildua2305@gmail.com> writes:
>
>> I want suggestions about one logical point raised by Evar.
>>
>> Let's consider a case that I'm on branch maint and then I do 'git
>> checkout master' followed by 'git branch -m feature', it will rename
>> master branch to feature. Now if I do 'git checkout -' to go to the
>> last branch, it will take me to maint since master branch doesn't
>> exist in this case.
>>
>> Now, for this copy operation - if I'm on branch maint and then I do
>> 'git checkout master' followed by 'git branch -c feature', it will
>> copy master branch to feature. Now if I do 'git checkout -' to go to
>> the last branch, it will again go to maint (according to the current
>> implementation). What do you think it should do? Is this the desired
>> behavior? Or should it go to master branch since that was the branch
>> checked out before copying.
>>
>> Also, in case this needs to be changed, can someone please point me to
>> how it's being handled so that I can change the behavior.
>
> When somebody says "I want to rename my current branch to X", it is
> clear that the person wants to end up being on a branch called X.
>
> To me, "I want to copy my current branch to Y" sounds more like "I
> want to create another Y that looks just like the current branch,
> but I want stay on my current branch".
This would be more useful to me if the semantics were copy & checkout
instead of just copy, since when I'd like to copy branches it's almost
always because I'm on some topic branch and want to create & work on a
new copy of that topic branch.
It would also be consistent with "git branch -m" and easier to
explain, i.e. "git branch -c just like -m except it doesn't delete the
branch name/config you moved away from".
Like with -m, you can still move around random other branches, e.g.:
# While on master
$ git branch -m some-other new-some-other
This will just move some-other to new-some-other without checkout out
new-some-other, it's only when the source name is the same as your
currently checked out branch that you checkout a new branch,
Now, of course the difference is that when you -m your current branch
it doesn't really have a choice of whether to move your checkout as
well (although I suppose it could leave you in a detached HEAD..) so
it *could* be done differently with -c, but the current behavior makes
more sense to me and matches the common case I'd use it for.
> If you think copy makes @{-1} problematic, perhaps your copy is
> doing more than it should (e.g. switching the current branch at the
> same time, or something).
I think what Sahil is getting at is asking where the @{-N} info is
stored and why this isn't equivalent to:
$ git checkout -b one master
$ git checkout -b two master
$ git checkout master
$ git checkout one
$ git checkout two
$ git checkout - # Goes to "one", not "master"
Which is in analogous flow without this feature that switches to the
last branch, but with "git branch -c" if you were on 'one' and copied
& checked out 'two' doing 'git checkout -' would bring you back to
'master', not 'one'.
next prev parent reply other threads:[~2017-06-06 7:39 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-28 22:56 [PATCH/RFC] branch: add tests for new copy branch feature Sahil Dua
2017-05-28 23:30 ` Ævar Arnfjörð Bjarmason
2017-05-29 20:41 ` Sahil Dua
2017-05-29 20:50 ` Ævar Arnfjörð Bjarmason
2017-05-29 22:23 ` Sahil Dua
2017-06-13 17:55 ` Jonathan Nieder
2017-06-13 18:01 ` Ævar Arnfjörð Bjarmason
2017-06-13 18:08 ` Jonathan Nieder
2017-05-29 2:09 ` Junio C Hamano
2017-05-29 19:39 ` Sahil Dua
2017-05-31 23:35 ` [PATCH/RFC v2 1/6] " Sahil Dua
2017-05-31 23:35 ` [PATCH/RFC v2 5/6] config: add copy config section logic Sahil Dua
2017-05-31 23:35 ` [PATCH/RFC v2 2/6] branch: add copy branch option Sahil Dua
2017-06-01 1:50 ` Junio C Hamano
2017-06-01 16:09 ` Sahil Dua
2017-05-31 23:35 ` [PATCH/RFC v2 4/6] config: modify function signature to include copy argument Sahil Dua
2017-05-31 23:35 ` [PATCH/RFC v2 6/6] branch: don't copy or rename config when same branch name Sahil Dua
2017-05-31 23:35 ` [PATCH/RFC v2 3/6] config: abstract out create section from key logic Sahil Dua
2017-06-01 18:35 ` [PATCH/RFC v3 1/3] branch: add tests for new copy branch feature Sahil Dua
2017-06-01 18:35 ` [PATCH/RFC v3 2/3] config: abstract out create section from key logic Sahil Dua
2017-06-01 18:35 ` [PATCH/RFC v3 3/3] branch: add copy branch feature implementation Sahil Dua
2017-06-01 18:59 ` Ævar Arnfjörð Bjarmason
2017-06-01 22:05 ` Sahil Dua
2017-06-05 20:40 ` [PATCH/RFC v4 1/3] branch: add tests for new copy branch feature Sahil Dua
2017-06-05 20:40 ` [PATCH/RFC v4 2/3] config: abstract out create section from key logic Sahil Dua
2017-06-05 20:40 ` [PATCH/RFC v4 3/3] branch: add copy branch feature implementation Sahil Dua
2017-06-05 20:52 ` Sahil Dua
2017-06-06 0:10 ` Junio C Hamano
2017-06-06 0:14 ` Junio C Hamano
2017-06-06 7:39 ` Ævar Arnfjörð Bjarmason [this message]
2017-06-06 10:13 ` Sahil Dua
2017-06-06 12:03 ` Junio C Hamano
2017-06-13 16:17 ` [PATCH 1/3] config: create a function to format section headers Sahil Dua
2017-06-13 16:17 ` [PATCH 3/3] branch: add a --copy (-c) option to go with --move (-m) Sahil Dua
2017-06-13 17:05 ` Junio C Hamano
2017-06-13 17:30 ` Junio C Hamano
2017-06-14 8:01 ` Sahil Dua
2017-06-18 21:19 ` [PATCH v2 " Sahil Dua
2017-06-13 16:17 ` [PATCH 2/3] branch: add test for -m renaming multiple config sections Sahil Dua
2017-06-13 17:10 ` Junio C Hamano
2017-06-13 17:31 ` Ævar Arnfjörð Bjarmason
2017-06-13 17:39 ` Junio C Hamano
2017-06-13 17:53 ` Ævar Arnfjörð Bjarmason
2017-06-18 21:17 ` [PATCH v2 " Sahil Dua
2017-06-13 17:06 ` [PATCH 1/3] config: create a function to format section headers Junio C Hamano
2017-06-13 17:09 ` Ævar Arnfjörð Bjarmason
2017-06-18 21:16 ` [PATCH v2 " Sahil Dua
2017-06-19 12:08 ` Ramsay Jones
2017-06-19 14:51 ` Sahil Dua
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACBZZX5OS_cz_mo4rpd+=DGtyN4SfipGrOXwVHJisv3CywoFaw@mail.gmail.com' \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sahildua2305@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).