Re: [PATCH v2 2/4] stripspace: Use parse-options for command-line parsing
On 2015-10-16 at 19:29:35 +0200, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
> >> - if (mode == INVAL)
> >> - usage(usage_msg);
> >
> > When given "git stripspace -s blorg", we used to set mode to INVAL
> > and then showed the correct usage. But we no longer have a check
> > that corresponds to the old INVAL thing, do we? Perhaps check argc
> > to detect presence of an otherwise ignored non-option argument
> > immediately after parse_options() returns?
>
> Perhaps like this.
Thanks. I'll fold it into v3.
Show 17 quoted lines
> diff --git a/builtin/stripspace.c b/builtin/stripspace.c
> index ac1ab3d..a8b7a93 100644
> --- a/builtin/stripspace.c
> +++ b/builtin/stripspace.c
> @@ -40,8 +40,9 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
> OPT_END()
> };
>
> - argc = parse_options(argc, argv, prefix, options, stripspace_usage,
> - PARSE_OPT_KEEP_DASHDASH);
> + argc = parse_options(argc, argv, prefix, options, stripspace_usage, 0);
> + if (argc)
> + usage_with_options(stripspace_usage, options);
>
> if (mode == STRIP_COMMENTS || mode == COMMENT_LINES)
> git_config(git_default_config, NULL);
>