{"thread":{"id":"51457","subject":"`@` alias for `HEAD` not working in `git push -u origin @`","startedAt":"2019-07-10T05:06:23Z","lastAt":"2019-07-31T16:10:57Z","messageCount":7,"participants":["Mark Florian","brian m. carlson","Johannes Schindelin","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"378753","messageId":"CANC=f2c8eynWJ1r=zwZq1qwrDE85LVFMU2mjLU26HYMDGaD4iA@mail.gmail.com","threadId":"51457","inReplyTo":null,"subject":"`@` alias for `HEAD` not working in `git push -u origin @`","fromName":"Mark Florian","fromEmail":"mflorian@gitlab.com","sentAt":"2019-07-10T05:06:08Z","receivedAt":"2019-07-10T05:06:23Z","isPatch":false,"sender":{"key":"mflorian@gitlab.com","avatar":null},"body":"Hello!\n\nI learned today that `@` is a shortcut for `HEAD`. From `git help reivisions`:\n\n    @ alone is a shortcut for HEAD.\n\nHowever, when I tried to use it in a command I frequently use, I got an error:\n\n    $ git push -u origin @\n    fatal: invalid refspec '@'\n\nI'm running git version 2.22.0 on Linux.\n\nIs this a bug, or have I misunderstood how this is supposed to work?\n\nCheers,\nMark\n"},{"id":"378781","messageId":"20190710233937.GG9224@genre.crustytoothpaste.net","threadId":"51457","inReplyTo":"CANC=f2c8eynWJ1r=zwZq1qwrDE85LVFMU2mjLU26HYMDGaD4iA@mail.gmail.com","subject":"Re: `@` alias for `HEAD` not working in `git push -u origin @`","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-07-10T23:39:37Z","receivedAt":"2019-07-10T23:39:46Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-07-10 at 05:06:08, Mark Florian wrote:\n> Hello!\n> \n> I learned today that `@` is a shortcut for `HEAD`. From `git help reivisions`:\n> \n>     @ alone is a shortcut for HEAD.\n> \n> However, when I tried to use it in a command I frequently use, I got an error:\n> \n>     $ git push -u origin @\n>     fatal: invalid refspec '@'\n> \n> I'm running git version 2.22.0 on Linux.\n> \n> Is this a bug, or have I misunderstood how this is supposed to work?\n\nThis is a bug. If the destination side of a refspec is omitted, and the\nsource side resolves to a ref starting with \"refs/heads/\" or\n\"refs/tags/\" (which I expect it does here), then that ref is used as the\ndestination.\n\nI submitted a patch at [0], but it was decided not to pick it up. If\nJunio and the list decide that it's wanted, I'm happy to resend or\nrevise and resend.\n\n[0] https://public-inbox.org/git/20180729192803.1047050-1-sandals@crustytoothpaste.net/\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"378800","messageId":"nycvar.QRO.7.76.6.1907111141380.46@tvgsbejvaqbjf.bet","threadId":"51457","inReplyTo":"20190710233937.GG9224@genre.crustytoothpaste.net","subject":"Re: `@` alias for `HEAD` not working in `git push -u origin @`","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-07-11T09:46:26Z","receivedAt":"2019-07-11T09:46:53Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi brian,\n\nOn Wed, 10 Jul 2019, brian m. carlson wrote:\n\n> On 2019-07-10 at 05:06:08, Mark Florian wrote:\n> >\n> > I learned today that `@` is a shortcut for `HEAD`. From `git help reivisions`:\n> >\n> >     @ alone is a shortcut for HEAD.\n> >\n> > However, when I tried to use it in a command I frequently use, I got an error:\n> >\n> >     $ git push -u origin @\n> >     fatal: invalid refspec '@'\n> >\n> > I'm running git version 2.22.0 on Linux.\n> >\n> > Is this a bug, or have I misunderstood how this is supposed to work?\n>\n> This is a bug. If the destination side of a refspec is omitted, and the\n> source side resolves to a ref starting with \"refs/heads/\" or\n> \"refs/tags/\" (which I expect it does here), then that ref is used as the\n> destination.\n>\n> I submitted a patch at [0], but it was decided not to pick it up. If\n> Junio and the list decide that it's wanted, I'm happy to resend or\n> revise and resend.\n>\n> [0] https://public-inbox.org/git/20180729192803.1047050-1-sandals@crustytoothpaste.net/\n\nAfter reading that thread, I come to the conclusion that it was not so\nmuch a decision not to pick it up, but more like a falling between the\ncracks.\n\nI would be in favor of this patch.\n\nSince I have your attention and since I am interested in a related issue\n(when I wanted to propose a GSoC mini project to let `git fetch <remote>\n@` expand the `@` to the current (local) branch name, Matthieu Moy\npointed out that `git fetch --current <remote>` might be a better UI):\nwhat does your patch do with `git fetch`'s refspec arguments?\n\nCiao,\nDscho\n"},{"id":"378806","messageId":"20190711144828.GH9224@genre.crustytoothpaste.net","threadId":"51457","inReplyTo":"nycvar.QRO.7.76.6.1907111141380.46@tvgsbejvaqbjf.bet","subject":"Re: `@` alias for `HEAD` not working in `git push -u origin @`","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-07-11T14:48:28Z","receivedAt":"2019-07-11T14:48:36Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-07-11 at 09:46:26, Johannes Schindelin wrote:\n> After reading that thread, I come to the conclusion that it was not so\n> much a decision not to pick it up, but more like a falling between the\n> cracks.\n> \n> I would be in favor of this patch.\n\nI think there was some later follow-up in a different thread (one of the\n\"What's cooking\" threads) that expressed reservations about it, but I\ncan't find that thread right now.\n\nRegardless, if there's interest, I can certainly resend and see how\nfolks on the list feel about it.\n\n> Since I have your attention and since I am interested in a related issue\n> (when I wanted to propose a GSoC mini project to let `git fetch <remote>\n> @` expand the `@` to the current (local) branch name, Matthieu Moy\n> pointed out that `git fetch --current <remote>` might be a better UI):\n> what does your patch do with `git fetch`'s refspec arguments?\n\nI haven't checked. I believe it would resolve \"git fetch origin @\" to\n\"git fetch origin HEAD\" and \"git fetch origin @:refs/heads/master\" to\n\"git fetch origin HEAD:refs/heads/master\".\n\nI can add some additional tests for this case, although I'm not\nespecially sure that it provides useful behavior people will want.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"378881","messageId":"nycvar.QRO.7.76.6.1907121228110.47@tvgsbejvaqbjf.bet","threadId":"51457","inReplyTo":"20190711144828.GH9224@genre.crustytoothpaste.net","subject":"Re: `@` alias for `HEAD` not working in `git push -u origin @`","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-07-12T10:29:06Z","receivedAt":"2019-07-12T10:29:20Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi brian,\n\nOn Thu, 11 Jul 2019, brian m. carlson wrote:\n\n> On 2019-07-11 at 09:46:26, Johannes Schindelin wrote:\n>\n> > Since I have your attention and since I am interested in a related issue\n> > (when I wanted to propose a GSoC mini project to let `git fetch <remote>\n> > @` expand the `@` to the current (local) branch name, Matthieu Moy\n> > pointed out that `git fetch --current <remote>` might be a better UI):\n> > what does your patch do with `git fetch`'s refspec arguments?\n>\n> I haven't checked. I believe it would resolve \"git fetch origin @\" to\n> \"git fetch origin HEAD\" and \"git fetch origin @:refs/heads/master\" to\n> \"git fetch origin HEAD:refs/heads/master\".\n\nThat sounds like a sane behavior, as `@` on the \"src\" side of a refspec\nthat tries to fetch from a remote repository should probably not expand\nto a _local_ branch.\n\n> I can add some additional tests for this case, although I'm not\n> especially sure that it provides useful behavior people will want.\n\nNah, from my side this is not necessary.\n\nCiao,\nDscho\n"},{"id":"379651","messageId":"20190731055832.GA18039@sigill.intra.peff.net","threadId":"51457","inReplyTo":"20190710233937.GG9224@genre.crustytoothpaste.net","subject":"Re: `@` alias for `HEAD` not working in `git push -u origin @`","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-07-31T05:58:33Z","receivedAt":"2019-07-31T05:58:35Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jul 10, 2019 at 11:39:37PM +0000, brian m. carlson wrote:\n\n> This is a bug. If the destination side of a refspec is omitted, and the\n> source side resolves to a ref starting with \"refs/heads/\" or\n> \"refs/tags/\" (which I expect it does here), then that ref is used as the\n> destination.\n> \n> I submitted a patch at [0], but it was decided not to pick it up. If\n> Junio and the list decide that it's wanted, I'm happy to resend or\n> revise and resend.\n> \n> [0] https://public-inbox.org/git/20180729192803.1047050-1-sandals@crustytoothpaste.net/\n\nI see I was cc'd on that original, but I don't remember ever reading it.\nIt seems like a sane enough idea to me.\n\nAlthough I did notice that you mentioned there:\n\n> I probably type \"git push upstream HEAD\" from five to thirty times a\n> day\n\nI find I do that rarely, because I have:\n\n  [push]\n  default = current\n\nand in a triangular workflow, I have:\n\n  [remote]\n  pushDefault = upstream\n\nSo \"git push\" without arguments typically does the same thing for me.\n\nNot an argument against your patch, but just something you might find\nuseful.\n\n-Peff\n"},{"id":"379690","messageId":"xmqqsgqmqj5k.fsf@gitster-ct.c.googlers.com","threadId":"51457","inReplyTo":"20190731055832.GA18039@sigill.intra.peff.net","subject":"Re: `@` alias for `HEAD` not working in `git push -u origin @`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-07-31T16:10:47Z","receivedAt":"2019-07-31T16:10:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Wed, Jul 10, 2019 at 11:39:37PM +0000, brian m. carlson wrote:\n>\n>> This is a bug. If the destination side of a refspec is omitted, and the\n>> source side resolves to a ref starting with \"refs/heads/\" or\n>> \"refs/tags/\" (which I expect it does here), then that ref is used as the\n>> destination.\n>> \n>> I submitted a patch at [0], but it was decided not to pick it up. If\n>> Junio and the list decide that it's wanted, I'm happy to resend or\n>> revise and resend.\n>> \n>> [0] https://public-inbox.org/git/20180729192803.1047050-1-sandals@crustytoothpaste.net/\n>\n> I see I was cc'd on that original, but I don't remember ever reading it.\n> It seems like a sane enough idea to me.\n\nI see I was also on the cc list; I am not sure what I thought about\nthe patch (i.e. implementation, not the desire to use '@' in the\ncontext in place for \"HEAD\") back then.\n\nNow I read it with everything I thought forgotten, I see two\npotential issues:\n\n - Any error message downstream will mention \"HEAD\" and there won't\n   be a trace of it originally being an \"@\" sign.  It may not be a\n   problem, especially for those who _KNOW_ that they should be\n   typing HEAD but can type \"@\" instead, but I am not sure what to\n   do those who do not know much about \"HEAD\" and start from \"@\" (by\n   the way, it is one reason why I do not like encouraging \"@\",\n   especially in introductory text).\n\n - The code should update llen to 4; right now the remainder of the\n   function does not use the variable in a way that the discrepancy\n   of replacing \"@\" with \"HEAD\" without updating llen matters, but\n   relying on the shape of the code that happens to exist right now\n   is a bad code hygiene.\n\nOther than that, the patch looks sensible to me.\n\n\n> Although I did notice that you mentioned there:\n>\n>> I probably type \"git push upstream HEAD\" from five to thirty times a\n>> day\n>\n> I find I do that rarely, because I have:\n>\n>   [push]\n>   default = current\n>\n> and in a triangular workflow, I have:\n>\n>   [remote]\n>   pushDefault = upstream\n>\n> So \"git push\" without arguments typically does the same thing for me.\n>\n> Not an argument against your patch, but just something you might find\n> useful.\n\nThat's a helpful tangent.  Thanks.\n"}]}