On Wed, Nov 22, 2017 at 01:20:30PM -0800, 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. 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