Re: [PATCH 3/3] prevent HEAD reflog to be interpreted as current branch reflog

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

 



Andy Parkins <andyparkins@xxxxxxxxx> writes:

> Please, please, HEAD@{} should /always/ be an alias for <current_branch>@{}.

I was confused, and after thinking about it a bit, I agree with
Nico's new @{} shorthand.

HEAD means "current" everywhere in git, but it does not
necessarily mean "current branch" (i.e. detached HEAD).  

But it almost always means the "current commit".  It is the
commit "git commit" builds on top of, and "git diff --cached"
and "git status" compare against.  It means the current branch
only in very limited contexts (exactly when we want a branch
name to operate on --- resetting and growing the branch tip via
commit/rebase/etc.).

Reflog is a vehicle to go back in time and time machines have
interesting interaction with the notion of "current".

HEAD@{5.minutes.ago} could mean "dereference HEAD symref to find
out what branch we are on RIGHT NOW, and then find out where the
tip of that branch was 5 minutes ago".  Alternatively it could
mean "what is the commit I would have referred to as HEAD 5
minutes ago, e.g. if I did "git show HEAD" back then".

I think both are useful, and the former semantics is given by
the "emptiness followed by @{} refers to the current branch"
shorthand, while yet-to-be-implemented HEAD@{} would give the
latter.

And I think the way Nico defined 'HEAD@{...}' is more consistent
with the way 'master@{...}' behaves; they both mean "what commit
did I mean if I said this at time ...".

I am not going to seriously suggest this, but it is conceivable
to want to be able to say things like "master^2~28@{yesterday}".
Naturally it would mean the 28th generation parent of the other
branch I merged into my 'master' branch yesterday (i.e. it asks
the question: "which commit would I have seen if I said "git
show master^2~28" yesterday?").

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]