Skip to content

Commit

Permalink
send-email: recognize absolute path on Windows
Browse files Browse the repository at this point in the history
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 <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Erik Faye-Lund authored and Junio C Hamano committed Apr 16, 2014
1 parent 0bc85ab commit cb005c1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cb005c1

Please sign in to comment.