git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GSoC][PATCH v3] Make options that expect object ids less chatty if id is invalid

From
Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Date
Mar 6, 2018, 19:44 UTC
Message-ID
<1520365472.27478.7.camel@gmail.com>
In-Reply-To
<xmqqzi3m6ooi.fsf@gitster-ct.c.googlers.com>
Hello Junio,

Thank you for reviewing my code. I appreciate it. I made the changes here [1].

On Mon, 2018-03-05 at 16:19 -0800, Junio C Hamano wrote:
Show 9 quoted lines
> Taking these together, I _think_ this patch is moving things in the
> right direction, in that it allows callers of parse_options_step()
> to tell "user knew what option s/he wanted, and sufficient error
> message has already be given" and "user gave us a nonsense option
> and would be helped by usage text" cases apart by introducing a new
> value PARSE_OPT_ERROR, but in order to be able to correctly give
> PARSE_OPT_ERROR back to the caller, parse_long_opt() and
> parse_short_opt() (possibly, but I didn't check) would need a bit of
> tweak to help their callers in this function.
I am not sure I got this right, but I believe this is already done.
- If an error occurs during value parsing in parse_short_opt or
parse_long_opt then -1 is returned and parse_option_step returns
PARSE_OPT_ERROR.
- If parse_short_opt and parse_long_opt encounter an unknown option
then -2 is returned and parse_option_step returns PARSE_OPT_UNKNOWN
(but only if PARSE_OPT_KEEP_UNKNOWN is not specified).
- If usage is shown by calling usage_with_options_internal then
PARSE_OPT_HELP is going to be forwarded and also returned by
parse_options_step.

What I also changed in the new patch [1] is to make parse_long_opt return -3 when ambiguous option are found, in which case parse_options_step will handle this return value by showing usage and returning PARSE_OPT_HELP.

Please correct me if I am wrong.

[1] https://public-inbox.org/git/20180306193116.23876-1-ungureanupaulse bastian@gmail.com/T/#u

Best regards, Paul Ungureanu

Previous: Junio C Hamano
Message 3 of 3 in “Make options that expect object ids less chatty if id is invalid”
  1. Paul-Sebastian UngureanuMar 3, 2018
  2. Junio C HamanoMar 6, 2018
  3. Paul-Sebastian UngureanuMar 6, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.