diff options
Diffstat (limited to 'third_party/git/parse-options.c')
-rw-r--r-- | third_party/git/parse-options.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/third_party/git/parse-options.c b/third_party/git/parse-options.c index 63d6bab60c0e..87b26a1d922e 100644 --- a/third_party/git/parse-options.c +++ b/third_party/git/parse-options.c @@ -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->flags & PARSE_OPT_CMDMODE) || + that->type != OPTION_CMDMODE || that->value != opt->value || that->defval != *(int *)opt->value) continue; @@ -95,14 +95,6 @@ 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); @@ -138,6 +130,16 @@ 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; @@ -355,7 +357,8 @@ is_abbreviated: } /* negated? */ if (!starts_with(arg, "no-")) { - if (skip_prefix(long_name, "no-", &long_name)) { + if (starts_with(long_name, "no-")) { + long_name += 3; opt_flags |= OPT_UNSET; goto again; } @@ -417,7 +420,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); } @@ -425,7 +428,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); } } @@ -620,7 +623,7 @@ static int show_gitcomp(const struct option *opts) * Scan and may produce a new option[] array, which should be used * instead of the original 'options'. * - * Right now this is only used to preprocess and substitute + * Right now this is only used to preprocess and substitue * OPTION_ALIAS. */ static struct option *preprocess_options(struct parse_opt_ctx_t *ctx, @@ -777,8 +780,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx, continue; } - if (!arg[2] /* "--" */ || - !strcmp(arg + 2, "end-of-options")) { + if (!arg[2]) { /* "--" */ if (!(ctx->flags & PARSE_OPT_KEEP_DASHDASH)) { ctx->argc--; ctx->argv++; |