Thread (6 messages) flat view 6 messages, 5 authors, 2016-06-15

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:52

Andy Parkins [off-list ref] 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?").
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help