{"thread":{"id":"11106","subject":"[PATCH] git-stash: Display help message if git-stash is run with wrong sub-commands","startedAt":"2007-12-03T02:34:05Z","lastAt":"2007-12-04T15:28:27Z","messageCount":6,"participants":["Kevin Leung","Junio C Hamano","Wayne Davison","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"61711","messageId":"e66701d40712021834h64bf8d0y14f0e222d0f9a617@mail.gmail.com","threadId":"11106","inReplyTo":null,"subject":"[PATCH] git-stash: Display help message if git-stash is run with wrong sub-commands","fromName":"Kevin Leung","fromEmail":"kevinlsk@gmail.com","sentAt":"2007-12-03T02:34:05Z","receivedAt":"2007-12-03T02:34:05Z","isPatch":true,"sender":{"key":"kevinlsk@gmail.com","avatar":null},"body":"The current git-stash behaviour is very error prone to typos. For example,\nif you typed \"git-stash llist\", git-stash would think that you wanted to\nsave to a stash named \"llist\", but in fact, you meant \"git-stash list\".\n\nSigned-off-by: Kevin Leung <kevinlsk@gmail.com>\n---\n git-stash.sh |   16 +++++++++-------\n 1 files changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 77c9421..a17cc25 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -1,7 +1,7 @@\n #!/bin/sh\n # Copyright (c) 2007, Nanako Shiraishi\n\n-USAGE='[ | list | show | apply | clear]'\n+USAGE='[  | save | list | show | apply | clear ]'\n\n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n@@ -195,6 +195,10 @@ show)\n        shift\n        show_stash \"$@\"\n        ;;\n+save)\n+       shift\n+       save_stash \"$@\" && git-reset --hard\n+       ;;\n apply)\n        shift\n        apply_stash \"$@\"\n@@ -202,14 +206,12 @@ apply)\n clear)\n        clear_stash\n        ;;\n-help | usage)\n-       usage\n-       ;;\n *)\n-       if test $# -gt 0 && test \"$1\" = save\n+       if test \"$#\" -eq \"0\"\n        then\n-               shift\n+               save_stash && git-reset --hard\n+       else\n+               usage\n        fi\n-       save_stash \"$*\" && git-reset --hard\n        ;;\n esac\n-- \n1.5.3.7-dirty\n"},{"id":"61713","messageId":"7vwsrwqysf.fsf@gitster.siamese.dyndns.org","threadId":"11106","inReplyTo":"e66701d40712021834h64bf8d0y14f0e222d0f9a617@mail.gmail.com","subject":"Re: [PATCH] git-stash: Display help message if git-stash is run with wrong sub-commands","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-03T02:48:00Z","receivedAt":"2007-12-03T02:48:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kevin Leung\" <kevinlsk@gmail.com> writes:\n\n> The current git-stash behaviour is very error prone to typos. For example,\n> if you typed \"git-stash llist\", git-stash would think that you wanted to\n> save to a stash named \"llist\", but in fact, you meant \"git-stash list\".\n>\n> Signed-off-by: Kevin Leung <kevinlsk@gmail.com>\n\nThanks.  Looks good.  except...\n\n> @@ -195,6 +195,10 @@ show)\n>         shift\n>         show_stash \"$@\"\n>         ;;\n> +save)\n> +       shift\n> +       save_stash \"$@\" && git-reset --hard\n> +       ;;\n\n... this should be \"$*\" as it was originally spelled.\n\nSave this script in foo.sh and run \"foo.sh a b c\" to see what I mean.\n\n#!/bin/sh\n\nfoo () {\n\tmsg=\"$1\"\n\techo \"Foo here <$1>\"\n}\n\nfoo \"$@\"\nfoo \"$*\"\n"},{"id":"61715","messageId":"e66701d40712021936p10ee73ddj9696d3a8b4092127@mail.gmail.com","threadId":"11106","inReplyTo":"7vwsrwqysf.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-stash: Display help message if git-stash is run with wrong sub-commands","fromName":"Kevin Leung","fromEmail":"kevinlsk@gmail.com","sentAt":"2007-12-03T03:36:59Z","receivedAt":"2007-12-03T03:36:59Z","isPatch":true,"sender":{"key":"kevinlsk@gmail.com","avatar":null},"body":"The current git-stash behaviour is very error prone to typos. For example,\nif you typed \"git-stash llist\", git-stash would think that you wanted to\nsave to a stash named \"llist\", but in fact, you meant \"git-stash list\".\n\nSigned-off-by: Kevin Leung <kevinlsk@gmail.com>\n---\n\n Thanks, Junio. It should be alright now.\n\n git-stash.sh |   16 +++++++++-------\n 1 files changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 77c9421..844a3e5 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -1,7 +1,7 @@\n #!/bin/sh\n # Copyright (c) 2007, Nanako Shiraishi\n\n-USAGE='[ | list | show | apply | clear]'\n+USAGE='[  | save | list | show | apply | clear ]'\n\n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n@@ -195,6 +195,10 @@ show)\n        shift\n        show_stash \"$@\"\n        ;;\n+save)\n+       shift\n+       save_stash \"$*\" && git-reset --hard\n+       ;;\n apply)\n        shift\n        apply_stash \"$@\"\n@@ -202,14 +206,12 @@ apply)\n clear)\n        clear_stash\n        ;;\n-help | usage)\n-       usage\n-       ;;\n *)\n-       if test $# -gt 0 && test \"$1\" = save\n+       if test \"$#\" -eq \"0\"\n        then\n-               shift\n+               save_stash && git-reset --hard\n+       else\n+               usage\n        fi\n-       save_stash \"$*\" && git-reset --hard\n        ;;\n esac\n-- \n1.5.3.7-dirty\n"},{"id":"61734","messageId":"20071203061617.GB1976@blorf.net","threadId":"11106","inReplyTo":"e66701d40712021834h64bf8d0y14f0e222d0f9a617@mail.gmail.com","subject":"Re: [PATCH] git-stash: Display help message if git-stash is run with wrong sub-commands","fromName":"Wayne Davison","fromEmail":"wayne@opencoder.net","sentAt":"2007-12-03T06:16:17Z","receivedAt":"2007-12-03T06:16:17Z","isPatch":true,"sender":{"key":"wayne@opencoder.net","avatar":"https://gravatar.com/avatar/d55d81825271b1bfe65e57e4e04297d4119aa03c6a1c71d2ff2812b9b4be9f45?d=mp&s=160"},"body":"On Mon, Dec 03, 2007 at 10:34:05AM +0800, Kevin Leung wrote:\n> +USAGE='[  | save | list | show | apply | clear ]'\n\nIt seems strange to me that git stash is using sub-sub-command words\ninstead of options.  Would it make more sense to be more like git branch\nand have a list be indicated by -l, etc.?\n\n..wayne..\n"},{"id":"61763","messageId":"Pine.LNX.4.64.0712031023480.27959@racer.site","threadId":"11106","inReplyTo":"20071203061617.GB1976@blorf.net","subject":"Re: [PATCH] git-stash: Display help message if git-stash is run with wrong sub-commands","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-12-03T10:25:17Z","receivedAt":"2007-12-03T10:25:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 2 Dec 2007, Wayne Davison wrote:\n\n> On Mon, Dec 03, 2007 at 10:34:05AM +0800, Kevin Leung wrote:\n> > +USAGE='[  | save | list | show | apply | clear ]'\n> \n> It seems strange to me that git stash is using sub-sub-command words \n> instead of options.  Would it make more sense to be more like git branch \n> and have a list be indicated by -l, etc.?\n\nBut those are not really options, are they?  They are commands, which \nexclude each other.  And even if they are sub-sub-commands, why should we \nnot rather fix \"git branch\" to support a sane syntax, too?\n\nWe could even put some general support into parse-options.[ch] for \nsub-commands.\n\nCiao,\nDscho\n"},{"id":"61916","messageId":"20071204152827.GB24201@blorf.net","threadId":"11106","inReplyTo":"Pine.LNX.4.64.0712031023480.27959@racer.site","subject":"Re: [PATCH] git-stash: Display help message if git-stash is run with wrong sub-commands","fromName":"Wayne Davison","fromEmail":"wayne@opencoder.net","sentAt":"2007-12-04T15:28:27Z","receivedAt":"2007-12-04T15:28:27Z","isPatch":true,"sender":{"key":"wayne@opencoder.net","avatar":"https://gravatar.com/avatar/d55d81825271b1bfe65e57e4e04297d4119aa03c6a1c71d2ff2812b9b4be9f45?d=mp&s=160"},"body":"On Mon, Dec 03, 2007 at 10:25:17AM +0000, Johannes Schindelin wrote:\n> But those are not really options, are they?  They are commands, which \n> exclude each other.\n\nOption syntax is often used to represent exclusive commands, especially\nwhen those commands need to be distinguished from free-form arg words.\nThe \"git checkout\" command is another example of this in git, and there\nare plenty of non-git examples of such a use of option syntax around.\nSuch a syntax makes it easier to have a default action while still\ntaking a free-form arg.  I personally think that using option syntax\nfor its behavior choices would be preferable with git stash.\n\n..wayne..\n"}]}