Subject: Re: how optparse can go horribly wrong

From: Clemens Buchacher <[email-masked]>
Date: Mon, 28 Sep 2009 15:37:07 +0200

On Sat, Sep 26, 2009 at 12:25:27PM -0700, Shawn O. Pearce wrote:

> What I think we should do is not allow cuddling of short options
> when the final option takes more than 1 character worth of argument.
> Thus `git commit -a -mfoo` is OK, but `git commit -amfoo` is not.

I also think that would be the most sensible solution.

A little experimentation with git-log reveals that it does not behave very
well either.

 git log -n1asdf	-> asdf is ignored
 git log -pn1		-> error
 git log -p1		-> error
 git log -1p		-> p is ignored

So I think this should instead behave just like you described above.

 git log -n1asdf	-> error: unknown option(s) -asdf
 git log -pn1		-> git log -p -n1
 git log -p1		-> git log -p -n1
 git log -1p		-> git log -p -n1

Clemens