fast-import: Don't use a maybe-clobbered errno value
[gitweb.git] / git-send-email.perl
index 76baa8e431e082c1e36eb9c78125094de0b8a85e..e47994afc4d6a1dd92c84706dea1b77c1b832114 100755 (executable)
@@ -367,8 +367,10 @@ sub expand_aliases {
        } while (!defined $_);
 
        $initial_reply_to = $_;
-       $initial_reply_to =~ s/^\s+<?/</;
-       $initial_reply_to =~ s/>?\s+$/>/;
+}
+if (defined $initial_reply_to && $_ ne "") {
+       $initial_reply_to =~ s/^\s*<?/</;
+       $initial_reply_to =~ s/>?\s*$/>/;
 }
 
 if (!defined $smtp_server) {
@@ -398,7 +400,7 @@ sub expand_aliases {
        close(C);
 
        my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
-       system($editor, $compose_filename);
+       system('sh', '-c', '$0 $@', $editor, $compose_filename);
 
        open(C2,">",$compose_filename . ".final")
                or die "Failed to open $compose_filename.final : " . $!;
@@ -578,7 +580,7 @@ sub send_message
                $ccline = "\nCc: $cc";
        }
        my $sanitized_sender = sanitize_address($sender);
-       make_message_id();
+       make_message_id() unless defined($message_id);
 
        my $header = "From: $sanitized_sender
 To: $to${ccline}
@@ -716,6 +718,9 @@ sub send_message
                                        }
                                        push @xh, $_;
                                }
+                               elsif (/^Message-Id: (.*)/i) {
+                                       $message_id = $1;
+                               }
                                elsif (!/^Date:\s/ && /^[-A-Za-z]+:\s+\S/) {
                                        push @xh, $_;
                                }
@@ -803,6 +808,7 @@ sub send_message
                        $references = "$message_id";
                }
        }
+       $message_id = undef;
 }
 
 if ($compose) {