From: Jeff King <peff@peff.net>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Git List <git@vger.kernel.org>,
Felipe Contreras <felipe.contreras@gmail.com>,
Duy Nguyen <pclouds@gmail.com>
Subject: Re: [PATCH 1/5] t1508 (at-combinations): more tests; document failures
Date: Wed, 1 May 2013 17:16:13 -0400 [thread overview]
Message-ID: <20130501211613.GA15392@sigill.intra.peff.net> (raw)
In-Reply-To: <CALkWK0nL+UvjsUKh6v4x_MaWJmsU6Uh_gh82iE7UT0UE-ZMt0g@mail.gmail.com>
On Thu, May 02, 2013 at 02:34:01AM +0530, Ramkumar Ramachandra wrote:
> Junio C Hamano wrote:
> > 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
next prev parent reply other threads:[~2013-05-01 21:16 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-01 16:20 [PATCH 0/5] A natural solution to the @ -> HEAD problem Ramkumar Ramachandra
2013-05-01 16:20 ` [PATCH 1/5] t1508 (at-combinations): more tests; document failures Ramkumar Ramachandra
2013-05-01 18:53 ` Junio C Hamano
2013-05-01 21:04 ` Ramkumar Ramachandra
2013-05-01 21:16 ` Jeff King [this message]
2013-05-01 22:01 ` Ramkumar Ramachandra
2013-05-01 22:54 ` Junio C Hamano
2013-05-02 2:22 ` Felipe Contreras
2013-05-02 9:07 ` Ramkumar Ramachandra
2013-05-02 9:45 ` Felipe Contreras
2013-05-02 11:03 ` Ramkumar Ramachandra
2013-05-02 11:36 ` Ramkumar Ramachandra
2013-05-02 16:45 ` Felipe Contreras
2013-05-02 16:56 ` Ramkumar Ramachandra
2013-05-02 17:01 ` Felipe Contreras
2013-05-02 17:02 ` Ramkumar Ramachandra
2013-05-02 17:08 ` Felipe Contreras
2013-05-02 17:09 ` Ramkumar Ramachandra
2013-05-04 8:10 ` David Aguilar
2013-05-04 8:16 ` David Aguilar
2013-05-01 16:20 ` [PATCH 2/5] sha1_name.c: don't waste cycles in the @-parsing loop Ramkumar Ramachandra
2013-05-01 17:57 ` Felipe Contreras
2013-05-01 18:48 ` Ramkumar Ramachandra
2013-05-02 0:04 ` Junio C Hamano
2013-05-01 16:20 ` [PATCH 3/5] sha1_name.c: simplify @-parsing in get_sha1_basic() Ramkumar Ramachandra
2013-05-01 18:09 ` Felipe Contreras
2013-05-01 18:36 ` Ramkumar Ramachandra
2013-05-01 18:54 ` Jonathan Nieder
2013-05-01 19:55 ` Ramkumar Ramachandra
2013-05-01 19:23 ` Felipe Contreras
2013-05-01 19:40 ` Ramkumar Ramachandra
2013-05-01 22:18 ` Felipe Contreras
2013-05-01 22:26 ` Ramkumar Ramachandra
2013-05-01 22:39 ` Felipe Contreras
2013-05-01 22:06 ` Ramkumar Ramachandra
2013-05-01 16:20 ` [PATCH 4/5] remote.c: teach branch_get() to treat symrefs other than HEAD Ramkumar Ramachandra
2013-05-01 18:16 ` Felipe Contreras
2013-05-01 18:44 ` Ramkumar Ramachandra
2013-05-01 19:28 ` Felipe Contreras
2013-05-01 19:50 ` Ramkumar Ramachandra
2013-05-01 20:48 ` Felipe Contreras
2013-05-01 20:57 ` Ramkumar Ramachandra
2013-05-01 22:23 ` Felipe Contreras
2013-05-01 16:20 ` [PATCH 5/5] refs.c: make @ a pseudo-ref alias to HEAD Ramkumar Ramachandra
2013-05-01 18:20 ` Felipe Contreras
2013-05-01 19:00 ` Ramkumar Ramachandra
2013-05-01 19:31 ` Felipe Contreras
2013-05-01 19:51 ` Ramkumar Ramachandra
2013-05-01 21:49 ` [PATCH 0/5] A natural solution to the @ -> HEAD problem Ramkumar Ramachandra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130501211613.GA15392@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=artagnon@gmail.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).