Skip to content

Commit cb005c1

Browse files
kusmagitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0bc85ab commit cb005c1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

git-send-email.perl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,18 @@ sub ssl_verify_params {
11131113
}
11141114
}
11151115

1116+
sub file_name_is_absolute {
1117+
my ($path) = @_;
1118+
1119+
# msys does not grok DOS drive-prefixes
1120+
if ($^O eq 'msys') {
1121+
return ($path =~ m#^/# || $path =~ m#[a-zA-Z]\:#)
1122+
}
1123+
1124+
require File::Spec::Functions;
1125+
return File::Spec::Functions::file_name_is_absolute($path);
1126+
}
1127+
11161128
# Returns 1 if the message was sent, and 0 otherwise.
11171129
# In actuality, the whole program dies when there
11181130
# is an error sending a message.
@@ -1197,7 +1209,7 @@ sub send_message {
11971209

11981210
if ($dry_run) {
11991211
# We don't want to send the email.
1200-
} elsif ($smtp_server =~ m#^/#) {
1212+
} elsif (file_name_is_absolute($smtp_server)) {
12011213
my $pid = open my $sm, '|-';
12021214
defined $pid or die $!;
12031215
if (!$pid) {
@@ -1271,7 +1283,7 @@ sub send_message {
12711283
printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
12721284
} else {
12731285
print (($dry_run ? "Dry-" : "")."OK. Log says:\n");
1274-
if ($smtp_server !~ m#^/#) {
1286+
if (!file_name_is_absolute($smtp_server)) {
12751287
print "Server: $smtp_server\n";
12761288
print "MAIL FROM:<$raw_from>\n";
12771289
foreach my $entry (@recipients) {

0 commit comments

Comments
 (0)