From cb005c1fdf814d3b65b5b43f5f4fa25aa1bcdf46 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 16 Apr 2014 10:08:18 +0200 Subject: [PATCH 1/2] send-email: recognize absolute path on Windows On Windows, absolute paths might start with a DOS drive prefix, which these two checks failed to recognize. Unfortunately, we cannot simply use the file_name_is_absolute helper in File::Spec::Functions, because Git for Windows has an MSYS-based Perl, where this helper doesn't grok DOS drive-prefixes. So let's manually check for these in that case, and fall back to the File::Spec-helper on other platforms (e.g Win32 with native Perl) Signed-off-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- git-send-email.perl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/git-send-email.perl b/git-send-email.perl index fdb0029b5..8f5f986e6 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -1113,6 +1113,18 @@ sub ssl_verify_params { } } +sub file_name_is_absolute { + my ($path) = @_; + + # msys does not grok DOS drive-prefixes + if ($^O eq 'msys') { + return ($path =~ m#^/# || $path =~ m#[a-zA-Z]\:#) + } + + require File::Spec::Functions; + return File::Spec::Functions::file_name_is_absolute($path); +} + # Returns 1 if the message was sent, and 0 otherwise. # In actuality, the whole program dies when there # is an error sending a message. @@ -1197,7 +1209,7 @@ sub send_message { if ($dry_run) { # We don't want to send the email. - } elsif ($smtp_server =~ m#^/#) { + } elsif (file_name_is_absolute($smtp_server)) { my $pid = open my $sm, '|-'; defined $pid or die $!; if (!$pid) { @@ -1271,7 +1283,7 @@ sub send_message { printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject); } else { print (($dry_run ? "Dry-" : "")."OK. Log says:\n"); - if ($smtp_server !~ m#^/#) { + if (!file_name_is_absolute($smtp_server)) { print "Server: $smtp_server\n"; print "MAIL FROM:<$raw_from>\n"; foreach my $entry (@recipients) { From f24ecf5998a6c913ea6111dc0650c91165149264 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 23 Apr 2014 09:37:38 -0700 Subject: [PATCH 2/2] send-email: windows drive prefix (e.g. C:) appears only at the beginning Tighten the regexp used in the "file_name_is_absolute" replacement used on msys to declare that only "[a-zA-Z]:" that appear at the very beginning is a path with a drive-prefix. Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-send-email.perl b/git-send-email.perl index 8f5f986e6..abd62b484 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -1118,7 +1118,7 @@ sub file_name_is_absolute { # msys does not grok DOS drive-prefixes if ($^O eq 'msys') { - return ($path =~ m#^/# || $path =~ m#[a-zA-Z]\:#) + return ($path =~ m#^/# || $path =~ m#^[a-zA-Z]\:#) } require File::Spec::Functions;