git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <gitster@pobox.com>,
	Nicolas Pitre <nico@fluxnic.net>,
	James Pickens <jepicken@gmail.com>,
	Daniel Barkalow <barkalow@iabervon.org>,
	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 14:54:18 -0700	[thread overview]
Message-ID: <7v1vl42uid.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20091015212632.GA13180@coredump.intra.peff.net> (Jeff King's message of "Thu\, 15 Oct 2009 17\:26\:32 -0400")

Jeff King <peff@peff.net> writes:

> On Thu, Oct 15, 2009 at 12:52:55PM -0700, Junio C Hamano wrote:
>
>> I like James's suggestion to allow us to store refs other than refs/heads/
>> in HEAD to denote this state, and keep commit and reset from updating such
>> a ref through updating HEAD.
>
> Didn't we already consider and reject this the first time around? For
> example, this thread has a ton of stuff about how we shouldn't prevent
> people from making commits on the wandering state:
>
>   http://thread.gmane.org/gmane.comp.version-control.git/35777/focus=35835
>
> And here's me even advocating this exact strategy (and I'm sure I didn't
> think of it; it's probably discussed elsewhere, too):
>
>   http://thread.gmane.org/gmane.comp.version-control.git/35777/focus=35858
>
> Not that I am not necessarily complaining, but I just hope this decision
> is "with new-found knowledge we are revisiting this decision" and not
> "we totally forgot about what came before".

Maybe we are reading different messages in the same message.

My understanding of James's suggestion is:

 (1) "git checkout $token" makes HEAD point at the refname dwim_ref()
     expands $token to, iff dwim_ref() is happy, and otherwise detaches
     HEAD;

 (2) "git commit" (and other things like "git reset HEAD^" that updates
     underlying ref thru updates to HEAD when HEAD is a symref) rejects
     when HEAD points at a ref outside refs/heads/, but works when HEAD
     points at a local branch, or when HEAD is detached.

As a consequence:

    $ git checkout v1.6.5      ;# does not detach, cannot update
    $ git symbolic-ref HEAD
    refs/tags/v1.6.5
    $ git checkout origin/next ;# ditto
    $ git symbolic-ref HEAD
    refs/remotes/origin/next

These are often done by sightseers, and we can add instructions to fork
and record upon an attempt to "git commit".

As a bonus, we get Daniel's extra information for detached HEAD for free,
as we can just read HEAD and learn what it points at.  We need to design
what "git branch" should say in this case.

This is backward incompatible, and makes what experts are used to do
slightly cumbersome to spell, i.e.

    $ git checkout v1.6.5^0      ;# detaches and can commit
    $ git checkout origin/next^0 ;# ditto
    $ git checkout $(git merge-base master sp/smart-http) ;# ditto

These detach, and I can apply the updates series to the same base as the
previous round on an unnamed branch.

So in other words, the semantics for detached HEAD case does not change at
all.  We never forbid committing or resetting while on detached HEAD, as
it is meant to be an easy way to get an unnamed throw-away state that is
not even worth coming up with a unique temporary branch name, and I do not
think the above contradicts with what was said in 35835.

We used to have only two states on HEAD: either on a local branch or
detached.  James is introducing another state: on a ref that is not a
local branch.

As that is useful for common sightseer tasks, we can afford to forbid
committing or updating for safety and we do not have to worry about
hurting the established usefulness of how detached HEAD works.

One drawback is that you cannot be in this sightseeing state without
having a ref.  You can have "look-but-not-touch" checkout on origin/next
or origin/master, but you cannot sightsee the parent of origin/next the
same way (it would detach).  I do not know if it is a big deal, though.

If it is very important to support:

    $ git checkout --look-but-not-touch origin/next^

then James's approach would not be very useful, as we do have to detach
HEAD and implement the "do not touch" logic for detached HEAD state
anyway, so we might just use the same logic we would use for origin/next^
when checking out origin/next itself.

  reply	other threads:[~2009-10-15 21:57 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
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 [this message]
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=7v1vl42uid.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --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).