From: Junio C Hamano Date: Wed, 4 Sep 2013 19:37:52 +0000 (-0700) Subject: Merge branch 'jc/parseopt-command-modes' X-Git-Tag: v1.8.5-rc0~179 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/v1.8.4-82-g366b80b?hp=-c Merge branch 'jc/parseopt-command-modes' Many commands use --dashed-option as a operation mode selector (e.g. "git tag --delete") that the user can use at most one (e.g. "git tag --delete --verify" is a nonsense) and you cannot negate (e.g. "git tag --no-delete" is a nonsense). Make it easier for users of parse_options() to enforce these restrictions. * jc/parseopt-command-modes: tag: use OPT_CMDMODE parse-options: add OPT_CMDMODE() --- 366b80bf0a84b607115bd4ffcd8e5ebfc7338442 diff --combined parse-options.h index 9b94596e4a,2404e06732..f37fc88143 --- a/parse-options.h +++ b/parse-options.h @@@ -13,6 -13,7 +13,7 @@@ enum parse_opt_type OPTION_COUNTUP, OPTION_SET_INT, OPTION_SET_PTR, + OPTION_CMDMODE, /* options with arguments (usually) */ OPTION_STRING, OPTION_INTEGER, @@@ -130,6 -131,8 +131,8 @@@ struct option #define OPT_BOOL(s, l, v, h) OPT_SET_INT(s, l, v, h, 1) #define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, \ (h), PARSE_OPT_NOARG, NULL, (p) } + #define OPT_CMDMODE(s, l, v, h, i) { OPTION_CMDMODE, (s), (l), (v), NULL, \ + (h), PARSE_OPT_NOARG|PARSE_OPT_NONEG, NULL, (i) } #define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), N_("n"), (h) } #define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) } #define OPT_STRING_LIST(s, l, v, a, h) \ @@@ -180,7 -183,7 +183,7 @@@ extern NORETURN void usage_msg_opt(cons extern int optbug(const struct option *opt, const char *reason); extern int opterror(const struct option *opt, const char *reason, int flags); -#if defined(__GNUC__) && ! defined(clang) +#if defined(__GNUC__) && ! defined(__clang__) #define opterror(o,r,f) (opterror((o),(r),(f)), -1) #endif