git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] stash: Learn to parse -m/--message like commit does
@ 2017-11-21 23:26 Phil Hord
  2017-11-21 23:26 ` [PATCH] doc: prefer 'stash push' instead of 'stash save' Phil Hord
  2017-11-22  4:44 ` [PATCH] stash: Learn to parse -m/--message like commit does Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: Phil Hord @ 2017-11-21 23:26 UTC (permalink / raw)
  To: Git, Thomas Gummerer; +Cc: Phil Hord

`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

* [PATCH] doc: prefer 'stash push' instead of 'stash save'
  2017-11-21 23:26 [PATCH] stash: Learn to parse -m/--message like commit does Phil Hord
@ 2017-11-21 23:26 ` Phil Hord
  2017-11-22  4:44 ` [PATCH] stash: Learn to parse -m/--message like commit does Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Phil Hord @ 2017-11-21 23:26 UTC (permalink / raw)
  To: Git, Thomas Gummerer; +Cc: Phil Hord

Although `git stash save` was deprecated recently, some parts of the
documentation still refer to it.

Signed-off-by: Phil Hord <phil.hord@gmail.com>
---
 Documentation/git-stash.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 8be661007..056dfb866 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -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
 ----------
-- 
2.15.0.471.g17a719cfe.dirty


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

* Re: [PATCH] stash: Learn to parse -m/--message like commit does
  2017-11-21 23:26 [PATCH] stash: Learn to parse -m/--message like commit does Phil Hord
  2017-11-21 23:26 ` [PATCH] doc: prefer 'stash push' instead of 'stash save' Phil Hord
@ 2017-11-22  4:44 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2017-11-22  4:44 UTC (permalink / raw)
  To: Phil Hord; +Cc: Git, Thomas Gummerer

Phil Hord <phil.hord@gmail.com> writes:

> `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(+)

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.


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

end of thread, other threads:[~2017-11-22  4:44 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:26 [PATCH] stash: Learn to parse -m/--message like commit does Phil Hord
2017-11-21 23:26 ` [PATCH] doc: prefer 'stash push' instead of 'stash save' Phil Hord
2017-11-22  4:44 ` [PATCH] stash: Learn to parse -m/--message like commit does Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).