Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 16 Oct 2009, Björn Steinbrink wrote:

> On 2009.10.15 14:54:18 -0700, Junio C Hamano wrote:
> > 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.
> 
> I don't have any numbers backing this up, but my gut feeling says that
> most cases of "Where have my commits gone?" that I have seen on #git
> were due to "git checkout HEAD~2"-like actions. Either because the user
> assumed SVN-like behaviour (you can't commit until you do "svn up", like
> "git reset --merge HEAD@{1}") or thought that "git checkout
> <committish>" would act like "git reset --hard <committish>".
> 
> For the latter I fail to envision any solution except for
> education (and I have no idea why the user expected checkout to work
> like reset).
> 
> The former can be solved by the proposed extra information in HEAD,
> forbidding changes to HEAD that make it reference a commit that's not
> reachable through the head stored in the extra information[*1*] and providing
> some command that acts like "svn up".
> 
> This seems quite different from the plain "forbid committing" or "detach
> and know how you get there", but more like "detach and know where you're
> coming from".

What's the state before the "git checkout HEAD~2"?

If it's:

$ git checkout origin/some-obscure-branch
(get curious about the commit a bit back)
$ git checkout HEAD~2

And then the user doesn't know how to get back to where they were, then it 
should work if git had stored "origin/some-obscure-branch~2" at this point 
(having substituted "origin/some-obscure-branch" (the previous extra info) 
for HEAD). Then we could have a "git up" that would discard modifiers from 
the extra info and check that out. Or users might find "git checkout 
origin/some-obscure-branch" obvious enough if git is reporting something 
related.

I know I often find my git.git repos on "* (no branch)", and I don't 
remember if I checked that out as origin/master or origin/next. And that's 
an important clue as to when I'd been doing there previously, and what I 
might want to do next. Perhaps these users are having a similar problem, 
where they're relying on git to remember what they were doing?

	-Daniel
*This .sig left intentionally blank*

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]