]> git.ipfire.org Git - thirdparty/git.git/commit
parse-options: clearer reporting of API misuse
authorJonathan Nieder <jrnieder@gmail.com>
Thu, 2 Dec 2010 06:01:18 +0000 (00:01 -0600)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Dec 2010 22:15:12 +0000 (14:15 -0800)
commit1e5ce570ca368b97c8e3b238bb0228c5ca41b494
tree8b56df17fd7985bd93d2ff1d5c55b5b7a577962a
parent9ca1169fd92c71ebbef92ff18aa5d91a2157d1bd
parse-options: clearer reporting of API misuse

The PARSE_OPT_LASTARG_DEFAULT flag is meant for options like
--contains that (1) traditionally had a mandatory argument and
(2) have some better behavior to use when appearing in the final
position.  It makes no sense to combine this with OPTARG, so ever
since v1.6.4-rc0~71 (parse-options: add parse_options_check to
validate option specs, 2009-07-09) this mistake is flagged with

error: `--option` uses incompatible flags LASTARG_DEFAULT and OPTARG

and an exit status representing an error in commandline usage.

Unfortunately that which might confuse scripters calling such an
erroneous program into thinking the _script_ contains an error.
Clarify that it is an internal error by dying with a message beginning
"error: BUG: ..." and status 128.

While at it, clean up parse_options_check to prepare for more checks.

Long term, it would be nicer to make such checks happen at compile
time.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c