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 d48b284183 ("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 87840620fd ("send-email: only 'require' instead of 'use' Net::SMTP", 2006-06-01) for Net::SMTP and 134550fe21 ("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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 3, 2018 at 15:38 UTC 1046c118d8116496dc4737b9229bdf7339202ba6
1 file changed +11 -13
git-send-email.perl
+11 -13
@@ -31,6 +31,8 @@ use Cwd qw(abs_path cwd);
31 use Git;
32 use Git::I18N;
33 use Git::Mail::Address;
34 +use Net::Domain ();
35 +use Net::SMTP ();
36
37 Getopt::Long::Configure qw/ pass_through /;
38
@@ -1143,10 +1145,8 @@ sub valid_fqdn {
1145 sub maildomain_net {
1146 my $maildomain;
1147
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);
1150
1151 return $maildomain;
1152 }
@@ -1154,17 +1154,15 @@ sub maildomain_net {
1154 sub maildomain_mta {
1155 my $maildomain;
1156
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;
1162
1164 - $maildomain = $domain if valid_fqdn($domain);
1163 + $maildomain = $domain if valid_fqdn($domain);
1164
1166 - last if $maildomain;
1167 - }
1165 + last if $maildomain;
1166 }
1167 }
1168