{"thread":{"id":"46211","subject":"Better usability of stash refs","startedAt":"2017-06-19T20:33:01Z","lastAt":"2017-06-20T13:46:15Z","messageCount":4,"participants":["Robert Dailey","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"322610","messageId":"CAHd499C8x_zWJyRNXO-410gxudk897-okJaA3uOPYr38QNHjpA@mail.gmail.com","threadId":"46211","inReplyTo":null,"subject":"Better usability of stash refs","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2017-06-19T20:32:54Z","receivedAt":"2017-06-19T20:33:01Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"To drop a stash, I have to do this (example):\n\n$ git stash drop stash@{3}\n\nUsing the full \"stash@{N}\" seems superfluous since the documentation\nstates it must be a stash in the first place. It would make more sense\n(and be quicker to type) to do:\n\n$ git stash drop 3\n\nIs there a trick I can use to make this shorthand possible? I thought\nabout creating a \"s\" script for \"stash\" that intercepted the\nparameters for only a couple of stash sub-commands and created the\nref, but that seems a lot of work.\n\nAny productivity tips here? Thanks in advance.\n"},{"id":"322611","messageId":"xmqqd19zsnxw.fsf@gitster.mtv.corp.google.com","threadId":"46211","inReplyTo":"CAHd499C8x_zWJyRNXO-410gxudk897-okJaA3uOPYr38QNHjpA@mail.gmail.com","subject":"Re: Better usability of stash refs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-19T20:49:15Z","receivedAt":"2017-06-19T20:49:23Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robert Dailey <rcdailey.lists@gmail.com> writes:\n\n> To drop a stash, I have to do this (example):\n>\n> $ git stash drop stash@{3}\n>\n> Using the full \"stash@{N}\" seems superfluous since the documentation\n> states it must be a stash in the first place. It would make more sense\n> (and be quicker to type) to do:\n>\n> $ git stash drop 3\n>\n> Is there a trick I can use to make this shorthand possible? I thought\n> about creating a \"s\" script for \"stash\" that intercepted the\n> parameters for only a couple of stash sub-commands and created the\n> ref, but that seems a lot of work.\n>\n> Any productivity tips here? Thanks in advance.\n\nIsn't that already the case?\n\ngit-stash.sh::drop_stash gives \"$@\" to assert_stash_ref, which in\nturn calls is_stash_ref, which in turn calls is_stash_like, and this\ncallchain eventually cals into parse_flags_and_rev.  Which has this\nbit (may be hard to read because it is incorrectly indented):\n\n\tcase \"$1\" in\n\t\t*[!0-9]*)\n\t\t\t:\n\t\t;;\n\t\t*)\n\t\t\tset -- \"${ref_stash}@{$1}\"\n\t\t;;\n\tesac\n\n\tREV=$(git rev-parse --symbolic --verify --quiet \"$1\") || {\n\t\treference=\"$1\"\n\t\tdie \"$(eval_gettext \"\\$reference is not a valid reference\")\"\n\t}\n\n"},{"id":"322612","messageId":"20170619205636.7adzgolilpfch3ux@sigill.intra.peff.net","threadId":"46211","inReplyTo":"CAHd499C8x_zWJyRNXO-410gxudk897-okJaA3uOPYr38QNHjpA@mail.gmail.com","subject":"Re: Better usability of stash refs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-06-19T20:56:36Z","receivedAt":"2017-06-19T20:56:48Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 19, 2017 at 03:32:54PM -0500, Robert Dailey wrote:\n\n> To drop a stash, I have to do this (example):\n> \n> $ git stash drop stash@{3}\n> \n> Using the full \"stash@{N}\" seems superfluous since the documentation\n> states it must be a stash in the first place. It would make more sense\n> (and be quicker to type) to do:\n> \n> $ git stash drop 3\n> \n> Is there a trick I can use to make this shorthand possible? I thought\n> about creating a \"s\" script for \"stash\" that intercepted the\n> parameters for only a couple of stash sub-commands and created the\n> ref, but that seems a lot of work.\n> \n> Any productivity tips here? Thanks in advance.\n\nJunio mentioned that this is already possible. I suspect the problem may\nbe that your Git is not recent enough. It was added in a56c8f5aa (stash:\nallow stashes to be referenced by index only, 2016-10-24), which is in\nv2.11.0.\n\n-Peff\n"},{"id":"322734","messageId":"CAHd499Ckn4QQp4s3kO61a4wRxopu7rywPOpNXJ=_zmHffp0d1Q@mail.gmail.com","threadId":"46211","inReplyTo":"20170619205636.7adzgolilpfch3ux@sigill.intra.peff.net","subject":"Re: Better usability of stash refs","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2017-06-20T13:46:10Z","receivedAt":"2017-06-20T13:46:15Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Mon, Jun 19, 2017 at 3:56 PM, Jeff King <peff@peff.net> wrote:\n> On Mon, Jun 19, 2017 at 03:32:54PM -0500, Robert Dailey wrote:\n>\n>> To drop a stash, I have to do this (example):\n>>\n>> $ git stash drop stash@{3}\n>>\n>> Using the full \"stash@{N}\" seems superfluous since the documentation\n>> states it must be a stash in the first place. It would make more sense\n>> (and be quicker to type) to do:\n>>\n>> $ git stash drop 3\n>>\n>> Is there a trick I can use to make this shorthand possible? I thought\n>> about creating a \"s\" script for \"stash\" that intercepted the\n>> parameters for only a couple of stash sub-commands and created the\n>> ref, but that seems a lot of work.\n>>\n>> Any productivity tips here? Thanks in advance.\n>\n> Junio mentioned that this is already possible. I suspect the problem may\n> be that your Git is not recent enough. It was added in a56c8f5aa (stash:\n> allow stashes to be referenced by index only, 2016-10-24), which is in\n> v2.11.0.\n>\n> -Peff\n\nThanks guys. Actually I'm running 2.13, I just haven't tried it since\nway before 2.11. I always assumed it wasn't working like I expected\nsince last time I tried it. Yesterday I just happened to remember that\nthis would be nice to have, so I wrote the email but didn't bother\ntesting it on the newest version first. Sorry about that.\n"}]}