Merge branch 'br/commit-tree-parseopt'
authorJunio C Hamano <gitster@pobox.com>
Wed, 20 Mar 2019 06:16:08 +0000 (15:16 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Mar 2019 06:16:08 +0000 (15:16 +0900)
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

1  2 
parse-options.h
diff --cc parse-options.h
index 7d83e2971d9afa11b11d6187bd96afb88cbb6118,3a442eee26c4d3c7e4fa50405bbd3cadb896fa6e..74cce4e7fce74237292e0b34bec2b02e0e945ca7
@@@ -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
  };