]> git.ipfire.org Git - thirdparty/git.git/commit - parse-options.h
parse-options: convert "command mode" to a flag
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 20 Feb 2020 14:15:16 +0000 (15:15 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Feb 2020 21:20:40 +0000 (13:20 -0800)
commitbc8620b44094e9fb6fc20d141678f9b845c19193
treea2120bed53eaf4ae3028c1dab988b3428fb5661e
parent62e7a6f7a1427f461e72ccd5acebc200d55747e0
parse-options: convert "command mode" to a flag

OPTION_CMDMODE is essentially OPTION_SET_INT plus an extra check that
the variable had not set before.  In order to allow custom processing
of the option, for example a "command mode" option that also has an
argument, it would be nice to use OPTION_CALLBACK and not have to rewrite
the extra check on incompatible options.  In other words, making the
processing of the option orthogonal to the "only one of these" behavior
provided by OPTION_CMDMODE.

Add a new flag that takes care of the check, and modify OPT_CMDMODE to
use it together with OPTION_SET_INT.  The new flag still requires that the
option value points to an int, but any OPTION_* value can be specified as
long as it does not require a non-int type for opt->value.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c
parse-options.h