{"thread":{"id":"54689","subject":"[PATCH] refspec: make @ a valid refspec","startedAt":"2020-11-22T16:46:46Z","lastAt":"2020-12-04T22:21:45Z","messageCount":13,"participants":["Felipe Contreras","Jeff King","Junio C Hamano","Jacob Keller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"410493","messageId":"20201122164641.2091160-1-felipe.contreras@gmail.com","threadId":"54689","inReplyTo":null,"subject":"[PATCH] refspec: make @ a valid refspec","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-22T16:46:41Z","receivedAt":"2020-11-22T16:46:46Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Since commit 9ba89f484e git learned how to push to a remote branch using\nthe source @, for example:\n\n  git push origin @:master\n\nHowever, if the right-hand side is missing, the push fails:\n\n  git push origin @\n\nIt is obvious what is the desired behavior, and allowing the push makes\nthings more consistent.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n refspec.c             | 5 ++++-\n t/t5511-refspec.sh    | 2 ++\n t/t5516-fetch-push.sh | 9 +++++++++\n 3 files changed, 15 insertions(+), 1 deletion(-)\n\ndiff --git a/refspec.c b/refspec.c\nindex c49347c2d7..adbfb3283a 100644\n--- a/refspec.c\n+++ b/refspec.c\n@@ -71,7 +71,10 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet\n \t}\n \n \titem->pattern = is_glob;\n-\titem->src = xstrndup(lhs, llen);\n+\tif (llen == 1 && *lhs == '@')\n+\t\titem->src = xstrdup(\"HEAD\");\n+\telse\n+\t\titem->src = xstrndup(lhs, llen);\n \tflags = REFNAME_ALLOW_ONELEVEL | (is_glob ? REFNAME_REFSPEC_PATTERN : 0);\n \n \tif (item->negative) {\ndiff --git a/t/t5511-refspec.sh b/t/t5511-refspec.sh\nindex f541f30bc2..f808649de4 100755\n--- a/t/t5511-refspec.sh\n+++ b/t/t5511-refspec.sh\n@@ -58,6 +58,8 @@ test_refspec fetch 'HEAD~4:refs/remotes/frotz/new'\t\tinvalid\n \n test_refspec push 'HEAD'\n test_refspec fetch 'HEAD'\n+test_refspec push '@'\n+test_refspec fetch '@'\n test_refspec push 'refs/heads/ nitfol'\t\t\t\tinvalid\n test_refspec fetch 'refs/heads/ nitfol'\t\t\t\tinvalid\n \ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex d11382f769..12c0c7c06b 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -501,6 +501,15 @@ test_expect_success 'push with config remote.*.push = HEAD' '\n \tcheck_push_result testrepo $the_first_commit heads/local\n '\n \n+test_expect_success 'push with @' '\n+\n+\tmk_test testrepo heads/master &&\n+\tgit checkout master &&\n+\tgit push testrepo @ &&\n+\tcheck_push_result testrepo $the_commit heads/master\n+\n+'\n+\n test_expect_success 'push with remote.pushdefault' '\n \tmk_test up_repo heads/master &&\n \tmk_test down_repo heads/master &&\n-- \n2.29.2\n\n"},{"id":"410642","messageId":"X7y5Wxu1eY4k6753@coredump.intra.peff.net","threadId":"54689","inReplyTo":"20201122164641.2091160-1-felipe.contreras@gmail.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-11-24T07:42:19Z","receivedAt":"2020-11-24T07:42:36Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Nov 22, 2020 at 10:46:41AM -0600, Felipe Contreras wrote:\n\n> Since commit 9ba89f484e git learned how to push to a remote branch using\n> the source @, for example:\n> \n>   git push origin @:master\n> \n> However, if the right-hand side is missing, the push fails:\n> \n>   git push origin @\n\nYeah, I think this probably makes sense. I find the \"@:master\" refspec a\nbit weird, but it is a natural consequence of parsing \"@\" on the LHS as\nan arbitrary object to lookup (not a ref).\n\nI did find the implementation a little curious:\n\n> -\titem->src = xstrndup(lhs, llen);\n> +\tif (llen == 1 && *lhs == '@')\n> +\t\titem->src = xstrdup(\"HEAD\");\n> +\telse\n> +\t\titem->src = xstrndup(lhs, llen);\n\nWe already know we are parsing the LHS, so why must we expand a bare @,\nwhereas we do not in \"@:master\". The answer is that the \"@\" is not\nexpanded until later, and parse_refspec() gets unhappy that \"@\" is also\nthe implicit value for the RHS.\n\nThis also means that:\n\n  git push origin @:foo\n\nwill now work when \"foo\" doesn't exist on the remote (if we find no\nmatch on the remote, we guess how it should be fully qualified; one of\nour heuristics involves seeing that HEAD points to a branch, and\ntherefore the other side should be a branch, too).\n\n> It is obvious what is the desired behavior, and allowing the push makes\n> things more consistent.\n\nThis same code is used by fetch, as well. There \"git fetch origin\n@:master\" does not work at all now. This would make that work (to fetch\nthe remote HEAD into master), along with \"git fetch origin @\" (into\nFETCH_HEAD only). Both seem sensible, and I cannot think of any other\nreasonable meaning for them.\n\n> ---\n>  refspec.c             | 5 ++++-\n>  t/t5511-refspec.sh    | 2 ++\n>  t/t5516-fetch-push.sh | 9 +++++++++\n>  3 files changed, 15 insertions(+), 1 deletion(-)\n\nWould we want to cover the extra cases I mentioned above (@:foo, and the\ntwo fetches), as well?\n\nI wondered if there was a good place to mention this in the refspec\ndocumentation, but it may just be an obvious fallout of the \"@ is a\nshortcut for HEAD\" definition in gitrevisions(7). The only change is\nthat we're resolving the shortcut sooner so that more code can take\nadvantage of it.\n\n-Peff\n"},{"id":"410698","messageId":"xmqqlfeqjzi1.fsf@gitster.c.googlers.com","threadId":"54689","inReplyTo":"X7y5Wxu1eY4k6753@coredump.intra.peff.net","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-11-24T20:01:10Z","receivedAt":"2020-11-24T20:01:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I wondered if there was a good place to mention this in the refspec\n> documentation, but it may just be an obvious fallout of the \"@ is a\n> shortcut for HEAD\" definition in gitrevisions(7). The only change is\n> that we're resolving the shortcut sooner so that more code can take\n> advantage of it.\n\nI too find that \"@ is a shortcut for HEAD\" looks ugly both at the UI\nlevel and at the implementation level [*1*], but as long as we have\nit, it is good to try to be consistent and allow \"@\" everywhere\nwhere one would write \"HEAD\" in places where it is syntacitically\ninfeasible---at least we would be consistently ugly that way ;-).\n\nThe title of the change may want to be clarified to help readers of\n\"git shortlog\".  It's not like it is only changing \"@\" and no other\nvariants valid refspec, but it forces readers to make sure that the\nauthor did not forget to deal with \":@\", \"src:@\", \"@:dst\", etc.\n\"make @ a synonym to HEAD in refspec\" or something along the line,\nperhaps.\n\n\n[Footnote]\n\n*1* I shouldn't complain too much, as my own invention to silently\nturn \"-\" given from the command line into \"@{-1}\" is ugly at the\ncode level the same way, even though it may be better at the UI\nlevel.\n"},{"id":"410720","messageId":"CAMP44s0PwJ8qEuCCpavshpm0GqV8p37rF8McR2=gdCk2kj+JiQ@mail.gmail.com","threadId":"54689","inReplyTo":"xmqqlfeqjzi1.fsf@gitster.c.googlers.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-24T22:01:45Z","receivedAt":"2020-11-24T22:02:19Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Nov 24, 2020 at 2:01 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Jeff King <peff@peff.net> writes:\n>\n> > I wondered if there was a good place to mention this in the refspec\n> > documentation, but it may just be an obvious fallout of the \"@ is a\n> > shortcut for HEAD\" definition in gitrevisions(7). The only change is\n> > that we're resolving the shortcut sooner so that more code can take\n> > advantage of it.\n>\n> I too find that \"@ is a shortcut for HEAD\" looks ugly both at the UI\n> level and at the implementation level [*1*], but as long as we have\n> it, it is good to try to be consistent and allow \"@\" everywhere\n> where one would write \"HEAD\" in places where it is syntacitically\n> infeasible---at least we would be consistently ugly that way ;-).\n\nBeauty is in the eye of the beholder.\n\nI find HEAD to be an eyesore.\n\n> The title of the change may want to be clarified to help readers of\n> \"git shortlog\".  It's not like it is only changing \"@\" and no other\n> variants valid refspec, but it forces readers to make sure that the\n> author did not forget to deal with \":@\", \"src:@\", \"@:dst\", etc.\n> \"make @ a synonym to HEAD in refspec\" or something along the line,\n> perhaps.\n\nRight. I didn't notice it changed the semantics of those.\n\nGiven that, your suggested title makes more sense.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"410727","messageId":"xmqqo8jmgyrd.fsf@gitster.c.googlers.com","threadId":"54689","inReplyTo":"CAMP44s0PwJ8qEuCCpavshpm0GqV8p37rF8McR2=gdCk2kj+JiQ@mail.gmail.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-11-24T22:45:26Z","receivedAt":"2020-11-24T22:45:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n>> I too find that \"@ is a shortcut for HEAD\" looks ugly both at the UI\n>> level and at the implementation level [*1*], but as long as we have\n>> it, it is good to try to be consistent and allow \"@\" everywhere\n>> where one would write \"HEAD\" in places where it is syntacitically\n>> infeasible---at least we would be consistently ugly that way ;-).\n>\n> Beauty is in the eye of the beholder.\n\nUsing \"@\" is rather \"illogical\" than \"ugly\", and at that point it is\nnot so subjective.\n\n@-mark leads a suffix that applies some \"magic\" to what comes before\nit (e.g. next@{1}, maint@{2.weeks.ago}, and master@{-1}).  Making @\na synonym for HEAD means '@' sometimes means a ref and most of the\ntime means the introducer of magic that applies to a ref.\n\nWorse yet, @{4} does not refer to HEAD@{4} but refers to the 4-th\nprevious commit the current branch pointed at, so a mnemonic for the\nend user to remember the distinction between the two is that a bare\n\"@\" is different from HEAD, which is a total opposite X-<.\n\nThis is all water under the bridge, though ;-)\n\n> Given that, your suggested title makes more sense.\n\nSounds good.\n"},{"id":"410728","messageId":"CA+P7+xr8_s0Fq_TGjDjHEPpGJ8Br5x7omY1fsg0HjcXjutyRkg@mail.gmail.com","threadId":"54689","inReplyTo":"xmqqo8jmgyrd.fsf@gitster.c.googlers.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2020-11-24T22:52:19Z","receivedAt":"2020-11-24T22:52:31Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Tue, Nov 24, 2020 at 2:45 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n> >> I too find that \"@ is a shortcut for HEAD\" looks ugly both at the UI\n> >> level and at the implementation level [*1*], but as long as we have\n> >> it, it is good to try to be consistent and allow \"@\" everywhere\n> >> where one would write \"HEAD\" in places where it is syntacitically\n> >> infeasible---at least we would be consistently ugly that way ;-).\n> >\n> > Beauty is in the eye of the beholder.\n>\n> Using \"@\" is rather \"illogical\" than \"ugly\", and at that point it is\n> not so subjective.\n>\n> @-mark leads a suffix that applies some \"magic\" to what comes before\n> it (e.g. next@{1}, maint@{2.weeks.ago}, and master@{-1}).  Making @\n> a synonym for HEAD means '@' sometimes means a ref and most of the\n> time means the introducer of magic that applies to a ref.\n>\n> Worse yet, @{4} does not refer to HEAD@{4} but refers to the 4-th\n> previous commit the current branch pointed at, so a mnemonic for the\n> end user to remember the distinction between the two is that a bare\n> \"@\" is different from HEAD, which is a total opposite X-<.\n>\n\nHowever, @{0} *does* refer to what is currently checked out, which\nwould be head.. So in a sense @ meaning \"the current branch\" and\napplying @{0} would always be HEAD, no?\n\nI think it sort of works, but yea it is a bit messy.\n\nThanks,\nJake\n"},{"id":"410729","messageId":"xmqqk0uagxei.fsf@gitster.c.googlers.com","threadId":"54689","inReplyTo":"CA+P7+xr8_s0Fq_TGjDjHEPpGJ8Br5x7omY1fsg0HjcXjutyRkg@mail.gmail.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-11-24T23:14:45Z","receivedAt":"2020-11-24T23:14:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jacob Keller <jacob.keller@gmail.com> writes:\n\n>> Worse yet, @{4} does not refer to HEAD@{4} but refers to the 4-th\n>> previous commit the current branch pointed at, so a mnemonic for the\n>> end user to remember the distinction between the two is that a bare\n>> \"@\" is different from HEAD, which is a total opposite X-<.\n>>\n>\n> However, @{0} *does* refer to what is currently checked out, which\n> would be head.. So in a sense @ meaning \"the current branch\" and\n> applying @{0} would always be HEAD, no?\n\nNot really.  \n\nIt happens to hold true for @{0}, because by definition you couldn't\nhave been on a different branch than the current one when you made\nthe topmost commit on the current branch.  For @{1} and higher, it\nis always \"where was the current branch at N commits ago?\" which is\ndifferent from \"where was the HEAD at N commits ago?\", unless you\nalways use a single branch and never switch away.\n\n"},{"id":"410731","messageId":"CA+P7+xp_iTnkdbWoDSRZustvjk5BRJOPD=snae8D1Fe_uXqO7g@mail.gmail.com","threadId":"54689","inReplyTo":"xmqqk0uagxei.fsf@gitster.c.googlers.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2020-11-24T23:47:05Z","receivedAt":"2020-11-24T23:48:45Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Tue, Nov 24, 2020 at 3:14 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Jacob Keller <jacob.keller@gmail.com> writes:\n>\n> >> Worse yet, @{4} does not refer to HEAD@{4} but refers to the 4-th\n> >> previous commit the current branch pointed at, so a mnemonic for the\n> >> end user to remember the distinction between the two is that a bare\n> >> \"@\" is different from HEAD, which is a total opposite X-<.\n> >>\n> >\n> > However, @{0} *does* refer to what is currently checked out, which\n> > would be head.. So in a sense @ meaning \"the current branch\" and\n> > applying @{0} would always be HEAD, no?\n>\n> Not really.\n>\n> It happens to hold true for @{0}, because by definition you couldn't\n> have been on a different branch than the current one when you made\n> the topmost commit on the current branch.  For @{1} and higher, it\n> is always \"where was the current branch at N commits ago?\" which is\n> different from \"where was the HEAD at N commits ago?\", unless you\n> always use a single branch and never switch away.\n>\n\nRight, once you add anything greater than zero it breaks down.. but\nthink about it a little differently: \"@{N}\" is sort of eliding the\nbranch name, which means we use the current branch. \"branch@\" (if it\nwere valid syntax) would be eliding the number which means \"the most\nrecent version of branch\". Thus, eliding both and using just \"@\" would\nmean \"the most recent version of the current branch\", which cannot be\nanything other than HEAD.\n\nOf course I agree that \"@ == HEAD\" can't be used to go *backwards*\nthrough that logic at all. But if you're moving forwards through it,\nthen \"@\" on its own can make sense as HEAD, but only as an implication\nof \"the most recent version of the current branch can't be anything\nelse\"\n\nThanks,\nJake\n"},{"id":"410732","messageId":"CAMP44s3f_cO61YVjvwsiswKQRESznOFn7KTshgv06a=zVRPLug@mail.gmail.com","threadId":"54689","inReplyTo":"xmqqo8jmgyrd.fsf@gitster.c.googlers.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-25T00:09:10Z","receivedAt":"2020-11-25T00:09:25Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Nov 24, 2020 at 4:45 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n> >> I too find that \"@ is a shortcut for HEAD\" looks ugly both at the UI\n> >> level and at the implementation level [*1*], but as long as we have\n> >> it, it is good to try to be consistent and allow \"@\" everywhere\n> >> where one would write \"HEAD\" in places where it is syntacitically\n> >> infeasible---at least we would be consistently ugly that way ;-).\n> >\n> > Beauty is in the eye of the beholder.\n>\n> Using \"@\" is rather \"illogical\" than \"ugly\", and at that point it is\n> not so subjective.\n\nI disagree.\n\n> @-mark leads a suffix that applies some \"magic\" to what comes before\n> it (e.g. next@{1}, maint@{2.weeks.ago}, and master@{-1}).  Making @\n> a synonym for HEAD means '@' sometimes means a ref and most of the\n> time means the introducer of magic that applies to a ref.\n\nAll this was discussed back then [1].\n\nIn my mind \"@\" means the same as \"@{0}\", and \"@{0}~0^0\". So I don't\nsee any inconsistency.\n\nYour mind may be different.\n\n> Worse yet, @{4} does not refer to HEAD@{4} but refers to the 4-th\n> previous commit the current branch pointed at, so a mnemonic for the\n> end user to remember the distinction between the two is that a bare\n> \"@\" is different from HEAD, which is a total opposite X-<.\n\nOnce again; each user is different. Personally I never use these\nshortcuts precisely because I'm not entirely sure what I want to tell\ngit. I just use \"git reflog\" and manually pick the commit id I want.\n\nI suspect most users don't use this notation either, so even if\nthere's an inconsistency (which I'm not entirely sure the @ shortcut\nhas anything to do with it), it would affect few users.\n\n> This is all water under the bridge, though ;-)\n\nIndeed.\n\nAnd I take it we can agree that it's better to have instructions like:\n\n  git push -u origin @\n\nRather than:\n\n  git push -u origin master\n\nRegardless of what some users think of \"@\", it's less contentious than \"master\".\n\nCheers.\n\n[1] https://lore.kernel.org/git/1367264106-2351-1-git-send-email-felipe.contreras@gmail.com/\n\n-- \nFelipe Contreras\n"},{"id":"410734","messageId":"CAMP44s2Yt_Vin1rLg-q9Jt8pA+bTDMjYbwSaGHZLgoNKL_nEvg@mail.gmail.com","threadId":"54689","inReplyTo":"xmqqk0uagxei.fsf@gitster.c.googlers.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-25T00:14:19Z","receivedAt":"2020-11-25T00:14:54Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Nov 24, 2020 at 5:14 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Jacob Keller <jacob.keller@gmail.com> writes:\n\n> > However, @{0} *does* refer to what is currently checked out, which\n> > would be head.. So in a sense @ meaning \"the current branch\" and\n> > applying @{0} would always be HEAD, no?\n>\n> Not really.\n>\n> It happens to hold true for @{0}, because by definition you couldn't\n> have been on a different branch than the current one when you made\n> the topmost commit on the current branch.  For @{1} and higher, it\n> is always \"where was the current branch at N commits ago?\" which is\n> different from \"where was the HEAD at N commits ago?\", unless you\n> always use a single branch and never switch away.\n\nBut @{0} is always the same as HEAD@{0}, which is always the same as @.\n\n-- \nFelipe Contreras\n"},{"id":"410735","messageId":"CAMP44s0F9TijOQ=JvosX_3z_F6wRtKe3gF=0NxrqucW4gAuzHQ@mail.gmail.com","threadId":"54689","inReplyTo":"CA+P7+xp_iTnkdbWoDSRZustvjk5BRJOPD=snae8D1Fe_uXqO7g@mail.gmail.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-25T00:28:37Z","receivedAt":"2020-11-25T00:28:51Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Nov 24, 2020 at 5:47 PM Jacob Keller <jacob.keller@gmail.com> wrote:\n>\n> On Tue, Nov 24, 2020 at 3:14 PM Junio C Hamano <gitster@pobox.com> wrote:\n> >\n> > Jacob Keller <jacob.keller@gmail.com> writes:\n> >\n> > >> Worse yet, @{4} does not refer to HEAD@{4} but refers to the 4-th\n> > >> previous commit the current branch pointed at, so a mnemonic for the\n> > >> end user to remember the distinction between the two is that a bare\n> > >> \"@\" is different from HEAD, which is a total opposite X-<.\n> > >>\n> > >\n> > > However, @{0} *does* refer to what is currently checked out, which\n> > > would be head.. So in a sense @ meaning \"the current branch\" and\n> > > applying @{0} would always be HEAD, no?\n> >\n> > Not really.\n> >\n> > It happens to hold true for @{0}, because by definition you couldn't\n> > have been on a different branch than the current one when you made\n> > the topmost commit on the current branch.  For @{1} and higher, it\n> > is always \"where was the current branch at N commits ago?\" which is\n> > different from \"where was the HEAD at N commits ago?\", unless you\n> > always use a single branch and never switch away.\n>\n> Right, once you add anything greater than zero it breaks down.. but\n> think about it a little differently: \"@{N}\" is sort of eliding the\n> branch name, which means we use the current branch. \"branch@\" (if it\n> were valid syntax) would be eliding the number which means \"the most\n> recent version of branch\". Thus, eliding both and using just \"@\" would\n> mean \"the most recent version of the current branch\", which cannot be\n> anything other than HEAD.\n\nYes, but to me HEAD is supposed to mean \"the current branch\", so\n\"branch@{1}\" and \"HEAD@{1}\" should be the same, and they are not. So\nto me they are the other way around.\n\n1. branch@{1}, HEAD@{1}, @@{1}: current branch 1 commit ago\n2. @{1}: 1 commit ago in general\n\nSince it's the opposite of what I would expect, I simply don't use\nthese notations.\n\n-- \nFelipe Contreras\n"},{"id":"410736","messageId":"xmqqft4ygtvl.fsf@gitster.c.googlers.com","threadId":"54689","inReplyTo":"CA+P7+xp_iTnkdbWoDSRZustvjk5BRJOPD=snae8D1Fe_uXqO7g@mail.gmail.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-11-25T00:30:54Z","receivedAt":"2020-11-25T00:31:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jacob Keller <jacob.keller@gmail.com> writes:\n\n> Of course I agree that \"@ == HEAD\" can't be used to go *backwards*\n> through that logic at all. But if you're moving forwards through it,\n> then \"@\" on its own can make sense as HEAD, but only as an implication\n> of \"the most recent version of the current branch can't be anything\n> else\"\n\nI'd rather put the lame excuses behind and accept that we ended up\nwith an ugly and illogical synonym that ;-)\n\nAnd making it consistently available in places where HEAD is\naccepted is a good thing.  Depending on the keyboard, it may be\neasy to type, too.\n\n"},{"id":"411411","messageId":"CAMP44s33jhx+5m_LmaVi58n0roJH-ZD9z0nU6M5d6_Kd+i=5Dw@mail.gmail.com","threadId":"54689","inReplyTo":"CAMP44s3f_cO61YVjvwsiswKQRESznOFn7KTshgv06a=zVRPLug@mail.gmail.com","subject":"Re: [PATCH] refspec: make @ a valid refspec","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-12-04T22:20:52Z","receivedAt":"2020-12-04T22:21:45Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hello,\n\nOn Tue, Nov 24, 2020 at 6:09 PM Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> On Tue, Nov 24, 2020 at 4:45 PM Junio C Hamano <gitster@pobox.com> wrote:\n> > Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> > > Beauty is in the eye of the beholder.\n> >\n> > Using \"@\" is rather \"illogical\" than \"ugly\", and at that point it is\n> > not so subjective.\n>\n> I disagree.\n\nThis is not an attempt to reignite the discussion, but just something\nthat might be of interest.\n\nI created a poll [1] in reddit's r/git: Do you know @ is a shortcut for HEAD?\n\n403 people gave a useful response. Of those; 74% didn't know such a\nshortcut existed, 80% liked this shortcut.\n\nBut more importantly: 59% did like the shortcut, but didn't know it\nexisted. That is: of the people that liked the shortcut; 74% didn't\nknow it existed.\n\nThis tells us something: putting personal preferences aside; the Git\nproject doesn't seem to be doing a great job of advertising its\nfeatures. Features a good chunk--if not the overwhelming majority--of\nusers might like.\n\nOther things of interest in the comments: one user didn't even know\nwhat HEAD was, another used \"head\" (lowercase) (macOS user), and\nlastly; the second most voted comment did take a shot at Git's known\nunintuitiveness.\n\nThat's it. Just putting it here.\n\nCheers.\n\n[1] https://www.reddit.com/r/git/comments/k15cqm/do_you_know_is_a_shortcut_for_head/\n\n-- \nFelipe Contreras\n"}]}