]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/parse-options-boolean'
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Oct 2011 19:34:15 +0000 (12:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Oct 2011 19:34:15 +0000 (12:34 -0700)
* jc/parse-options-boolean:
  apply: use OPT_NOOP_NOARG
  revert: use OPT_NOOP_NOARG
  parseopt: add OPT_NOOP_NOARG
  archive.c: use OPT_BOOL()
  parse-options: deprecate OPT_BOOLEAN

Conflicts:
builtin/revert.c

1  2 
builtin/revert.c

index 200149e2e78525d34f04eb29752453561faf5d88,db5b1d49cc5f7143279c90d0234e17b1646c9b8b..010508d571a5425aac2e0f5390ebac9698a5d1cb
@@@ -92,62 -69,18 +92,60 @@@ static int option_parse_x(const struct 
        return 0;
  }
  
 -static void parse_args(int argc, const char **argv)
 +static void verify_opt_compatible(const char *me, const char *base_opt, ...)
 +{
 +      const char *this_opt;
 +      va_list ap;
 +
 +      va_start(ap, base_opt);
 +      while ((this_opt = va_arg(ap, const char *))) {
 +              if (va_arg(ap, int))
 +                      break;
 +      }
 +      va_end(ap);
 +
 +      if (this_opt)
 +              die(_("%s: %s cannot be used with %s"), me, this_opt, base_opt);
 +}
 +
 +static void verify_opt_mutually_compatible(const char *me, ...)
 +{
 +      const char *opt1, *opt2 = NULL;
 +      va_list ap;
 +
 +      va_start(ap, me);
 +      while ((opt1 = va_arg(ap, const char *))) {
 +              if (va_arg(ap, int))
 +                      break;
 +      }
 +      if (opt1) {
 +              while ((opt2 = va_arg(ap, const char *))) {
 +                      if (va_arg(ap, int))
 +                              break;
 +              }
 +      }
 +
 +      if (opt1 && opt2)
 +              die(_("%s: %s cannot be used with %s"), me, opt1, opt2);
 +}
 +
 +static void parse_args(int argc, const char **argv, struct replay_opts *opts)
  {
 -      const char * const * usage_str = revert_or_cherry_pick_usage();
 +      const char * const * usage_str = revert_or_cherry_pick_usage(opts);
 +      const char *me = action_name(opts);
-       int noop;
 +      int reset = 0;
 +      int contin = 0;
        struct option options[] = {
 -              OPT_BOOLEAN('n', "no-commit", &no_commit, "don't automatically commit"),
 -              OPT_BOOLEAN('e', "edit", &edit, "edit the commit message"),
 +              OPT_BOOLEAN(0, "reset", &reset, "forget the current operation"),
 +              OPT_BOOLEAN(0, "continue", &contin, "continue the current operation"),
 +              OPT_BOOLEAN('n', "no-commit", &opts->no_commit, "don't automatically commit"),
 +              OPT_BOOLEAN('e', "edit", &opts->edit, "edit the commit message"),
-               { OPTION_BOOLEAN, 'r', NULL, &noop, NULL, "no-op (backward compatibility)",
-                 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 0 },
+               OPT_NOOP_NOARG('r', NULL),
 -              OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
 -              OPT_INTEGER('m', "mainline", &mainline, "parent number"),
 -              OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
 -              OPT_STRING(0, "strategy", &strategy, "strategy", "merge strategy"),
 -              OPT_CALLBACK('X', "strategy-option", &xopts, "option",
 +              OPT_BOOLEAN('s', "signoff", &opts->signoff, "add Signed-off-by:"),
 +              OPT_INTEGER('m', "mainline", &opts->mainline, "parent number"),
 +              OPT_RERERE_AUTOUPDATE(&opts->allow_rerere_auto),
 +              OPT_STRING(0, "strategy", &opts->strategy, "strategy", "merge strategy"),
 +              OPT_CALLBACK('X', "strategy-option", &opts, "option",
                        "option for merge strategy", option_parse_x),
                OPT_END(),
                OPT_END(),