Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl62
1 files changed, 45 insertions, 17 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 0a6dcc1f88..5262d88ee3 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -60,6 +60,7 @@ git send-email --dump-aliases
Sending:
--envelope-sender <str> * Email envelope sender.
+ --sendmail-cmd <str> * Command to run to send email.
--smtp-server <str:int> * Outgoing SMTP server to use. The port
is optional. Default 'localhost'.
--smtp-server-option <str> * Outgoing SMTP server option to use.
@@ -243,6 +244,7 @@ my ($confirm);
my (@suppress_cc);
my ($auto_8bit_encoding);
my ($compose_encoding);
+my ($sendmail_cmd);
# Variables with corresponding config settings & hardcoded defaults
my ($debug_net_smtp) = 0; # Net::SMTP, see send_message()
my $thread = 1;
@@ -291,6 +293,7 @@ my %config_settings = (
"assume8bitencoding" => \$auto_8bit_encoding,
"composeencoding" => \$compose_encoding,
"transferencoding" => \$target_xfer_encoding,
+ "sendmailcmd" => \$sendmail_cmd,
);
my %config_path_settings = (
@@ -460,6 +463,7 @@ $rc = GetOptions(
"no-bcc" => \$no_bcc,
"chain-reply-to!" => \$chain_reply_to,
"no-chain-reply-to" => sub {$chain_reply_to = 0},
+ "sendmail-cmd=s" => \$sendmail_cmd,
"smtp-server=s" => \$smtp_server,
"smtp-server-option=s" => \@smtp_server_options,
"smtp-server-port=s" => \$smtp_server_port,
@@ -1061,16 +1065,19 @@ if (defined $reply_to) {
$reply_to = sanitize_address($reply_to);
}
-if (!defined $smtp_server) {
+if (!defined $sendmail_cmd && !defined $smtp_server) {
my @sendmail_paths = qw( /usr/sbin/sendmail /usr/lib/sendmail );
push @sendmail_paths, map {"$_/sendmail"} split /:/, $ENV{PATH};
foreach (@sendmail_paths) {
if (-x $_) {
- $smtp_server = $_;
+ $sendmail_cmd = $_;
last;
}
}
- $smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*
+
+ if (!defined $sendmail_cmd) {
+ $smtp_server = 'localhost'; # could be 127.0.0.1, too... *shrug*
+ }
}
if ($compose && $compose > 0) {
@@ -1554,11 +1561,17 @@ EOF
if ($dry_run) {
# We don't want to send the email.
- } elsif (file_name_is_absolute($smtp_server)) {
+ } elsif (defined $sendmail_cmd || file_name_is_absolute($smtp_server)) {
my $pid = open my $sm, '|-';
defined $pid or die $!;
if (!$pid) {
- exec($smtp_server, @sendmail_parameters) or die $!;
+ if (defined $sendmail_cmd) {
+ exec ("sh", "-c", "$sendmail_cmd \"\$@\"", "-", @sendmail_parameters)
+ or die $!;
+ } else {
+ exec ($smtp_server, @sendmail_parameters)
+ or die $!;
+ }
}
print $sm "$header\n$message";
close $sm or die $!;
@@ -1654,14 +1667,21 @@ EOF
printf($dry_run ? __("Dry-Sent %s\n") : __("Sent %s\n"), $subject);
} else {
print($dry_run ? __("Dry-OK. Log says:\n") : __("OK. Log says:\n"));
- if (!file_name_is_absolute($smtp_server)) {
+ if (!defined $sendmail_cmd && !file_name_is_absolute($smtp_server)) {
print "Server: $smtp_server\n";
print "MAIL FROM:<$raw_from>\n";
foreach my $entry (@recipients) {
print "RCPT TO:<$entry>\n";
}
} else {
- print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
+ my $sm;
+ if (defined $sendmail_cmd) {
+ $sm = $sendmail_cmd;
+ } else {
+ $sm = $smtp_server;
+ }
+
+ print "Sendmail: $sm ".join(' ',@sendmail_parameters)."\n";
}
print $header, "\n";
if ($smtp) {
@@ -1677,7 +1697,6 @@ EOF
$in_reply_to = $initial_in_reply_to;
$references = $initial_in_reply_to || '';
-$subject = $initial_subject;
$message_num = 0;
# Prepares the email, prompts the user, sends it out
@@ -1700,6 +1719,7 @@ sub process_file {
@xh = ();
my $input_format = undef;
my @header = ();
+ $subject = $initial_subject;
$message = "";
$message_num++;
# First unfold multiline header fields
@@ -1906,15 +1926,23 @@ sub process_file {
}
# set up for the next message
- if ($thread && $message_was_sent &&
- ($chain_reply_to || !defined $in_reply_to || length($in_reply_to) == 0 ||
- $message_num == 1)) {
- $in_reply_to = $message_id;
- if (length $references > 0) {
- $references .= "\n $message_id";
- } else {
- $references = "$message_id";
+ if ($thread) {
+ if ($message_was_sent &&
+ ($chain_reply_to || !defined $in_reply_to || length($in_reply_to) == 0 ||
+ $message_num == 1)) {
+ $in_reply_to = $message_id;
+ if (length $references > 0) {
+ $references .= "\n $message_id";
+ } else {
+ $references = "$message_id";
+ }
}
+ } elsif (!defined $initial_in_reply_to) {
+ # --thread and --in-reply-to manage the "In-Reply-To" header and by
+ # extension the "References" header. If these commands are not used, reset
+ # the header values to their defaults.
+ $in_reply_to = undef;
+ $references = '';
}
$message_id = undef;
$num_sent++;
@@ -2020,7 +2048,7 @@ sub validate_patch {
require Cwd;
my $target = Cwd::abs_path($fn);
# The hook needs a correct cwd and GIT_DIR.
- my $cwd_save = Cwd::cwd();
+ my $cwd_save = Cwd::getcwd();
chdir($repo->wc_path() or $repo->repo_path())
or die("chdir: $!");
local $ENV{"GIT_DIR"} = $repo->repo_path();