Re: [RFC PATCH] stash: accept options also when subcommand 'save' is omitted
- From
Jeff King <peff@peff.net>
- Date
- Aug 18, 2009, 17:45 UTC
- Message-ID
- <20090818174509.GA27518@coredump.intra.peff.net>
- In-Reply-To
- <vpqws51l1hb.fsf@bauges.imag.fr>
On Tue, Aug 18, 2009 at 03:01:52PM +0200, Matthieu Moy wrote:
Show 15 quoted lines
> Hmm, googling a bit, I just noticed that there's already something in > pu: > ea41cfc4f (Make 'git stash -k' a short form for 'git stash save --keep-index') > which also does the trick, while adding a -k alias for --keep-index. > > [...] > > Mine has at least two advantages: > > * It won't require changing the code again when new options are added > to 'git stash save'. > > * It works with 'git stash -k -q' for example, while the other > proposal checks that $# == 1, which won't work if there are more > than one option.
I think yours is nicer, especially as we have just added the '-p|--patch' option, as well. With what is there now, you can do "git stash -p", but not "git stash -p -k".
> But I may have missed its drawbacks ;-)
The only I can think of is that bogus input will provoke 'save'. So something like:
git stash --apply
will invoke "git stash save --apply", which doesn't even complain. It just tries to make a stash with message --apply. Now of course this input is obviously bogus, but probably the right thing to do is complain.
OTOH, I think it is the fault of "git stash save --apply" for not doing the complaining, so your patch really isn't making it worse. Probably it should barf on anything unrecognized starting with a '-', and allow '--' to separate the message from the rest of the options (in the rare case that you want a message starting with '-').
-Peff