git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: stash: learn to parse -m/--message like commit does

From
Phil Hord <phil.hord@gmail.com>
Date
Nov 21, 2017, 23:09 UTC
Message-ID
<CABURp0p71fdytYqj3nhhij1APdEY-inmTMbQ8aiF-J-hKd-c0w@mail.gmail.com>
In-Reply-To
<CABURp0qadq2cAwR_Nk76J8RqpQk4DZwtnu6aS5hR=LjVD-dGgA@mail.gmail.com>
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:
Show 60 quoted lines
> `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
Previous: Phil HordNext: Jonathan Nieder
Message 2 of 3 in “stash: learn to parse -m/--message like commit does”
  1. Phil HordNov 21, 2017
  2. Phil HordNov 21, 2017
  3. Jonathan NiederNov 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.