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

Re: [PATCH] send-email: disable option auto-abbreviation

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 25, 2022, 07:11 UTC
Message-ID
<xmqqv8n3cxv9.fsf@gitster.g>
In-Reply-To
<20221124020056.242185-1-kyle@kyleam.com>
Kyle Meyer <kyle@kyleam.com> writes:
Show 17 quoted lines
> send-email supports specifying format-patch options.  However, some
> valid format-patch short options trigger an error because Getopt's
> default auto-abbreviation is enabled.  For example, with
>
>   git send-email -v 3 @{u}
>
> the -v is consumed as send-email's --validate, and 3 is passed on to
> the format-patch call, leading to
>
>   fatal: ambiguous argument '3': unknown revision or path not in the
>   working tree.  [...]
>
> Disable Getopt's auto-abbreviation feature so that such options are
> properly relayed to format-patch.  With this change, there is some
> risk of breaking external scripts that rely on the abbreviation, but
> that is hopefully unlikely given that Git does not advertise support
> for auto-abbreviation and most subcommands do not support it.

I personally have no sympathy to those who drive "format-patch" from inside "send-email".

Having said that.

Many subcommands of "git" do take uniquely abbreviated double-dashed option names, but it is true that we do not allow --vanything to be given as -v even when there is no other double-dashed option that begins with 'v', so "git send-email -v" that stands for "git send-email --validate" indeed is an odd thing.

But robbing "git send-email --val" that expands to "--validate" from the users is going a bit too far, I am afraid. The right solution for allowing "-v 3" given to "format-patch" I think is to make send-email understand it and pass that through. The presence of both ("validate" => \$validate) and ("v" => \$reroll_count) in the GetOptions() argument would prevent "-v" to be taken as "--validate" while still allowing "--val" to be used as an abbrevatiion, no?

By the way, do we advertise support for any and all options to format-patch when the feature to drive it from send-email is used? Some of the options (e.g. "-o <directory>") do not make any sense in the context I would suspect.

Previous: Kyle MeyerNext: Kyle Meyer
Message 2 of 7 in “send-email: disable option auto-abbreviation”
  1. send-email: disable option auto-abbreviationKyle Meyer, Nov 24, 2022
  2. Junio C HamanoNov 25, 2022
  3. Kyle MeyerNov 25, 2022
  4. send-email: relay '-v N' to format-patchKyle Meyer, Nov 26, 2022
  5. Junio C HamanoNov 27, 2022
  6. Ævar Arnfjörð BjarmasonNov 28, 2022
  7. Junio C HamanoNov 28, 2022

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.