builtin/reset: compute checkout metadata for reset
[git] / parse-options.c
index e8c0410..63d6bab 100644 (file)
@@ -61,7 +61,7 @@ static enum parse_opt_result opt_command_mode_error(
         */
        for (that = all_opts; that->type != OPTION_END; that++) {
                if (that == opt ||
-                   that->type != OPTION_CMDMODE ||
+                   !(that->flags & PARSE_OPT_CMDMODE) ||
                    that->value != opt->value ||
                    that->defval != *(int *)opt->value)
                        continue;
@@ -95,6 +95,14 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
        if (!(flags & OPT_SHORT) && p->opt && (opt->flags & PARSE_OPT_NOARG))
                return error(_("%s takes no value"), optname(opt, flags));
 
+       /*
+        * Giving the same mode option twice, although unnecessary,
+        * is not a grave error, so let it pass.
+        */
+       if ((opt->flags & PARSE_OPT_CMDMODE) &&
+           *(int *)opt->value && *(int *)opt->value != opt->defval)
+               return opt_command_mode_error(opt, all_opts, flags);
+
        switch (opt->type) {
        case OPTION_LOWLEVEL_CALLBACK:
                return opt->ll_callback(p, opt, NULL, unset);
@@ -130,16 +138,6 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
                *(int *)opt->value = unset ? 0 : opt->defval;
                return 0;
 
-       case OPTION_CMDMODE:
-               /*
-                * Giving the same mode option twice, although is unnecessary,
-                * is not a grave error, so let it pass.
-                */
-               if (*(int *)opt->value && *(int *)opt->value != opt->defval)
-                       return opt_command_mode_error(opt, all_opts, flags);
-               *(int *)opt->value = opt->defval;
-               return 0;
-
        case OPTION_STRING:
                if (unset)
                        *(const char **)opt->value = NULL;
@@ -419,7 +417,7 @@ static void check_typos(const char *arg, const struct option *options)
                return;
 
        if (starts_with(arg, "no-")) {
-               error(_("did you mean `--%s` (with two dashes ?)"), arg);
+               error(_("did you mean `--%s` (with two dashes)?"), arg);
                exit(129);
        }
 
@@ -427,7 +425,7 @@ static void check_typos(const char *arg, const struct option *options)
                if (!options->long_name)
                        continue;
                if (starts_with(options->long_name, arg)) {
-                       error(_("did you mean `--%s` (with two dashes ?)"), arg);
+                       error(_("did you mean `--%s` (with two dashes)?"), arg);
                        exit(129);
                }
        }