Re: [PATCH] refspec: make @ a valid refspec
- From
Jacob Keller <jacob.keller@gmail.com>
- Date
- Nov 24, 2020, 23:47 UTC
- Message-ID
- <CA+P7+xp_iTnkdbWoDSRZustvjk5BRJOPD=snae8D1Fe_uXqO7g@mail.gmail.com>
- In-Reply-To
- <xmqqk0uagxei.fsf@gitster.c.googlers.com>
On Tue, Nov 24, 2020 at 3:14 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
>
> Jacob Keller <jacob.keller@gmail.com> writes:
>
> >> Worse yet, @{4} does not refer to HEAD@{4} but refers to the 4-th
> >> previous commit the current branch pointed at, so a mnemonic for the
> >> end user to remember the distinction between the two is that a bare
> >> "@" is different from HEAD, which is a total opposite X-<.
> >>
> >
> > However, @{0} *does* refer to what is currently checked out, which
> > would be head.. So in a sense @ meaning "the current branch" and
> > applying @{0} would always be HEAD, no?
>
> Not really.
>
> It happens to hold true for @{0}, because by definition you couldn't
> have been on a different branch than the current one when you made
> the topmost commit on the current branch. For @{1} and higher, it
> is always "where was the current branch at N commits ago?" which is
> different from "where was the HEAD at N commits ago?", unless you
> always use a single branch and never switch away.
>Right, once you add anything greater than zero it breaks down.. but think about it a little differently: "@{N}" is sort of eliding the branch name, which means we use the current branch. "branch@" (if it were valid syntax) would be eliding the number which means "the most recent version of branch". Thus, eliding both and using just "@" would mean "the most recent version of the current branch", which cannot be anything other than HEAD.
Of course I agree that "@ == HEAD" can't be used to go *backwards* through that logic at all. But if you're moving forwards through it, then "@" on its own can make sense as HEAD, but only as an implication of "the most recent version of the current branch can't be anything else"
Thanks, Jake