With perl-Getopt-Long >= 2.55 a warning is issued for options which are
specified more than once. In addition to causing users to see warnings,
this results in test failures which compare the output. An example,
from t9001-send-email.37:
| +++ diff -u expect actual
| --- expect 2023-11-14 10:38:23.854346488 +0000
| +++ actual 2023-11-14 10:38:23.848346466 +0000
| @@ -1,2 +1,7 @@
| +Duplicate specification "no-chain-reply-to" for option "no-chain-reply-to"
| +Duplicate specification "to-cover|to-cover!" for option "to-cover"
| +Duplicate specification "cc-cover|cc-cover!" for option "cc-cover"
| +Duplicate specification "no-thread" for option "no-thread"
| +Duplicate specification "no-to-cover" for option "no-to-cover"
| fatal: longline.patch:35 is longer than 998 characters
| warning: no patches were sent
| error: last command exited with $?=1
| not ok 37 - reject long lines
Remove the duplicate option specs.
Teach `--git-completion-helper` to output the '--no-' options. They are
not included in the options hash and would otherwise be lost.
Signed-off-by: Todd Zullinger <tmz@pobox.com>
---
I compared the output from
git send-email --git-completion-helper | tr ' ' ' '\n' | sort
before and after the change to ensure no options were lost (or added).
I also confirmed that each of the options changed did not result in any
error. Unrecognized options result in an error from `git format-patch`,
e.g.:
$ git send-email --foo
fatal: unrecognized argument: --foo
format-patch -o /tmp/PaqtbH3jCw --foo: command returned error: 128
A little history:
Support for the '--no-' prefix was added in Getopt::Long >= 2.33, in
commit 8ca8b48 (Negatable options (with "!") now also support the
"no-" prefix., 2003-04-04). Getopt::Long 2.34 was included in
perl-5.8.1 (2003-09-25), per Module::CoreList[1].
We list perl-5.8 as the minimum version in INSTALL. This would leave
users with perl-5.8.0 (2002-07-18) with non-working arguments for
options where we're removing the explicit 'no-' variant.
The explicit 'no-' opts were added in f471494303 (git-send-email.perl:
support no- prefix with older GetOptions, 2015-01-30), specifically to
support perl-5.8.0 which includes the older Getopt::Long.
It may be time to bump the Perl requirement to 5.8.1 (2003-09-25) or
even 5.10.0 (2007-12-18). We last bumped the requirement from 5.6 to
5.8 in d48b284183 (perl: bump the required Perl version to 5.8 from
5.6.[21], 2010-09-24).
Another option to avoid the warning from Getopt::Long >= 2.55 would be
to remove the '!' negation, but that would drop support for the 'no'
prefix variants (e.g.: `--nocc-cover`). While these are not documented
(and I don't think they ever were[2]), they have worked for a long, long
time. Odds are good that some scripts rely on them and we don't want
anyone yelling at Junio.
I lean toward dropping support for the 21-year-old 5.8.0.
If there is a way to have our cake without any consequence, I'm happy to
hear it. If not, I'll add a commit which bumps the requirement in
general or notes that some git-send-email requires perl >= 5.8.1 and
adjusts the 'use' line there to `use 5.008001;`.
[1] http://perlpunks.de/corelist/mversion?module=Getopt%3A%3ALong
[2] The 'no-' opts were added in f471494303 (git-send-email.perl:
support no- prefix with older GetOptions, 2015-01-30). The commit
message says "the help only mentions the 'no-' prefix and not the
'no' prefix, add explicit support for the 'no-' prefix to support
older GetOptions versions."
git-send-email.perl | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index cacdbd6bb2..94046e0fb7 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -119,13 +119,16 @@ sub completion_helper {
foreach my $key (keys %$original_opts) {
unless (exists $not_for_completion{$key}) {
- $key =~ s/!$//;
+ my $negate = ($key =~ s/!$//);
if ($key =~ /[:=][si]$/) {
$key =~ s/[:=][si]$//;
push (@send_email_opts, "--$_=") foreach (split (/\|/, $key));
} else {
push (@send_email_opts, "--$_") foreach (split (/\|/, $key));
+ if ($negate) {
+ push (@send_email_opts, "--no-$_") foreach (split (/\|/, $key));
+ }
}
}
}
@@ -491,7 +494,6 @@ sub config_regexp {
"bcc=s" => \@getopt_bcc,
"no-bcc" => \$no_bcc,
"chain-reply-to!" => \$chain_reply_to,
- "no-chain-reply-to" => sub {$chain_reply_to = 0},
"sendmail-cmd=s" => \$sendmail_cmd,
"smtp-server=s" => \$smtp_server,
"smtp-server-option=s" => \@smtp_server_options,
@@ -506,36 +508,27 @@ sub config_regexp {
"smtp-auth=s" => \$smtp_auth,
"no-smtp-auth" => sub {$smtp_auth = 'none'},
"annotate!" => \$annotate,
- "no-annotate" => sub {$annotate = 0},
"compose" => \$compose,
"quiet" => \$quiet,
"cc-cmd=s" => \$cc_cmd,
"header-cmd=s" => \$header_cmd,
"no-header-cmd" => \$no_header_cmd,
"suppress-from!" => \$suppress_from,
- "no-suppress-from" => sub {$suppress_from = 0},
"suppress-cc=s" => \@suppress_cc,
"signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
- "no-signed-off-cc|no-signed-off-by-cc" => sub {$signed_off_by_cc = 0},
- "cc-cover|cc-cover!" => \$cover_cc,
- "no-cc-cover" => sub {$cover_cc = 0},
- "to-cover|to-cover!" => \$cover_to,
- "no-to-cover" => sub {$cover_to = 0},
+ "cc-cover!" => \$cover_cc,
+ "to-cover!" => \$cover_to,
"confirm=s" => \$confirm,
"dry-run" => \$dry_run,
"envelope-sender=s" => \$envelope_sender,
"thread!" => \$thread,
- "no-thread" => sub {$thread = 0},
"validate!" => \$validate,
- "no-validate" => sub {$validate = 0},
"transfer-encoding=s" => \$target_xfer_encoding,
"format-patch!" => \$format_patch,
- "no-format-patch" => sub {$format_patch = 0},
"8bit-encoding=s" => \$auto_8bit_encoding,
"compose-encoding=s" => \$compose_encoding,
"force" => \$force,
"xmailer!" => \$use_xmailer,
- "no-xmailer" => sub {$use_xmailer = 0},
"batch-size=i" => \$batch_size,
"relogin-delay=i" => \$relogin_delay,
"git-completion-helper" => \$git_completion_helper,
--
2.43.0.rc2