From: Junio C Hamano Date: Wed, 20 Mar 2019 06:16:08 +0000 (+0900) Subject: Merge branch 'br/commit-tree-parseopt' X-Git-Tag: v2.22.0-rc0~135 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0c45fa32ec87b15fd828bcbfc41d0d2349b4e7ad Merge branch 'br/commit-tree-parseopt' The command line parser of "git commit-tree" has been rewritten to use the parse-options API. * br/commit-tree-parseopt: commit-tree: utilize parse-options api --- 0c45fa32ec87b15fd828bcbfc41d0d2349b4e7ad diff --cc parse-options.h index 7d83e2971d,3a442eee26..74cce4e7fc --- a/parse-options.h +++ b/parse-options.h @@@ -222,14 -202,25 +222,25 @@@ const char *optname(const struct optio BUG("option callback does not expect an argument"); \ } while (0) + /* + * Similar to the assertions above, but checks that "arg" is always non-NULL. + * This assertion also implies BUG_ON_OPT_NEG(), letting you declare both + * assertions in a single line. + */ + #define BUG_ON_OPT_NEG_NOARG(unset, arg) do { \ + BUG_ON_OPT_NEG(unset); \ + if(!(arg)) \ + BUG("option callback expects an argument"); \ + } while(0) + /*----- incremental advanced APIs -----*/ -enum { - PARSE_OPT_COMPLETE = -2, - PARSE_OPT_HELP = -1, - PARSE_OPT_DONE, +enum parse_opt_result { + PARSE_OPT_COMPLETE = -3, + PARSE_OPT_HELP = -2, + PARSE_OPT_ERROR = -1, /* must be the same as error() */ + PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */ PARSE_OPT_NON_OPTION, - PARSE_OPT_ERROR, PARSE_OPT_UNKNOWN };