Re: [PATCH 1/5] t1508 (at-combinations): more tests; document failures
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:06
Jeff King [off-list ref] writes:
On Thu, May 02, 2013 at 02:34:01AM +0530, Ramkumar Ramachandra wrote:quoted
Junio C Hamano wrote:quoted
Just making sure. HEAD@{$n} and @{$n} for non-negative $n mean totally different things. @{0} and HEAD@{0} are almost always the same, and @{1} and HEAD@{1} may often happen to be the same, but as a blanket statement, I find "Since HEAD is implicit in @{}" very misleading.When will they be different? I'm looking at this from the parser's point of view: when the part before @{} is missing, we dwim a "HEAD".The difference is that HEAD@{} refers to HEAD's reflog, but @{} refers to the reflog of the branch pointed to by HEAD. For example, try: git init repo && cd repo git commit --allow-empty -m one && git commit --allow-empty -m two && git checkout HEAD^ && git commit --allow-empty -m three && git checkout master && for i in 0 1 2; do echo "HEAD@{$i}: $(git log -1 --oneline HEAD@{$i} 2>&1)" echo " @{$i}: $(git log -1 --oneline @{$i} 2>&1)" done which produces: HEAD@{0}: 1fbb097 two @{0}: 1fbb097 two HEAD@{1}: 42f3f4d three @{1}: 1089d0e one HEAD@{2}: 1089d0e one @{2}: fatal: Log for '' only has 2 entries. Unless your reflogs are screwed up, the 0th reflog should always point to the same commit (since you just moved HEAD there), but beyond that there is not necessarily any relation. And even for the 0th reflog entry, the reflog information is not the same. Try this on the repo above: echo "HEAD@{0}: $(git log -g -1 --format='%gd %gs' HEAD@{0})" echo " @{0}: $(git log -g -1 --format='%gd %gs' @{0})" which yields: HEAD@{0}: HEAD@{0} checkout: moving from ... to master @{0}: master@{0} commit: two -Peff
Thanks for helping with a basic education I found no time for myself today.