send-email: avoid duplicate specification warnings
PATCH 1/1 send-email: avoid duplicate specification warnings
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.
---
I've run this through the full test suite. I also compared the output of --help to ensure it only differs in the removal of the "Duplicate specification" warnings. I _think_ that's a good sign that no other changes will result. But I would be grateful to anyone who can confirm or reject that theory.
git-send-email.perl | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
git-send-email.perl +3 -13
@@ -491,7 +491,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 +505,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}, + "signed-off-by-cc!" => \$signed_off_by_cc, + "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,
Quoted 19 lines · Todd Zullinger
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
Quoted 1 line
Remove the duplicate option specs.
As long as these manual implementation of "no-" are doing true opposite of the positive one, it should be sufficient to remove them, so I'd prefer to see you explicitly say that you did audit them all to make sure.
For example,
git-send-email.perl sub config_regexp { · line 509
Quoted 2 lines
git-send-email.perl +0
-1"annotate!" => \$annotate, - "no-annotate" => sub {$annotate = 0},
this is an example of good pair. With the former, "--no-annotate" and "--annotate" result in $annotate set to false and true, and the latter attempts to set $annotate to false upon "--no-annotate", so the net result of removing the latter should be a no-op.
git-send-email.perl sub config_regexp { · line 516
Quoted 2 lines
git-send-email.perl +0
-1"suppress-from!" => \$suppress_from, - "no-suppress-from" => sub {$suppress_from = 0},
Ditto.
As it is very late at night here, I didn't do a though job to scan and validate all of them (some did not have their positive counterparts in the context), though. Thanks for woking on this.
Quoted 4 lines · Todd Zullinger
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:
This made me wonder if the warnings are new, or if the duplicated auto-negated options are new. I.e., were the manual "--no-foo" option specs doing something useful in the older versions (in which case we'd need to do something more complicated)?
But I think the answer is no. We've explicitly marked these with "!" to indicate that they're negatable. And certainly running with Getopt::Long 2.52 (from perl 5.36, which is the current in Debian unstable) seems to support them.
It does make me wonder why some boolean options are not marked as negatable (even if just to countermand an earlier option), but that is outside the scope of your patch.
Quoted 5 lines
I've run this through the full test suite. I also compared the output of --help to ensure it only differs in the removal of the "Duplicate specification" warnings. I _think_ that's a good sign that no other changes will result. But I would be grateful to anyone who can confirm or reject that theory.
I guess you meant "-h", not "--help", since the latter will just show the manpage. But isn't "-h" just dumping a static usage message we wrote, and not auto-generated by the code?
The changes look good to me (even after double-checking Junio's question that they are all appropriately matched with their "positive" sides). This one is curious:
git-send-email.perl sub config_regexp { · line 520
Quoted 1 line
git-send-email.perl +0
-1- "cc-cover|cc-cover!" => \$cover_cc,
It was an alternate name for itself? I think somebody just misunderstood how the API was supposed to work. The "!" would applies to all names, if I understand correctly, so this really is doing nothing beyond just "cc-cover!", which is what your patch switches it to.
-Peff
Quoted 10 lines · Jeff King
Quoted 5 lines · Todd Zullinger
I've run this through the full test suite. I also compared the output of --help to ensure it only differs in the removal of the "Duplicate specification" warnings. I _think_ that's a good sign that no other changes will result. But I would be grateful to anyone who can confirm or reject that theory.
I guess you meant "-h", not "--help", since the latter will just show the manpage. But isn't "-h" just dumping a static usage message we wrote, and not auto-generated by the code?
Yes to both. This is why I shouldn't submit patches within a few hours of waking up.
Quoted 2 lines
The changes look good to me (even after double-checking Junio's question that they are all appropriately matched with their "positive" sides).
Indeed. I need to go through them each to test that the results match before and after. With the fallback to passing options to format-patch, testing outside of a git repo makes this rather convenient. If I've dropped an option it will result in the "Cannot run git format-patch from outside a repository" error. That's a good start to ensure the changes don't cause any regressions.
I did notice that I mistakenly dropped --[no-]signed-off-cc. I need to keep:
"signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
as is.
Quoted 8 lines
This one is curious:
git-send-email.perl sub config_regexp { · line 520
Quoted 1 line
git-send-email.perl +0
-1- "cc-cover|cc-cover!" => \$cover_cc,It was an alternate name for itself? I think somebody just misunderstood how the API was supposed to work. The "!" would applies to all names, if I understand correctly, so this really is doing nothing beyond just "cc-cover!", which is what your patch switches it to.
I wondered about those as well. Perhaps this is needed in some older version of Getopt::Long? I'll try to look through the history of the module to see if that's the case.
Since this isn't anything new with 2.43, it doesn't need to be fixed with much urgency.
Thanks both,
Signature · 1 line
Todd
Quoted 2 lines · Todd Zullinger
Since this isn't anything new with 2.43, it doesn't need to be fixed with much urgency.
True. Unless the new version of Getopt::Long is quickly spreading through our user base, that is.
Quoted 1 line
Thanks both,
Thanks for spotting the issue and acting on it quickly.
v2 cover send-email: avoid duplicate specification warnings
Changes since v1:
* Teach --git-completion-helper to output the '--no-' options. They are not included in the options hash and would otherwise be lost.
* Restore the --signed-off-cc alias which was mistakenly removed.
Todd Zullinger (2):
send-email: avoid duplicate specification warnings
send-email: remove stray characters from usage
git-send-email.perl | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
Signature · 1 line
2.43.0.rc2
RFC PATCH v2 1/2 send-email: avoid duplicate specification warnings
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.
---
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: 128A 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(-)
git-send-email.perl +6 -13
@@ -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,
Signature · 1 line
2.43.0.rc2
Quoted 19 lines · Todd Zullinger
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
Quoted 4 lines
Remove the duplicate option specs.
Teach
--git-completion-helperto output the '--no-' options. They are not included in the options hash and would otherwise be lost.
Nice to see a careful handling of potential fallouts.
Quoted 7 lines
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::Long2.34 was included in perl-5.8.1 (2003-09-25), per Module::CoreList[1].
Quoted 7 lines
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 olderGetopt::Long.
These are all very much relevant and deserve to be in the log message, not hidden under the three-dash line, I would think. Thanks for digging the history. The first paragraph was a bit hard to read as it wasn't clear "support" on which side is being discussed, though. If it were written perhaps like so:
Getopt::Long >= 2.33 started supporting the '--no-' prefix natively by appending '!' to the option specification string, which was shipped with perl-5.8.1 and not present in perl-5.8.0
it would have been clear that it was talking about the support given by Getopt module, not on our side.
Quoted 4 lines
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).
Isn't the position this patch takes a lot stronger than "It may be time"? If we applied this patch, it drops the support for folks with Perl 5.8.0 (which I do not think is a bad thing, by the way).
This sounds like something that is worth describing in the log message (and Release Notes).
Quoted 4 lines
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;.
Sounds like a plan.
git-send-email.perl sub completion_helper { · line 122
Quoted 10 lines
git-send-email.perl +1
-1@@ -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/!$//);
A very minor nit, but I'd call this $negatable if I were doing this patch.
Just to make sure I did not misunderstand what you said below the three-dash line, if we were to take the other option that allows us to live with 5.8.0, we would make this hunk ...
git-send-email.perl sub config_regexp { · line 494
Quoted 2 lines
git-send-email.perl +0
-1"chain-reply-to!" => \$chain_reply_to, - "no-chain-reply-to" => sub {$chain_reply_to = 0},
... look more like this?
git-send-email.perl sub completion_helper { · line 126
Quoted 4 lines
git-send-email.perl +2
-1- "chain-reply-to!" => \$chain_reply_to, + "chain-reply-to" => \$chain_reply_to, "no-chain-reply-to" => sub {$chain_reply_to = 0}, + "nochain-reply-to" => sub {$chain_reply_to = 0},
That is, by removing the "!" suffix, we reject the native support of "--no-*" offered by Getopt::Long, and implement the negated variants ourselves?
Thanks.
v3 cover send-email: avoid duplicate specification warnings
Quoted 1 line · Junio C Hamano
Todd Zullinger <[email protected]> writes:
[...]
Quoted 21 lines
Quoted 7 lines
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::Long2.34 was included in perl-5.8.1 (2003-09-25), per Module::CoreList[1].Quoted 7 lines
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 olderGetopt::Long.These are all very much relevant and deserve to be in the log message, not hidden under the three-dash line, I would think. Thanks for digging the history. The first paragraph was a bit hard to read as it wasn't clear "support" on which side is being discussed, though. If it were written perhaps like so:
Quoted 6 lines
Getopt::Long>= 2.33 started supporting the '--no-' prefix natively by appending '!' to the option specification string, which was shipped with perl-5.8.1 and not present in perl-5.8.0it would have been clear that it was talking about the support given by Getopt module, not on our side.
That is much better. I've adjusted the commit message similarly and hopefully kept your improved wording largely intact.
Quoted 8 lines
Quoted 4 lines
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).Isn't the position this patch takes a lot stronger than "It may be time"? If we applied this patch, it drops the support for folks with Perl 5.8.0 (which I do not think is a bad thing, by the way).
Indeed it is. I should have mentioned that more explicitly. I added the RFC tag to this round because I was unsure whether we'd want to go the route of bumping the Perl requirement. But I managed to not actually say as much.
Quoted 2 lines
This sounds like something that is worth describing in the log message (and Release Notes).
I think the new commit messages describe the changes better. I didn't include anything in RelNotes as I was presuming we'd leave this for 2.44 rather than risk causing any problems this late in the 2.43 cycle. If you think the risk is low and/or the benefit is high, I can add it to the 2.43.0 RelNotes.
Quoted 6 lines
Quoted 6 lines
git-send-email.perl +0
-0@@ -119,13 +119,16 @@ sub completion_helper {
Quoted 7 lines
git-send-email.perl sub completion_helper { · line 122
Quoted 4 lines
git-send-email.perl +1
-1foreach my $key (keys %$original_opts) { unless (exists $not_for_completion{$key}) { - $key =~ s/!$//; + my $negate = ($key =~ s/!$//);A very minor nit, but I'd call this $negatable if I were doing this patch.
Sounds good.
Quoted 9 lines
Just to make sure I did not misunderstand what you said below the three-dash line, if we were to take the other option that allows us to live with 5.8.0, we would make this hunk ...
git-send-email.perl sub config_regexp { · line 494
Quoted 2 lines
git-send-email.perl +0
-1"chain-reply-to!" => \$chain_reply_to, - "no-chain-reply-to" => sub {$chain_reply_to = 0},... look more like this?
Quoted 8 lines
git-send-email.perl sub completion_helper { · line 126
Quoted 4 lines
git-send-email.perl +2
-1- "chain-reply-to!" => \$chain_reply_to, + "chain-reply-to" => \$chain_reply_to, "no-chain-reply-to" => sub {$chain_reply_to = 0}, + "nochain-reply-to" => sub {$chain_reply_to = 0},That is, by removing the "!" suffix, we reject the native support of "--no-*" offered by
Getopt::Long, and implement the negated variants ourselves?
Exactly. We could bundle the two no* options together, but that's a trivial style issue, i.e.:
Review
Quoted 4 lines
(quoted diff) +2
-2- "chain-reply-to!" => \$chain_reply_to, - "no-chain-reply-to" => sub {$chain_reply_to = 0}, + "chain-reply-to" => \$chain_reply_to, + "no-chain-reply-to|nochain-reply-to" => sub {$chain_reply_to = 0},
Thanks for a very helpful review, as always.
Todd Zullinger (2):
perl: bump the required Perl version to 5.8.1 from 5.8.0
send-email: avoid duplicate specification warnings
Documentation/CodingGuidelines | 2 +- INSTALL | 2 +- contrib/diff-highlight/DiffHighlight.pm | 2 +- contrib/mw-to-git/Git/Mediawiki.pm | 2 +- git-archimport.perl | 2 +- git-cvsexportcommit.perl | 2 +- git-cvsimport.perl | 2 +- git-cvsserver.perl | 2 +- git-send-email.perl | 23 ++++++++--------------- git-svn.perl | 2 +- gitweb/INSTALL | 2 +- gitweb/gitweb.perl | 2 +- perl/Git.pm | 2 +- perl/Git/I18N.pm | 2 +- perl/Git/LoadCPAN.pm | 2 +- perl/Git/LoadCPAN/Error.pm | 2 +- perl/Git/LoadCPAN/Mail/Address.pm | 2 +- perl/Git/Packet.pm | 2 +- t/t0202/test.pl | 2 +- t/t5562/invoke-with-content-length.pl | 2 +- t/t9700/test.pl | 2 +- t/test-terminal.perl | 2 +- 22 files changed, 29 insertions(+), 36 deletions(-)
Range-diff against v2:
-: ---------- > 1: b276216a53 perl: bump the required Perl version to 5.8.1 from 5.8.0 1: 59e2c79085 ! 2: e076a2ede5 send-email: avoid duplicate specification warnings
@@ Metadata
## Commit message ##
send-email: avoid duplicate specification warnings
- 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:
+ 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
@@ Commit message
| error: last command exited with $?=1
| not ok 37 - reject long lines
- Remove the duplicate option specs.
+ Remove the duplicate option specs. These are primarily the explicit
+ '--no-' prefix opts which were added in f471494303 (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.
## git-send-email.perl ##
@@ git-send-email.perl: sub completion_helper {
foreach my $key (keys %$original_opts) {
unless (exists $not_for_completion{$key}) {
- $key =~ s/!$//;
-+ my $negate = ($key =~ s/!$//);
++ my $negatable = ($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) {
++ if ($negatable) {
+ push (@send_email_opts, "--no-$_") foreach (split (/\|/, $key));
+ }
}
2: c1f37d4395 < -: ---------- send-email: remove stray characters from usage
Signature · 1 line
2.43.0.rc2
PATCH v3 1/2 perl: bump the required Perl version to 5.8.1 from 5.8.0
The following commit will make use of a Getopt::Long feature which is only present in Perl >= 5.8.1. Document that as the minimum version we support.
Many of our Perl scripts will continue to run with 5.8.0 but this change allows us to adjust them as needed without breaking any promises to our users.
The Perl requirement was last changed in d48b284183 (perl: bump the required Perl version to 5.8 from 5.6.[21], 2010-09-24). At that time, 5.8.0 was 8 years old. It is now over 21 years old.
---
I debated changing all the 'use 5.008;' lines here, as most don't actually require a newer Perl, but the previous bump did the same.
I can see the merit in either direction.
Changing it allows future contributors to be confident in relying on 5.8.1 features.
Not changing it allows anyone stuck on 5.8.0 to continue using the perl scripts which don't actually require 5.8.1.
Tangentially, the Perl docs for 'use' function recommend against the 5.008001 form[1]:
Specifying VERSION as a numeric argument of the form 5.024001 should generally be avoided as older less readable syntax compared to v5.24.1. Before perl 5.8.0 released in 2002 the more verbose numeric form was the only supported syntax, which is why you might see it in older code.
use v5.24.1; # compile time version check
use 5.24.1; # ditto
use 5.024_001; # ditto; older syntax compatible with perl 5.6
I'm not enough of a Perl coder to have a strong preference or desire to push for such a change, but I thought it was worth mentioning in case others wonder why we're using the 5.008001 form.
[1] https://perldoc.perl.org/functions/use#use-VERSION
Documentation/CodingGuidelines | 2 +- INSTALL | 2 +- contrib/diff-highlight/DiffHighlight.pm | 2 +- contrib/mw-to-git/Git/Mediawiki.pm | 2 +- git-archimport.perl | 2 +- git-cvsexportcommit.perl | 2 +- git-cvsimport.perl | 2 +- git-cvsserver.perl | 2 +- git-send-email.perl | 4 ++-- git-svn.perl | 2 +- gitweb/INSTALL | 2 +- gitweb/gitweb.perl | 2 +- perl/Git.pm | 2 +- perl/Git/I18N.pm | 2 +- perl/Git/LoadCPAN.pm | 2 +- perl/Git/LoadCPAN/Error.pm | 2 +- perl/Git/LoadCPAN/Mail/Address.pm | 2 +- perl/Git/Packet.pm | 2 +- t/t0202/test.pl | 2 +- t/t5562/invoke-with-content-length.pl | 2 +- t/t9700/test.pl | 2 +- t/test-terminal.perl | 2 +- 22 files changed, 23 insertions(+), 23 deletions(-)
Documentation/CodingGuidelines +1 -1
@@ -490,7 +490,7 @@ For Perl programs: - Most of the C guidelines above apply. - - We try to support Perl 5.8 and later ("use Perl 5.008"). + - We try to support Perl 5.8.1 and later ("use Perl 5.008001"). - use strict and use warnings are strongly preferred.
INSTALL +1 -1
@@ -119,7 +119,7 @@ Issues of note: - A POSIX-compliant shell is required to run some scripts needed for everyday use (e.g. "bisect", "request-pull"). - - "Perl" version 5.8 or later is needed to use some of the + - "Perl" version 5.8.1 or later is needed to use some of the features (e.g. sending patches using "git send-email", interacting with svn repositories with "git svn"). If you can live without these, use NO_PERL. Note that recent releases of
contrib/diff-highlight/DiffHighlight.pm +1 -1
@@ -1,6 +1,6 @@ package DiffHighlight; -use 5.008; +use 5.008001; use warnings FATAL => 'all'; use strict;
contrib/mw-to-git/Git/Mediawiki.pm +1 -1
@@ -1,6 +1,6 @@ package Git::Mediawiki; -use 5.008; +use 5.008001; use strict; use POSIX; use Git;
git-archimport.perl +1 -1
@@ -54,7 +54,7 @@ =head1 Devel Notes =cut -use 5.008; +use 5.008001; use strict; use warnings; use Getopt::Std;
git-cvsexportcommit.perl +1 -1
@@ -1,6 +1,6 @@ #!/usr/bin/perl -use 5.008; +use 5.008001; use strict; use warnings; use Getopt::Std;
git-cvsimport.perl +1 -1
@@ -13,7 +13,7 @@ # The head revision is on branch "origin" by default. # You can change that with the '-o' option. -use 5.008; +use 5.008001; use strict; use warnings; use Getopt::Long;
git-cvsserver.perl +1 -1
@@ -15,7 +15,7 @@ #### #### -use 5.008; +use 5.008001; use strict; use warnings; use bytes;
git-send-email.perl +2 -2
@@ -16,7 +16,7 @@ # and second line is the subject of the message. # -use 5.008; +use 5.008001; use strict; use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Getopt::Long;
@@ -228,7 +228,7 @@ sub system_or_msg { my @sprintf_args = ($cmd_name ? $cmd_name : $args->[0], $exit_code); if (defined $msg) { # Quiet the 'redundant' warning category, except we - # need to support down to Perl 5.8, so we can't do a + # need to support down to Perl 5.8.1, so we can't do a # "no warnings 'redundant'", since that category was # introduced in perl 5.22, and asking for it will die # on older perls.
git-svn.perl +1 -1
@@ -1,7 +1,7 @@ #!/usr/bin/perl # Copyright (C) 2006, Eric Wong <[email protected]> # License: GPL v2 or later -use 5.008; +use 5.008001; use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use strict; use vars qw/ $AUTHOR $VERSION
gitweb/INSTALL +1 -1
@@ -29,7 +29,7 @@ Requirements ------------ - Core git tools - - Perl 5.8 + - Perl 5.8.1 - Perl modules: CGI, Encode, Fcntl, File::Find, File::Basename. - web server
gitweb/gitweb.perl +1 -1
@@ -7,7 +7,7 @@ # # This program is licensed under the GPLv2 -use 5.008; +use 5.008001; use strict; use warnings; # handle ACL in file access tests
perl/Git.pm +1 -1
@@ -7,7 +7,7 @@ =head1 NAME package Git; -use 5.008; +use 5.008001; use strict; use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : ();
perl/Git/I18N.pm +1 -1
@@ -1,5 +1,5 @@ package Git::I18N; -use 5.008; +use 5.008001; use strict; use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); BEGIN {
perl/Git/LoadCPAN.pm +1 -1
@@ -1,5 +1,5 @@ package Git::LoadCPAN; -use 5.008; +use 5.008001; use strict; use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : ();
perl/Git/LoadCPAN/Error.pm +1 -1
@@ -1,5 +1,5 @@ package Git::LoadCPAN::Error; -use 5.008; +use 5.008001; use strict; use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Git::LoadCPAN (
perl/Git/LoadCPAN/Mail/Address.pm +1 -1
@@ -1,5 +1,5 @@ package Git::LoadCPAN::Mail::Address; -use 5.008; +use 5.008001; use strict; use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); use Git::LoadCPAN (
perl/Git/Packet.pm +1 -1
@@ -1,5 +1,5 @@ package Git::Packet; -use 5.008; +use 5.008001; use strict; use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : (); BEGIN {
t/t0202/test.pl +1 -1
@@ -1,5 +1,5 @@ #!/usr/bin/perl -use 5.008; +use 5.008001; use lib (split(/:/, $ENV{GITPERLLIB})); use strict; use warnings;
t/t5562/invoke-with-content-length.pl +1 -1
@@ -1,4 +1,4 @@ -use 5.008; +use 5.008001; use strict; use warnings;
t/t9700/test.pl +1 -1
@@ -1,7 +1,7 @@ #!/usr/bin/perl use lib (split(/:/, $ENV{GITPERLLIB})); -use 5.008; +use 5.008001; use warnings; use strict;
t/test-terminal.perl +1 -1
@@ -1,5 +1,5 @@ #!/usr/bin/perl -use 5.008; +use 5.008001; use strict; use warnings; use IO::Pty;
Signature · 1 line
2.43.0.rc2
Re: [PATCH v3 1/2] perl: bump the required Perl version to 5.8.1 from 5.8.0
Quoted 11 lines · Todd Zullinger
The following commit will make use of a
Getopt::Longfeature which is only present in Perl >= 5.8.1. Document that as the minimum version we support.Many of our Perl scripts will continue to run with 5.8.0 but this change allows us to adjust them as needed without breaking any promises to our users.
The Perl requirement was last changed in
d48b284183(perl: bump the required Perl version to 5.8 from 5.6.[21], 2010-09-24). At that time, 5.8.0 was 8 years old. It is now over 21 years old.
Thanks, IMHO this is long overdue. You mentioned 5.10 elsewhere in the thread, and it came up recently in a discussion (it would allow the use of "//" for defined-or). So we could perhaps go a bit farther. But I am also fine with 5.8.1 for now, if that is all it takes for this fix (and I expect the chance that it causes a problem for anybody to be close to zero).
Quoted 5 lines
Signed-off-by Todd Zullinger <[email protected]>---
I debated changing all the 'use 5.008;' lines here, as most don't actually require a newer Perl, but the previous bump did the same.
Quoted 7 lines
I can see the merit in either direction.
Changing it allows future contributors to be confident in relying on 5.8.1 features.
Not changing it allows anyone stuck on 5.8.0 to continue using the perl scripts which don't actually require 5.8.1.
Yeah, I can see both sides of the argument. I think I'd err on the side of bumping (as you did here). That lets somebody who will be affected know immediately, rather than only finding out when we randomly depend on a feature later.
All of this discussion could likewise go in the commit message. :)
Quoted 9 lines
Tangentially, the Perl docs for 'use' function recommend against the 5.008001 form[1]:
Specifying VERSION as a numeric argument of the form 5.024001 should generally be avoided as older less readable syntax compared to v5.24.1. Before perl 5.8.0 released in 2002 the more verbose numeric form was the only supported syntax, which is why you might see it in older code.
Quoted 7 lines
use v5.24.1; # compile time version check
use 5.24.1; # ditto
use 5.024_001; # ditto; older syntax compatible with perl 5.6I'm not enough of a Perl coder to have a strong preference or desire to push for such a change, but I thought it was worth mentioning in case others wonder why we're using the 5.008001 form.
I doubt it matters too much either way. I suspect at the time we moved to v5.8 the nicer syntax was still pretty new (having only been introduced by v5.6, which we were moving off of) and that older versions of perl might not give as nice a message when they see it. But given that 5.6 is now 23 years old, we can probably assume nobody will use it (or at least they will be accustomed to whatever ugly message it produces).
But IMHO that should be done as a separate patch anyway.
-Peff
PATCH v3 2/2 send-email: avoid duplicate specification warnings
In reply to Todd ZullingerA 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 f471494303 (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.
--- git-send-email.perl | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
git-send-email.perl +6 -13
@@ -119,13 +119,16 @@ sub completion_helper { foreach my $key (keys %$original_opts) { unless (exists $not_for_completion{$key}) { - $key =~ s/!$//; + my $negatable = ($key =~ s/!$//); if ($key =~ /[:=][si]$/) { $key =~ s/[:=][si]$//; push (@send_email_opts, "--$_=") foreach (split (/\|/, $key)); } else { push (@send_email_opts, "--$_") foreach (split (/\|/, $key)); + if ($negatable) { + 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,
Signature · 1 line
2.43.0.rc2
Quoted 8 lines · Todd Zullinger
Quoted 2 lines
This sounds like something that is worth describing in the log message (and Release Notes).
I think the new commit messages describe the changes better. I didn't include anything in RelNotes as I was presuming we'd leave this for 2.44 rather than risk causing any problems this late in the 2.43 cycle. If you think the risk is low and/or the benefit is high, I can add it to the 2.43.0 RelNotes.
Please don't worry about the release notes, which I'll do only when the topic hits the 'master' branch. It was meant primarily as a note to myself. And I agree that this would be material for 2.44 and later.
Both patches, plus the stray single quote fix patch, looked good.
Thanks.
RFC PATCH v2 2/2 send-email: remove stray characters from usage
In reply to Todd ZullingerA few stray single quotes crept into the usage string in a2ce608244 (send-email docs: add format-patch options, 2021-10-25). Remove them.
---
This is not scrictly tied to the previous commit. It just stood out while I was reviewing the usage output.
git-send-email.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
git-send-email.perl +2 -2
@@ -28,8 +28,8 @@ sub usage { print <<EOT; -git send-email' [<options>] <file|directory> -git send-email' [<options>] <format-patch options> +git send-email [<options>] <file|directory> +git send-email [<options>] <format-patch options> git send-email --dump-aliases Composing:
Signature · 1 line
2.43.0.rc2
Re: [RFC PATCH v2 2/2] send-email: remove stray characters from usage
Quoted 7 lines · Todd Zullinger
A few stray single quotes crept into the usage string in
a2ce608244(send-email docs: add format-patch options, 2021-10-25). Remove them.Signed-off-by Todd Zullinger <[email protected]>---
This is not scrictly tied to the previous commit. It just stood out while I was reviewing the usage output.
Thanks. Let's split this out as a docfix patch and handle it separately.
Quoted 19 lines
git-send-email.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)git-send-email.perl +2
-2@@ -28,8 +28,8 @@ sub usage { print <<EOT; -git send-email' [<options>] <file|directory> -git send-email' [<options>] <format-patch options> +git send-email [<options>] <file|directory> +git send-email [<options>] <format-patch options> git send-email --dump-aliases Composing:
PATCH 1/1 send-email: remove stray characters from usage
A few stray single quotes crept into the usage string in a2ce608244 (send-email docs: add format-patch options, 2021-10-25). Remove them.
---
[I trimmed the Cc: list]
Quoted 2 lines · Junio C Hamano
Thanks. Let's split this out as a docfix patch and handle it separately.
Done. :)
git-send-email.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
git-send-email.perl +2 -2
@@ -28,8 +28,8 @@ sub usage { print <<EOT; -git send-email' [<options>] <file|directory> -git send-email' [<options>] <format-patch options> +git send-email [<options>] <file|directory> +git send-email [<options>] <format-patch options> git send-email --dump-aliases Composing:
Signature · 1 line
2.43.0.rc2