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

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

From
Kyle Meyer <kyle@kyleam.com>
Date
Nov 24, 2022, 02:00 UTC
Message-ID
<20221124020056.242185-1-kyle@kyleam.com>

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.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
---
 git-send-email.perl   | 2 +-
 t/t9001-send-email.sh | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 5861e99a6e..1e6d5d7677 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -24,7 +24,7 @@
 use Git;
 use Git::I18N;
 
-Getopt::Long::Configure qw/ pass_through /;
+Getopt::Long::Configure qw/ pass_through no_auto_abbrev /;
 
 package FakeTerm;
 sub new {
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 01c74b8b07..c2ebf19ec6 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -2334,6 +2334,12 @@ test_expect_success $PREREQ 'test that send-email works outside a repo' '
 		"$(pwd)/0001-add-main.patch"
 '
 
+test_expect_success $PREREQ 'send-email relays -v 4' '
+	test_when_finished "rm -f out" &&
+	git send-email --dry-run -v 4 -1 >out &&
+	grep "PATCH v4" out
+'
+
 test_expect_success $PREREQ 'test that sendmail config is rejected' '
 	test_config sendmail.program sendmail &&
 	test_must_fail git send-email \

base-commit: e7e5c6f715b2de7bea0d39c7d2ba887335b40aa0
-- 
2.38.1
Next: Junio C Hamano
Message 1 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.