Skip to content

Commit 1046c11

Browse files
avargitster
authored andcommitted
git-send-email: unconditionally use Net::{SMTP,Domain}
The Net::SMTP and Net::Domain were both first released with perl v5.7.3[1], since my d48b284 ("perl: bump the required Perl version to 5.8 from 5.6.[21]", 2010-09-24) we've depended on 5.8, so there's no reason to conditionally require them anymore. This conditional loading was initially added in 8784062 ("send-email: only 'require' instead of 'use' Net::SMTP", 2006-06-01) for Net::SMTP and 134550f ("git-send-email.perl - try to give real name of the calling host to HELO/EHLO", 2010-03-14) for Net::Domain, both of which predate the hard dependency on 5.8. Since they're guaranteed to be installed now let's "use" them instead. The cost of loading them both is trivial given what git-send-email does (~15ms on my system), and it's better to not defer any potential loading errors until runtime. This patch is better viewed with -w, which shows that the only change in the last two hunks is removing the "if eval" wrapper block. 1. $ parallel 'corelist {}' ::: Net::{SMTP,Domain} Data for 2015-02-14 Net::SMTP was first released with perl v5.7.3 Data for 2015-02-14 Net::Domain was first released with perl v5.7.3 Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 29118b3 commit 1046c11

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

git-send-email.perl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
use Git;
3232
use Git::I18N;
3333
use Git::Mail::Address;
34+
use Net::Domain ();
35+
use Net::SMTP ();
3436

3537
Getopt::Long::Configure qw/ pass_through /;
3638

@@ -1143,28 +1145,24 @@ sub valid_fqdn {
11431145
sub maildomain_net {
11441146
my $maildomain;
11451147

1146-
if (eval { require Net::Domain; 1 }) {
1147-
my $domain = Net::Domain::domainname();
1148-
$maildomain = $domain if valid_fqdn($domain);
1149-
}
1148+
my $domain = Net::Domain::domainname();
1149+
$maildomain = $domain if valid_fqdn($domain);
11501150

11511151
return $maildomain;
11521152
}
11531153

11541154
sub maildomain_mta {
11551155
my $maildomain;
11561156

1157-
if (eval { require Net::SMTP; 1 }) {
1158-
for my $host (qw(mailhost localhost)) {
1159-
my $smtp = Net::SMTP->new($host);
1160-
if (defined $smtp) {
1161-
my $domain = $smtp->domain;
1162-
$smtp->quit;
1157+
for my $host (qw(mailhost localhost)) {
1158+
my $smtp = Net::SMTP->new($host);
1159+
if (defined $smtp) {
1160+
my $domain = $smtp->domain;
1161+
$smtp->quit;
11631162

1164-
$maildomain = $domain if valid_fqdn($domain);
1163+
$maildomain = $domain if valid_fqdn($domain);
11651164

1166-
last if $maildomain;
1167-
}
1165+
last if $maildomain;
11681166
}
11691167
}
11701168

0 commit comments

Comments
 (0)