Skip to content

Commit

Permalink
Merge branch 'jc/send-email'
Browse files Browse the repository at this point in the history
* jc/send-email:
  Make git-send-email detect mbox-style patches more readily
  git-send-email: real name with period need to be dq-quoted on From: line
  git-send-email: do not drop custom headers the user prepared
  • Loading branch information
Junio C Hamano committed Oct 19, 2006
2 parents 9100c9d + e6b0964 commit 2dcd3ce
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ sub format_2822_time {
my $compose_filename = ".msg.$$";

# Variables we fill in automatically, or via prompting:
my (@to,@cc,@initial_cc,@bcclist,
my (@to,@cc,@initial_cc,@bcclist,@xh,
$initial_reply_to,$initial_subject,@files,$from,$compose,$time);

# Behavior modification variables
Expand Down Expand Up @@ -411,6 +411,11 @@ sub send_message
$gitversion = Git::version();
}

my ($author_name) = ($from =~ /^(.*?)\s+</);
if ($author_name =~ /\./ && $author_name !~ /^".*"$/) {
my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
$from = "\"$name\"$addr";
}
my $header = "From: $from
To: $to
Cc: $cc
Expand All @@ -424,6 +429,9 @@ sub send_message
$header .= "In-Reply-To: $reply_to\n";
$header .= "References: $references\n";
}
if (@xh) {
$header .= join("\n", @xh) . "\n";
}

if ($dry_run) {
# We don't want to send the email.
Expand Down Expand Up @@ -476,15 +484,22 @@ sub send_message

my $author_not_sender = undef;
@cc = @initial_cc;
my $found_mbox = 0;
@xh = ();
my $input_format = undef;
my $header_done = 0;
$message = "";
while(<F>) {
if (!$header_done) {
$found_mbox = 1, next if (/^From /);
if (/^From /) {
$input_format = 'mbox';
next;
}
chomp;
if (!defined $input_format && /^[-A-Za-z]+:\s/) {
$input_format = 'mbox';
}

if ($found_mbox) {
if (defined $input_format && $input_format eq 'mbox') {
if (/^Subject:\s+(.*)$/) {
$subject = $1;

Expand All @@ -499,13 +514,17 @@ sub send_message
$2, $_) unless $quiet;
push @cc, $2;
}
elsif (/^[-A-Za-z]+:\s+\S/) {
push @xh, $_;
}

} else {
# In the traditional
# "send lots of email" format,
# line 1 = cc
# line 2 = subject
# So let's support that, too.
$input_format = 'lots';
if (@cc == 0) {
printf("(non-mbox) Adding cc: %s from line '%s'\n",
$_, $_) unless $quiet;
Expand Down

0 comments on commit 2dcd3ce

Please sign in to comment.