{"thread":{"id":"47301","subject":"[PATCH v2] Teach stash to parse -m/--message like commit does","startedAt":"2017-11-22T21:21:31Z","lastAt":"2017-11-24T05:47:44Z","messageCount":3,"participants":["Phil Hord","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"333324","messageId":"20171122212031.5988-1-phil.hord@gmail.com","threadId":"47301","inReplyTo":null,"subject":"[PATCH v2] Teach stash to parse -m/--message like commit does","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2017-11-22T21:20:30Z","receivedAt":"2017-11-22T21:21:31Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"`git stash push -m foo` uses \"foo\" as the message for the stash. But\n`git stash push -m\"foo\"` does not parse successfully.  Similarly\n`git stash push --message=\"My stash message\"` also fails.  The stash\ndocumentation doesn't suggest this syntax should work, but gitcli\ndoes and my fingers have learned this pattern long ago for `commit`.\n\nTeach `git stash` and `git store` to parse -mFoo and --message=Foo\nthe same as `git commit` would do.  Even though it's an internal\nfunction, add similar support to create_stash() for consistency.\n\nReviewd-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Phil Hord <phil.hord@gmail.com>\n---\n\nAdded tests for 'stash push' and 'stash store'.\nAdded a note that create_stash is included but unnecessary.\n\n git-stash.sh     | 18 +++++++++++\n t/t3903-stash.sh | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 111 insertions(+)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 4b7495144..1114005ce 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -76,6 +76,12 @@ create_stash () {\n \t\t\tshift\n \t\t\tstash_msg=${1?\"BUG: create_stash () -m requires an argument\"}\n \t\t\t;;\n+\t\t-m*)\n+\t\t\tstash_msg=${1#-m}\n+\t\t\t;;\n+\t\t--message=*)\n+\t\t\tstash_msg=${1#--message=}\n+\t\t\t;;\n \t\t-u|--include-untracked)\n \t\t\tshift\n \t\t\tuntracked=${1?\"BUG: create_stash () -u requires an argument\"}\n@@ -193,6 +199,12 @@ store_stash () {\n \t\t\tshift\n \t\t\tstash_msg=\"$1\"\n \t\t\t;;\n+\t\t-m*)\n+\t\t\tstash_msg=${1#-m}\n+\t\t\t;;\n+\t\t--message=*)\n+\t\t\tstash_msg=${1#--message=}\n+\t\t\t;;\n \t\t-q|--quiet)\n \t\t\tquiet=t\n \t\t\t;;\n@@ -251,6 +263,12 @@ push_stash () {\n \t\t\ttest -z ${1+x} && usage\n \t\t\tstash_msg=$1\n \t\t\t;;\n+\t\t-m*)\n+\t\t\tstash_msg=${1#-m}\n+\t\t\t;;\n+\t\t--message=*)\n+\t\t\tstash_msg=${1#--message=}\n+\t\t\t;;\n \t\t--help)\n \t\t\tshow_help\n \t\t\t;;\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 3b1ac1971..39c7f2ebd 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -804,6 +804,99 @@ test_expect_success 'push -m shows right message' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'push -m also works without space' '\n+\t>foo &&\n+\tgit add foo &&\n+\tgit stash push -m\"unspaced test message\" &&\n+\techo \"stash@{0}: On master: unspaced test message\" >expect &&\n+\tgit stash list -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'store -m foo shows right message' '\n+\tgit stash clear &&\n+\tgit reset --hard &&\n+\techo quux >bazzy &&\n+\tgit add bazzy &&\n+\tSTASH_ID=$(git stash create) &&\n+\tgit stash store -m \"store m\" $STASH_ID &&\n+\techo \"stash@{0}: store m\" >expect &&\n+\tgit stash list -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'store -mfoo shows right message' '\n+\tgit stash clear &&\n+\tgit reset --hard &&\n+\techo quux >bazzy &&\n+\tgit add bazzy &&\n+\tSTASH_ID=$(git stash create) &&\n+\tgit stash store -m\"store mfoo\" $STASH_ID &&\n+\techo \"stash@{0}: store mfoo\" >expect &&\n+\tgit stash list -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'store --message=foo shows right message' '\n+\tgit stash clear &&\n+\tgit reset --hard &&\n+\techo quux >bazzy &&\n+\tgit add bazzy &&\n+\tSTASH_ID=$(git stash create) &&\n+\tgit stash store --message=\"store message=foo\" $STASH_ID &&\n+\techo \"stash@{0}: store message=foo\" >expect &&\n+\tgit stash list -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'store --message foo shows right message' '\n+\tgit stash clear &&\n+\tgit reset --hard &&\n+\techo quux >bazzy &&\n+\tgit add bazzy &&\n+\tSTASH_ID=$(git stash create) &&\n+\tgit stash store --message \"store message foo\" $STASH_ID &&\n+\techo \"stash@{0}: store message foo\" >expect &&\n+\tgit stash list -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'push -mfoo uses right message' '\n+\t>foo &&\n+\tgit add foo &&\n+\tgit stash push -m\"test mfoo\" &&\n+\techo \"stash@{0}: On master: test mfoo\" >expect &&\n+\tgit stash list -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'push --message foo is synonym for -mfoo' '\n+\t>foo &&\n+\tgit add foo &&\n+\tgit stash push --message \"test message foo\" &&\n+\techo \"stash@{0}: On master: test message foo\" >expect &&\n+\tgit stash list -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'push --message=foo is synonym for -mfoo' '\n+\t>foo &&\n+\tgit add foo &&\n+\tgit stash push --message=\"test message=foo\" &&\n+\techo \"stash@{0}: On master: test message=foo\" >expect &&\n+\tgit stash list -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'push -m shows right message' '\n+\t>foo &&\n+\tgit add foo &&\n+\tgit stash push -m \"test m foo\" &&\n+\techo \"stash@{0}: On master: test m foo\" >expect &&\n+\tgit stash list -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'create stores correct message' '\n \t>foo &&\n \tgit add foo &&\n-- \n2.15.0.471.g17a719cfe.dirty\n\n"},{"id":"333330","messageId":"20171122220155.GD2854@sigill","threadId":"47301","inReplyTo":"20171122212031.5988-1-phil.hord@gmail.com","subject":"Re: [PATCH v2] Teach stash to parse -m/--message like commit does","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-11-22T22:01:56Z","receivedAt":"2017-11-22T22:02:02Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 22, 2017 at 01:20:30PM -0800, Phil Hord wrote:\n\n> `git stash push -m foo` uses \"foo\" as the message for the stash. But\n> `git stash push -m\"foo\"` does not parse successfully.  Similarly\n> `git stash push --message=\"My stash message\"` also fails.  The stash\n> documentation doesn't suggest this syntax should work, but gitcli\n> does and my fingers have learned this pattern long ago for `commit`.\n> \n> Teach `git stash` and `git store` to parse -mFoo and --message=Foo\n> the same as `git commit` would do.  Even though it's an internal\n> function, add similar support to create_stash() for consistency.\n\nI definitely approve of the goal. The implementation looks pretty\nstraightforward given the current parsing scheme.\n\nMany of our other scripts lean on \"rev-parse --parseopt\" to handle\noptions.  E.g.:\n\nOPTIONS=\"\\\ngit foo [options]\n--\nm,message=     stash message\n\"\nfoo() {\n\tfor i in \"$@\"; do echo \" pre: $i\"; done\n\teval \"$(echo -n \"$OPTIONS\" | git rev-parse --parseopt -- \"$@\")\"\n\tfor i in \"$@\"; do echo \"post: $i\"; done\n}\nfoo -mmsg\nfoo -m msg\nfoo --message=msg\nfoo --message msg\n\nshould convert each of those into \"-m msg\". It also handles unique\npartial options like \"--mess\", though IMHO that is not that big a deal.\n\nWould it be possible to convert stash to use --parseopt? I'm fine if the\nanswer is \"no\", or even \"yes, but it's tricky so let's do this in the\nmeantime\". But I think that's the endgame we should be shooting for (or,\nof course, doing the whole thing in C, which I think somebody else is\nworking on).\n\n-Peff\n"},{"id":"333410","messageId":"xmqq4lpkp6rq.fsf@gitster.mtv.corp.google.com","threadId":"47301","inReplyTo":"20171122212031.5988-1-phil.hord@gmail.com","subject":"Re: [PATCH v2] Teach stash to parse -m/--message like commit does","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-11-24T05:47:37Z","receivedAt":"2017-11-24T05:47:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <phil.hord@gmail.com> writes:\n\n> `git stash push -m foo` uses \"foo\" as the message for the stash. But\n> `git stash push -m\"foo\"` does not parse successfully.  Similarly\n> `git stash push --message=\"My stash message\"` also fails.  The stash\n> documentation doesn't suggest this syntax should work, but gitcli\n> does and my fingers have learned this pattern long ago for `commit`.\n>\n> Teach `git stash` and `git store` to parse -mFoo and --message=Foo\n> the same as `git commit` would do.  Even though it's an internal\n> function, add similar support to create_stash() for consistency.\n\nI sense some typo around \"git store\", but I am not exactly sure what\nthe right spelling should be. \"git stash -m..\", \"git stash save -m..\",\n\"git stash push -m..\" and \"git stash store -m..\", if you want a full\nenumeration, but stepping back a bit, mentioning \"git stash\" ought\nto be sufficient.  A need to spell all of them whose handling of -m\nyou fixed would imply there may be some others whose handling of -m\nis still broken, which is not a good place for us to end up with.\n\n> Reviewd-by: Junio C Hamano <gitster@pobox.com>\n\nHeh, I didn't review this version and certainly not its test.  \n\nI didn't see anything questionable there after a quick read, though.\n\nThanks.\n\n\n\n"}]}