git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* stash: learn to parse -m/--message like commit does
@ 2017-11-21 23:07 Phil Hord
  2017-11-21 23:09 ` Phil Hord
  2017-11-21 23:22 ` Jonathan Nieder
  0 siblings, 2 replies; 3+ messages in thread
From: Phil Hord @ 2017-11-21 23:07 UTC (permalink / raw)
  To: Git, Thomas Gummerer

`git stash push -m foo` uses "foo" as the message for the stash. But
`git stash push -m"foo"` does not parse successfully.  Similarly
`git stash push --message="My stash message"` also fails.  Nothing
in the documentation suggests this syntax should work, but it does
work for `git commit`, and my fingers have learned this pattern long
ago.

Teach `git stash` to parse -mFoo and --message=Foo the same as
`git commit` would do.

Signed-off-by: Phil Hord <phil.hord@gmail.com>
---
 git-stash.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/git-stash.sh b/git-stash.sh
index 4b7495144..1114005ce 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -76,6 +76,12 @@ create_stash () {
  shift
  stash_msg=${1?"BUG: create_stash () -m requires an argument"}
  ;;
+ -m*)
+ stash_msg=${1#-m}
+ ;;
+ --message=*)
+ stash_msg=${1#--message=}
+ ;;
  -u|--include-untracked)
  shift
  untracked=${1?"BUG: create_stash () -u requires an argument"}
@@ -193,6 +199,12 @@ store_stash () {
  shift
  stash_msg="$1"
  ;;
+ -m*)
+ stash_msg=${1#-m}
+ ;;
+ --message=*)
+ stash_msg=${1#--message=}
+ ;;
  -q|--quiet)
  quiet=t
  ;;
@@ -251,6 +263,12 @@ push_stash () {
  test -z ${1+x} && usage
  stash_msg=$1
  ;;
+ -m*)
+ stash_msg=${1#-m}
+ ;;
+ --message=*)
+ stash_msg=${1#--message=}
+ ;;
  --help)
  show_help
  ;;
-- 
2.15.0.471.g17a719cfe.dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: stash: learn to parse -m/--message like commit does
  2017-11-21 23:07 stash: learn to parse -m/--message like commit does Phil Hord
@ 2017-11-21 23:09 ` Phil Hord
  2017-11-21 23:22 ` Jonathan Nieder
  1 sibling, 0 replies; 3+ messages in thread
From: Phil Hord @ 2017-11-21 23:09 UTC (permalink / raw)
  To: Git, Thomas Gummerer

Hm..  Sorry about the formatting here.  It's been a while.  I'll try again.

On Tue, Nov 21, 2017 at 3:07 PM, Phil Hord <phil.hord@gmail.com> wrote:
> `git stash push -m foo` uses "foo" as the message for the stash. But
> `git stash push -m"foo"` does not parse successfully.  Similarly
> `git stash push --message="My stash message"` also fails.  Nothing
> in the documentation suggests this syntax should work, but it does
> work for `git commit`, and my fingers have learned this pattern long
> ago.
>
> Teach `git stash` to parse -mFoo and --message=Foo the same as
> `git commit` would do.
>
> Signed-off-by: Phil Hord <phil.hord@gmail.com>
> ---
>  git-stash.sh | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/git-stash.sh b/git-stash.sh
> index 4b7495144..1114005ce 100755
> --- a/git-stash.sh
> +++ b/git-stash.sh
> @@ -76,6 +76,12 @@ create_stash () {
>   shift
>   stash_msg=${1?"BUG: create_stash () -m requires an argument"}
>   ;;
> + -m*)
> + stash_msg=${1#-m}
> + ;;
> + --message=*)
> + stash_msg=${1#--message=}
> + ;;
>   -u|--include-untracked)
>   shift
>   untracked=${1?"BUG: create_stash () -u requires an argument"}
> @@ -193,6 +199,12 @@ store_stash () {
>   shift
>   stash_msg="$1"
>   ;;
> + -m*)
> + stash_msg=${1#-m}
> + ;;
> + --message=*)
> + stash_msg=${1#--message=}
> + ;;
>   -q|--quiet)
>   quiet=t
>   ;;
> @@ -251,6 +263,12 @@ push_stash () {
>   test -z ${1+x} && usage
>   stash_msg=$1
>   ;;
> + -m*)
> + stash_msg=${1#-m}
> + ;;
> + --message=*)
> + stash_msg=${1#--message=}
> + ;;
>   --help)
>   show_help
>   ;;
> --
> 2.15.0.471.g17a719cfe.dirty

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: stash: learn to parse -m/--message like commit does
  2017-11-21 23:07 stash: learn to parse -m/--message like commit does Phil Hord
  2017-11-21 23:09 ` Phil Hord
@ 2017-11-21 23:22 ` Jonathan Nieder
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Nieder @ 2017-11-21 23:22 UTC (permalink / raw)
  To: Phil Hord; +Cc: Git, Thomas Gummerer

Hi,

Phil Hord wrote:

> `git stash push -m foo` uses "foo" as the message for the stash. But
> `git stash push -m"foo"` does not parse successfully.  Similarly
> `git stash push --message="My stash message"` also fails.  Nothing
> in the documentation suggests this syntax should work,

"git help cli" says it should work.  Thanks for working on it.

>                                                        but it does
> work for `git commit`, and my fingers have learned this pattern long
> ago.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-21 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-21 23:07 stash: learn to parse -m/--message like commit does Phil Hord
2017-11-21 23:09 ` Phil Hord
2017-11-21 23:22 ` Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).