From: Igor Djordjevic <igor.d.djordjevic@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>
Cc: Sahil Dua <sahildua2305@gmail.com>,
Ramsay Jones <ramsay@ramsayjones.plus.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: What's cooking in git.git (Jul 2017, #09; Mon, 31)
Date: Tue, 8 Aug 2017 00:20:24 +0200 [thread overview]
Message-ID: <db848b3e-e4cc-ddf4-9e4c-7b47b2f5d7a7@gmail.com> (raw)
In-Reply-To: <e5564e40-702f-390b-69e2-2ed6e45610c8@gmail.com>
On 07/08/2017 23:25, Igor Djordjevic wrote:
> On 06/08/2017 22:26, Ævar Arnfjörð Bjarmason wrote:
>> On Sat, Aug 05 2017, Junio C. Hamano jotted:
>>> I actually consider "branch" to *never* invoking a checkout. Even
>>> when "git branch -m A B" happens to be done when your checked out
>>> branch is A and you end up being on B. That is not a "checkout".
>>
>> I think we just have a different mental model of what "checkout"
>> means. In my mind any operation that updates the HEAD to point to a new
>> branch is a checkout of that branch.
>
> If I may, from a side-viewer`s point of view, it seems you`re
> thinking in low-level implementation details, where what Junio
> describes seems more as a high-level, conceptual/end-user`s point of
> view.
>
> Needing to update HEAD reference once we "rename" a branch, too, what
> you consider a "checkout", seems to be required only because branch
> name _is_ the branch reference in Git, so we need to update HEAD to
> point to a new/renamed branch reference -- but it`s still the same
> branch, conceptually.
>
> Documentation for "git-checkout" states that it is used to "*Switch
> branches*...[snip]", and that is not what happens here.
> Implementation-wise it does because we can`t do it differently at the
> moment, but in user`s eyes it`s still the same branch, so no switch
> is made as far as the user is concerned.
>
> In a different implementation, where branches would have permanent
> references other than their names, no HEAD update would be needed as
> the reference would still be the same, no matter the name change,
> making the `git branch -m` situation clear even from your standpoint,
> I`d say.
>
>>> Really from the end-user's point of view that is not a checkout.
>>> The user renamed the branch A and the same conceptual entity, which
>>> is a branch, is now called B. If that branch was what was checked
>>> out (IOW, if that branch was what would be grown by one commit if
>>> the user did "git commit"), then now that branch's name is B. It is
>>> natural if you ask "symbolic-ref HEAD" what branch is checked out
>>> after renaming A to B (and A happened to be what was checked out),
>>> the answer chould be B.
>>>
>>> It's like the city you live in changed the name of the street your
>>> house is on. You do not call movers, you do not do anything, but
>>> your address changes.
>>
>> Yeah I see what you mean, although this analogy rapidly breaks down when
>> you poke at it as shown above. My house (a sha1) can be on any number of
>> streets and new ones can be added/removed all the time without changing
>> where my house is at.
>
> I may be missing something, but I find the house/address analogy a
> good one, actually, as I understood that "house" resembles a branch
> reference HEAD is pointing to, not a sha1.
>
> Even further, and that might be the point of confusion, "house" seems
> to be more like a "permanent branch reference" I mentioned above,
> where your address can change (branch being renamed), but you would
> still be in the same house (HEAD would still point to the same
> permanent branch reference).
>
> If you move to another house, only then would HEAD change to point to
> another (permanent) branch reference (a different house), and that
> would be a checkout.
>
> Yes, it`s not really how it works from the inside, but I think that`s
> irrelevant for the end-user experience :)
>
>> So it's just a way to get something exactly like -m except the "move &&
>> checkout" logic is changed to "copy && checkout".
>
> Again, it seems the "checkout" part of "move && checkout" you`re
> talking about is a user-wise unnecessary implementation detail. For
> the user, it`s just a simple "move", staying on the same, but renamed
> branch, thus no branch switching occurred (no "checkout", as per
> documentation).
All this said, having you mentioning the two argument version:
> $ git checkout master
> $ git branch -m topic avar/topic
... exactly proves the point that "git branch -m" is not expected to
involve a checkout, even from implementation perspective. It`s just a
consequence of needing to update the (now obsolete) reference HEAD
points to (only) when the branch we`re renaming (moving) is the one
that is currently checked-out.
> Yeah it's not something I'm interested in or have a use-case for,
> although I think in the same way we have -t for checkout it might be
> sensible to have e.g.:
>
> $ git checkout -b topic-2 -c topic -t origin/master
>
> Where the new -c or --config-from would mean "...and get the config from
> 'topic'". Such a name would probably be less confusing than
> --super-b[branch?] which to be implies some ongoing hierarchical
> relationship.
This, on the other hand, sounds sensible, staying true to the
existing logic. In the same manner you can do either:
$ git branch topic -t origin/master
$ git checkout topic
... or shorter equivalent:
$ git checkout -b topic -t origin/master
..., you should be able to do:
$ git branch -c topic topic-2
$ git checkout topic-2
..., or equivalent:
$ git checkout -b topic-2 -c topic
..., where "-c" would follow the same (or similar) logic as "-t" does
now, as you already pointed out :)
p.s. That said, is `git checkout -b topic-2 --move topic` being
missed now...? :P That one would/could/should actually be expected to
move (rename) the branch *and* check it out, no matter if HEAD
currently points to it or not.
Regards,
Buga
next prev parent reply other threads:[~2017-08-07 22:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-31 22:30 What's cooking in git.git (Jul 2017, #09; Mon, 31) Junio C Hamano
2017-07-31 23:36 ` Ramsay Jones
2017-08-03 20:26 ` Sahil Dua
2017-08-03 21:07 ` Junio C Hamano
2017-08-03 22:20 ` Ramsay Jones
2017-08-05 20:34 ` Ævar Arnfjörð Bjarmason
2017-08-05 22:37 ` Junio C Hamano
2017-08-06 20:26 ` Ævar Arnfjörð Bjarmason
2017-08-07 21:25 ` Igor Djordjevic
2017-08-07 22:20 ` Igor Djordjevic [this message]
2017-08-08 13:14 ` Ævar Arnfjörð Bjarmason
2017-08-08 18:55 ` Igor Djordjevic
2017-08-03 20:17 ` Sahil Dua
2017-08-03 20:23 ` Stefan Beller
2017-08-03 21:17 ` Junio C Hamano
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=db848b3e-e4cc-ddf4-9e4c-7b47b2f5d7a7@gmail.com \
--to=igor.d.djordjevic@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ramsay@ramsayjones.plus.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).