parse-options: PARSE_OPT_KEEP_UNKNOWN only applies to --options
The description of 'PARSE_OPT_KEEP_UNKNOWN' starts with "Keep unknown arguments instead of erroring out". This is a bit misleading, as this flag only applies to unknown --options, while non-option arguments are kept even without this flag. Update the description to clarify this, and rename the flag to PARSE_OPTIONS_KEEP_UNKNOWN_OPT to make this obvious just by looking at the flag name. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
80882bc5e7
commit
99d86d60e5
@ -332,7 +332,7 @@ again:
|
||||
rest = NULL;
|
||||
if (!rest) {
|
||||
/* abbreviated? */
|
||||
if (!(p->flags & PARSE_OPT_KEEP_UNKNOWN) &&
|
||||
if (!(p->flags & PARSE_OPT_KEEP_UNKNOWN_OPT) &&
|
||||
!strncmp(long_name, arg, arg_end - arg)) {
|
||||
is_abbreviated:
|
||||
if (abbrev_option &&
|
||||
@ -515,7 +515,7 @@ static void parse_options_start_1(struct parse_opt_ctx_t *ctx,
|
||||
ctx->prefix = prefix;
|
||||
ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0);
|
||||
ctx->flags = flags;
|
||||
if ((flags & PARSE_OPT_KEEP_UNKNOWN) &&
|
||||
if ((flags & PARSE_OPT_KEEP_UNKNOWN_OPT) &&
|
||||
(flags & PARSE_OPT_STOP_AT_NON_OPTION) &&
|
||||
!(flags & PARSE_OPT_ONE_SHOT))
|
||||
BUG("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
|
||||
@ -839,7 +839,7 @@ enum parse_opt_result parse_options_step(struct parse_opt_ctx_t *ctx,
|
||||
unknown:
|
||||
if (ctx->flags & PARSE_OPT_ONE_SHOT)
|
||||
break;
|
||||
if (!(ctx->flags & PARSE_OPT_KEEP_UNKNOWN))
|
||||
if (!(ctx->flags & PARSE_OPT_KEEP_UNKNOWN_OPT))
|
||||
return PARSE_OPT_UNKNOWN;
|
||||
ctx->out[ctx->cpidx++] = ctx->argv[0];
|
||||
ctx->opt = NULL;
|
||||
|
||||
Reference in New Issue
Block a user