Skip to content

Commit 6ff658c

Browse files
tmzullingergitster
authored andcommitted
send-email: avoid duplicate specification warnings
A warning is issued for options which are specified more than once beginning with perl-Getopt-Long >= 2.55. 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. These are primarily the explicit '--no-' prefix opts which were added in f471494 (git-send-email.perl: support no- prefix with older GetOptions, 2015-01-30). This was done specifically to support perl-5.8.0 which includes Getopt::Long 2.32[1]. Getopt::Long 2.33 added support for the '--no-' prefix natively by appending '!' to the option specification string, which was included in perl-5.8.1 and is not present in perl-5.8.0. The previous commit bumped the minimum supported Perl version to 5.8.1 so we no longer need to provide the '--no-' variants for negatable options manually. 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d13a73e commit 6ff658c

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

git-send-email.perl

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,16 @@ sub completion_helper {
119119

120120
foreach my $key (keys %$original_opts) {
121121
unless (exists $not_for_completion{$key}) {
122-
$key =~ s/!$//;
122+
my $negatable = ($key =~ s/!$//);
123123

124124
if ($key =~ /[:=][si]$/) {
125125
$key =~ s/[:=][si]$//;
126126
push (@send_email_opts, "--$_=") foreach (split (/\|/, $key));
127127
} else {
128128
push (@send_email_opts, "--$_") foreach (split (/\|/, $key));
129+
if ($negatable) {
130+
push (@send_email_opts, "--no-$_") foreach (split (/\|/, $key));
131+
}
129132
}
130133
}
131134
}
@@ -491,7 +494,6 @@ sub config_regexp {
491494
"bcc=s" => \@getopt_bcc,
492495
"no-bcc" => \$no_bcc,
493496
"chain-reply-to!" => \$chain_reply_to,
494-
"no-chain-reply-to" => sub {$chain_reply_to = 0},
495497
"sendmail-cmd=s" => \$sendmail_cmd,
496498
"smtp-server=s" => \$smtp_server,
497499
"smtp-server-option=s" => \@smtp_server_options,
@@ -506,36 +508,27 @@ sub config_regexp {
506508
"smtp-auth=s" => \$smtp_auth,
507509
"no-smtp-auth" => sub {$smtp_auth = 'none'},
508510
"annotate!" => \$annotate,
509-
"no-annotate" => sub {$annotate = 0},
510511
"compose" => \$compose,
511512
"quiet" => \$quiet,
512513
"cc-cmd=s" => \$cc_cmd,
513514
"header-cmd=s" => \$header_cmd,
514515
"no-header-cmd" => \$no_header_cmd,
515516
"suppress-from!" => \$suppress_from,
516-
"no-suppress-from" => sub {$suppress_from = 0},
517517
"suppress-cc=s" => \@suppress_cc,
518518
"signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
519-
"no-signed-off-cc|no-signed-off-by-cc" => sub {$signed_off_by_cc = 0},
520-
"cc-cover|cc-cover!" => \$cover_cc,
521-
"no-cc-cover" => sub {$cover_cc = 0},
522-
"to-cover|to-cover!" => \$cover_to,
523-
"no-to-cover" => sub {$cover_to = 0},
519+
"cc-cover!" => \$cover_cc,
520+
"to-cover!" => \$cover_to,
524521
"confirm=s" => \$confirm,
525522
"dry-run" => \$dry_run,
526523
"envelope-sender=s" => \$envelope_sender,
527524
"thread!" => \$thread,
528-
"no-thread" => sub {$thread = 0},
529525
"validate!" => \$validate,
530-
"no-validate" => sub {$validate = 0},
531526
"transfer-encoding=s" => \$target_xfer_encoding,
532527
"format-patch!" => \$format_patch,
533-
"no-format-patch" => sub {$format_patch = 0},
534528
"8bit-encoding=s" => \$auto_8bit_encoding,
535529
"compose-encoding=s" => \$compose_encoding,
536530
"force" => \$force,
537531
"xmailer!" => \$use_xmailer,
538-
"no-xmailer" => sub {$use_xmailer = 0},
539532
"batch-size=i" => \$batch_size,
540533
"relogin-delay=i" => \$relogin_delay,
541534
"git-completion-helper" => \$git_completion_helper,

0 commit comments

Comments
 (0)