From: Michael J Gruber <git@drmicha.warpmail.net>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: James Pickens <jepicken@gmail.com>, Jeff King <peff@peff.net>,
Junio C Hamano <gitster@pobox.com>,
Nicolas Pitre <nico@fluxnic.net>,
Jay Soffian <jaysoffian@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
Date: Thu, 15 Oct 2009 18:29:26 +0200 [thread overview]
Message-ID: <4AD74DE6.9010800@drmicha.warpmail.net> (raw)
In-Reply-To: <alpine.LNX.2.00.0910151054190.32515@iabervon.org>
Daniel Barkalow venit, vidit, dixit 15.10.2009 17:36:
> On Thu, 15 Oct 2009, James Pickens wrote:
>
>> On Wed, Oct 14, 2009 at 4:09 PM, Jeff King <peff@peff.net> wrote:
>>> That makes the most sense to me. If "git checkout" could write metadata
>>> into HEAD (or into DETACH_HEAD, as in Daniel's patch), then checkout
>>> could record an "ok to commit" bit. And could also be used to change it
>>> after the fact. E.g.:
>>>
>>> $ git checkout --detach=commit origin/master
>>> $ git commit ;# should be ok
>>>
>>> $ git checkout --detach=examine origin/master
>>> $ git commit ;# complain
>>> $ git checkout --detach=commit HEAD
>>> $ git commit ;# ok
>>>
>>> I guess something like "rebase" should detach with "ok to commit", since
>>> it is planning on attaching the commits later. I'm not sure about "git
>>> bisect". I guess probably it should be "not ok to commit" to be on the
>>> safe side, and then somebody can "git checkout --detach=commit" if they
>>> want to.
>>
>> How about not detaching the head at all if the user checks out any ref, and
>> reject commits if he checked out a tag or remote branch. For example:
>>
>> $ git checkout origin/master
>> $ git status
>> # On branch origin/master
>> $ git commit ;# complain
>>
>> $ git checkout v1.0.1
>> $ git status
>> # On tag v1.0.1
>> $ git commit ;# complain
>>
>> $ git checkout v1.0.1^0 ;# detach
>> $ git commit ;# ok
>>
>> I think this would help the newbies and wouldn't cost the experts too much.
>> Checking out anything other than a plain ref would still detach the head, and
>> commits on a detached head would still be allowed.
>
> I think reducing users' exposure to the "detached HEAD" state would just
> make it take longer for them to find that state familiar.
Yep. Which is why I keep suggesting that git clone does not create any
local branches at all ;)
> It's not like the concept is actually very difficult or unusual. CVS has
> it as "cvs checkout -r <something>" or "cvs checkout -D <something>"; SVN
> has it as "svn checkout -r <something>". It was weird and scary in CVS if
> you did it (it was "sticky tags", and you had to find a different option
> to get back to normal), but SVN is easier ("svn checkout -r HEAD").
svn up -r HEAD
> I think the description used in CVS and SVN (and, I think, others) is that
> you're not at the HEAD revision. I think they both account for the state
> where you've checked out the revision by number that's the latest
> revision, but you still can't grow the branch because you can't
> simultaneously stay on r1000 (as requested explicitly) and add a new
> commit.
I'd say the fundamental difference is that in CVS and SVN, there is
always only one "tip", which they call HEAD. This is also why revision
numbers make sense.
In git and hg there can be many tips (branch heads) from which to grow
the DAG. Heck, you can grow a new one from any commit ;)
> So maybe the right explanation is:
>
> $ git checkout master; git branch
> * master
> $ git checkout origin/master; git branch
> * origin/master (not at head)
Ouch, please don't. HEAD has a completely different meaning in git. I
know you know, of course.
> $ git checkout 123cafe^5; git branch
> * 123cafe^5 (not at head)
> $ git checkout HEAD^2; git branch
> * 123cafe^5^2
> $ git commit; git branch
> * (temporary branch)
>
> Then we can say that one way that git is different from SVN is that all
> branches of other repositories are read-only, and you can't be at the
> head when you're on them (because the head of those branches are in
> different repositories); instead you grow the history locally, and you
> tell the remote branch to adopt your history.
You can change your refs/remotes/origin/master, of course, it's just by
convention (for a good reason) that git treats them as read-only, and
porc. respects that.
git's branches are simply completely different, they're movable tags,
and I think that's one point new users *have* to grok. Once they're over
this then even detached heads are a natural thing.
>> Perhaps as an additional safety feature, Git could refuse to switch away
>> from a detached head if the head isn't reachable from any ref
>
> As far as I know, people don't actually seem to lose stuff this way. In
> part, that's because they get scared before they get there; in part,
> that's because they just don't think to go there; and in part, we tell
> them how to recover stuff at that point (using the ref log or the sha1).
Maybe we just don't scare them enough yet :)
Michael
next prev parent reply other threads:[~2009-10-15 16:36 UTC|newest]
Thread overview: 93+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-14 4:44 [PATCH] Proof-of-concept patch to remember what the detached HEAD was Daniel Barkalow
2009-10-14 5:07 ` Junio C Hamano
2009-10-14 5:08 ` Jeff King
2009-10-14 10:33 ` Johannes Schindelin
2009-10-14 15:39 ` Jeff King
2009-10-14 18:34 ` Junio C Hamano
2009-10-14 18:40 ` Jeff King
2009-10-14 15:56 ` Daniel Barkalow
2009-10-14 18:56 ` Jay Soffian
2009-10-14 19:15 ` Daniel Barkalow
2009-10-14 20:18 ` Nicolas Pitre
2009-10-14 20:37 ` Daniel Barkalow
2009-10-14 20:42 ` Junio C Hamano
2009-10-14 20:48 ` Nicolas Pitre
2009-10-14 22:34 ` Junio C Hamano
2009-10-14 23:09 ` Jeff King
2009-10-14 23:34 ` Nicolas Pitre
2009-10-15 0:56 ` Junio C Hamano
2009-10-15 1:47 ` Jeff King
2009-10-15 3:08 ` Nicolas Pitre
2009-10-15 4:21 ` Jeff King
2009-10-16 1:04 ` Johannes Schindelin
2009-10-16 1:36 ` Nicolas Pitre
2009-10-16 2:07 ` Johannes Schindelin
2009-10-16 2:45 ` Nicolas Pitre
2009-10-16 2:56 ` Junio C Hamano
2009-10-17 7:24 ` Sean Estabrooks
2009-10-26 22:22 ` Johannes Schindelin
2009-10-27 3:41 ` Nanako Shiraishi
2009-10-27 10:33 ` Making Git easy to use -- without RTFM, was " Johannes Schindelin
2009-10-27 17:58 ` Avery Pennarun
2009-10-16 0:53 ` Johannes Schindelin
2009-10-16 3:00 ` Junio C Hamano
2009-10-15 7:36 ` James Pickens
2009-10-15 12:54 ` Jakub Narebski
2009-10-15 14:11 ` Björn Steinbrink
2009-10-15 19:03 ` Nicolas Pitre
2009-10-15 15:36 ` Daniel Barkalow
2009-10-15 16:29 ` Michael J Gruber [this message]
2009-10-15 19:07 ` Nicolas Pitre
2009-10-15 19:22 ` Daniel Barkalow
2009-10-15 22:56 ` Thomas Rast
2009-10-15 18:51 ` Nicolas Pitre
2009-10-15 19:52 ` Junio C Hamano
2009-10-15 21:26 ` Jeff King
2009-10-15 21:54 ` Junio C Hamano
2009-10-15 22:08 ` Junio C Hamano
2009-10-15 23:16 ` Nicolas Pitre
2009-10-15 23:47 ` James Pickens
2009-10-16 0:34 ` Nicolas Pitre
2009-10-16 0:43 ` Johannes Schindelin
2009-10-16 5:03 ` Björn Steinbrink
2009-10-15 22:16 ` Jeff King
2009-10-15 22:17 ` Jeff King
2009-10-16 4:29 ` Björn Steinbrink
2009-10-16 6:02 ` Daniel Barkalow
2009-10-16 8:27 ` Björn Steinbrink
2009-10-16 15:44 ` Nicolas Pitre
2009-10-15 19:31 ` Daniel Barkalow
2009-10-15 20:34 ` Junio C Hamano
2009-10-15 21:35 ` Daniel Barkalow
2009-10-15 21:48 ` Nicolas Pitre
2009-10-16 12:15 ` Julian Phillips
2009-10-16 14:30 ` Björn Steinbrink
2009-10-16 17:31 ` Julian Phillips
2009-10-16 18:29 ` Daniel Barkalow
2009-10-16 19:05 ` Junio C Hamano
2009-10-16 19:48 ` Julian Phillips
2009-10-16 20:19 ` Nicolas Pitre
2009-10-17 15:15 ` Julian Phillips
2009-10-17 17:04 ` Björn Steinbrink
2009-10-17 17:35 ` Julian Phillips
2009-10-17 17:48 ` Björn Steinbrink
2009-10-17 22:28 ` Julian Phillips
2009-10-16 20:19 ` Junio C Hamano
2009-10-17 15:32 ` Julian Phillips
2009-10-17 17:43 ` Junio C Hamano
2009-10-17 22:19 ` Julian Phillips
2009-10-17 7:55 ` Björn Steinbrink
2009-10-17 8:11 ` Junio C Hamano
2009-10-17 8:40 ` Björn Steinbrink
2009-10-17 9:04 ` Junio C Hamano
2009-10-17 17:07 ` James Pickens
2009-10-17 19:41 ` Björn Steinbrink
2009-10-18 22:47 ` Junio C Hamano
2009-10-19 8:44 ` Björn Steinbrink
2009-10-17 15:02 ` Julian Phillips
2009-10-14 23:52 ` Eric Raible
2009-10-16 22:36 ` Christoph Bartoschek
2009-10-17 7:43 ` Junio C Hamano
2009-10-17 8:19 ` Björn Steinbrink
2009-10-17 17:42 ` Junio C Hamano
2009-10-17 20:35 ` Daniel Barkalow
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=4AD74DE6.9010800@drmicha.warpmail.net \
--to=git@drmicha.warpmail.net \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jaysoffian@gmail.com \
--cc=jepicken@gmail.com \
--cc=nico@fluxnic.net \
--cc=peff@peff.net \
/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).