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

Re: [PATCH v2] Teach stash to parse -m/--message like commit does

From
Jeff King <peff@peff.net>
Date
Nov 22, 2017, 22:01 UTC
Message-ID
<20171122220155.GD2854@sigill>
In-Reply-To
<20171122212031.5988-1-phil.hord@gmail.com>
On Wed, Nov 22, 2017 at 01:20:30PM -0800, Phil Hord wrote:
Show 9 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.  The stash
> documentation doesn't suggest this syntax should work, but gitcli
> does and my fingers have learned this pattern long ago for `commit`.
> 
> Teach `git stash` and `git store` to parse -mFoo and --message=Foo
> the same as `git commit` would do.  Even though it's an internal
> function, add similar support to create_stash() for consistency.

I definitely approve of the goal. The implementation looks pretty straightforward given the current parsing scheme.

Many of our other scripts lean on "rev-parse --parseopt" to handle options. E.g.:

OPTIONS="\
git foo [options]
--
m,message=     stash message
"
foo() {
	for i in "$@"; do echo " pre: $i"; done
	eval "$(echo -n "$OPTIONS" | git rev-parse --parseopt -- "$@")"
	for i in "$@"; do echo "post: $i"; done
}
foo -mmsg
foo -m msg
foo --message=msg
foo --message msg

should convert each of those into "-m msg". It also handles unique partial options like "--mess", though IMHO that is not that big a deal.

Would it be possible to convert stash to use --parseopt? I'm fine if the answer is "no", or even "yes, but it's tricky so let's do this in the meantime". But I think that's the endgame we should be shooting for (or, of course, doing the whole thing in C, which I think somebody else is working on).

-Peff
Previous: Phil HordNext: Junio C Hamano
Message 2 of 3 in “Teach stash to parse -m/--message like commit does”
  1. Teach stash to parse -m/--message like commit doesPhil Hord, Nov 22, 2017
  2. Jeff KingNov 22, 2017
  3. Junio C HamanoNov 24, 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.