Merge branch 'dk/send-email-avoid-net-smtp-ssl-when-able'
authorJunio C Hamano <gitster@pobox.com>
Fri, 2 Jun 2017 06:05:59 +0000 (15:05 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Jun 2017 06:05:59 +0000 (15:05 +0900)
A hotfix to a topic in 'master'.

* dk/send-email-avoid-net-smtp-ssl-when-able:
send-email: Net::SMTP::starttls was introduced in v2.34

1  2 
git-send-email.perl
diff --combined git-send-email.perl
index f0417f64e7513ad085c5227500569f23905f03e4,d326238c0a069c3c5d008497f72c9f2ffcc326c3..0168a476497ad6107ff567377bb7cb97e29e4892
@@@ -25,9 -25,8 +25,9 @@@ use Getopt::Long
  use Text::ParseWords;
  use Term::ANSIColor;
  use File::Temp qw/ tempdir tempfile /;
 -use File::Spec::Functions qw(catfile);
 +use File::Spec::Functions qw(catdir catfile);
  use Error qw(:try);
 +use Cwd qw(abs_path cwd);
  use Git;
  use Git::I18N;
  
@@@ -1355,7 -1354,7 +1355,7 @@@ EO
                }
  
                require Net::SMTP;
-               my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("1.28");
+               my $use_net_smtp_ssl = version->parse($Net::SMTP::VERSION) < version->parse("2.34");
                $smtp_domain ||= maildomain();
  
                if ($smtp_encryption eq 'ssl') {
@@@ -1754,23 -1753,6 +1754,23 @@@ sub unique_email_list 
  
  sub validate_patch {
        my $fn = shift;
 +
 +      my $validate_hook = catfile(catdir($repo->repo_path(), 'hooks'),
 +                                  'sendemail-validate');
 +      my $hook_error;
 +      if (-x $validate_hook) {
 +              my $target = abs_path($fn);
 +              # The hook needs a correct cwd and GIT_DIR.
 +              my $cwd_save = cwd();
 +              chdir($repo->wc_path() or $repo->repo_path())
 +                      or die("chdir: $!");
 +              local $ENV{"GIT_DIR"} = $repo->repo_path();
 +              $hook_error = "rejected by sendemail-validate hook"
 +                      if system($validate_hook, $target);
 +              chdir($cwd_save) or die("chdir: $!");
 +      }
 +      return $hook_error if $hook_error;
 +
        open(my $fh, '<', $fn)
                or die sprintf(__("unable to open %s: %s\n"), $fn, $!);
        while (my $line = <$fh>) {