git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <junkio@cox.net>
Date
Feb 3, 2007, 03:04 UTC
Message-ID
<7v4pq4djre.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200702021308.48599.andyparkins@gmail.com>
Andy Parkins <andyparkins@gmail.com> 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?").

Previous: Andy Parkins
Message 35 of 35 in “prevent HEAD reflog to be interpreted as current branch reflog”
  1. 3/3 prevent HEAD reflog to be interpreted as current branch reflogNicolas Pitre, Feb 1, 2007
  2. Shawn O. PearceFeb 1, 2007
  3. Junio C HamanoFeb 1, 2007
  4. Simon 'corecode' SchubertFeb 1, 2007
  5. Nicolas PitreFeb 1, 2007
  6. Matthias LederhoferFeb 1, 2007
  7. 4/3 provide a nice @{...} syntax to always mean the current branch reflogNicolas Pitre, Feb 1, 2007
  8. 5/3 , was Re: [PATCH 4/3] provide a nice @{...} syntax to always mean the current branch reflogJohannes Schindelin, Feb 1, 2007
  9. 6/3 , was Re: [PATCH 5/3], was Re: [PATCH 4/3] provide a nice @{...} syntax to always mean the current branch reflogJohannes Schindelin, Feb 1, 2007
  10. Junio C HamanoFeb 2, 2007
  11. Nicolas PitreFeb 1, 2007
  12. Jakub NarebskiFeb 2, 2007
  13. Johannes SchindelinFeb 2, 2007
  14. Lars HjemliFeb 2, 2007
  15. Andy ParkinsFeb 2, 2007
  16. Nicolas PitreFeb 2, 2007
  17. Nicolas PitreFeb 2, 2007
  18. Andy ParkinsFeb 2, 2007
  19. Simon 'corecode' SchubertFeb 2, 2007
  20. Nicolas PitreFeb 2, 2007
  21. Mark WoodingFeb 3, 2007
  22. Andy ParkinsFeb 3, 2007
  23. Jakub NarebskiFeb 2, 2007
  24. Simon 'corecode' SchubertFeb 2, 2007
  25. Simon 'corecode' SchubertFeb 2, 2007
  26. Nicolas PitreFeb 2, 2007
  27. Lars HjemliFeb 2, 2007
  28. Johannes SchindelinFeb 5, 2007
  29. Shawn O. PearceFeb 5, 2007
  30. Johannes SchindelinFeb 5, 2007
  31. Lars HjemliFeb 5, 2007
  32. Andy ParkinsFeb 2, 2007
  33. Rogan DawesFeb 2, 2007
  34. Andy ParkinsFeb 2, 2007
  35. Junio C HamanoFeb 3, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.