threads / discuss / 48061

[GSoC] parse: not show usage help when invalid id

Subject: [GSoC] parse: not show usage help when invalid id

## tl;dr

2 messages between Mar 16, 2018 and Mar 16, 2018.

replies: 1people: 2as markdown or json

Roger Solano· Mar 16, 2018, 22:33 UTC · lore

patch for too chatty command when <id> is invalid ex. git tag --contains <id>

It is possible to skip 'goto show_usage_error' when parse_long_opt fails? and return directly from there.

Signed-off-by: Roger Solano <sc_rogeralberto@hotmail.com>
---
 parse-options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/parse-options.c b/parse-options.c
index 125e84f98..074915eb3 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -550,7 +550,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
 			goto show_usage;
 		switch (parse_long_opt(ctx, arg + 2, options)) {
 		case -1:
-			goto show_usage_error;
+			return -1; 
 		case -2:
 			goto unknown;
 		}
-- 
2.13.6
Junio C Hamano· Mar 16, 2018, 23:05 UTC · re: Roger Solano · lore

Re: [GSoC] parse: not show usage help when invalid id

Roger Solano <sroger.git@gmail.com> writes:
Show 5 quoted lines
> patch for too chatty command when <id> is invalid
> ex. git tag --contains <id>
>
> It is possible to skip 'goto show_usage_error' when
> parse_long_opt fails? and return directly from there.

Can you explain how this relates to and/or compares with a recent update [1]?

Thanks.
[1] https://public-inbox.org/git/20180306193116.23876-1-ungureanupaulsebastian@gmail.com
Show 19 quoted lines
>
> Signed-off-by: Roger Solano <sc_rogeralberto@hotmail.com>
> ---
>  parse-options.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/parse-options.c b/parse-options.c
> index 125e84f98..074915eb3 100644
> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -550,7 +550,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
>  			goto show_usage;
>  		switch (parse_long_opt(ctx, arg + 2, options)) {
>  		case -1:
> -			goto show_usage_error;
> +			return -1; 
>  		case -2:
>  			goto unknown;
>  		}

← back to recent threads