stash: Learn to parse -m/--message like commit does
PATCH 1/1 stash: Learn to parse -m/--message like commit does
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.
--- git-stash.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
git-stash.sh +18 -0
@@ -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 ;;
Signature · 1 line
2.15.0.471.g17a719cfe.dirty
PATCH 1/1 doc: prefer 'stash push' instead of 'stash save'
Although git stash save was deprecated recently, some parts of the documentation still refer to it.
--- Documentation/git-stash.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/git-stash.txt +2 -2
@@ -175,14 +175,14 @@ create:: return its object name, without storing it anywhere in the ref namespace. This is intended to be useful for scripts. It is probably not - the command you want to use; see "save" above. + the command you want to use; see "push" above. store:: Store a given stash created via 'git stash create' (which is a dangling merge commit) in the stash ref, updating the stash reflog. This is intended to be useful for scripts. It is - probably not the command you want to use; see "save" above. + probably not the command you want to use; see "push" above. DISCUSSION ----------
Signature · 1 line
2.15.0.471.g17a719cfe.dirty
Quoted 7 lines · Phil Hord
git stash push -m foouses "foo" as the message for the stash. Butgit stash push -m"foo"does not parse successfully. Similarlygit stash push --message="My stash message"also fails. Nothing in the documentation suggests this syntax should work, but it does work forgit commit, and my fingers have learned this pattern long ago.
Quoted 7 lines
Teach
git stashto parse -mFoo and --message=Foo the same asgit commitwould do.Signed-off-by Phil Hord <[email protected]>--- git-stash.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Makes sense. Thanks.
I wonder if you want to add a trivial test or two for this, if "git stash [save|push|nothing] -m foo" is already tested. It appears that t3903 already has a test that does 'push -m "test message"' and sees if that appears in the output of "list", which looks like the ideal place to do so.