From ce91c2f6538fc4a905882f2a7a57d814d82b13e8 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 5 Oct 2006 16:36:49 -0700 Subject: git-send-email: do not drop custom headers the user prepared The command picked up only Subject, CC, and From headers in the incoming mbox text. Sending out patches prepared by git-format-patch with user's custom headers was impossible with that. Just keep the ones it does not need to look at and add them to the header of the message when sending it out. Signed-off-by: Junio C Hamano --- git-send-email.perl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/git-send-email.perl b/git-send-email.perl index 3f50abaeb..2fd5e8793 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -83,7 +83,7 @@ sub cleanup_compose_files(); 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 @@ -422,6 +422,9 @@ X-Mailer: git-send-email $gitversion $header .= "In-Reply-To: $reply_to\n"; $header .= "References: $references\n"; } + if (@xh) { + $header .= join("\n", @xh) . "\n"; + } if ($smtp_server =~ m#^/#) { my $pid = open my $sm, '|-'; @@ -472,6 +475,7 @@ foreach my $t (@files) { my $author_not_sender = undef; @cc = @initial_cc; + @xh = (); my $found_mbox = 0; my $header_done = 0; $message = ""; @@ -495,6 +499,9 @@ foreach my $t (@files) { $2, $_) unless $quiet; push @cc, $2; } + elsif (/^[-A-Za-z]+:\s+\S/) { + push @xh, $_; + } } else { # In the traditional -- cgit v1.2.1 From 7a2a0d214169a5d6f22fc62c4ae6a7ca5b27fb3e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 5 Oct 2006 23:40:15 -0700 Subject: git-send-email: real name with period need to be dq-quoted on From: line An author name like 'A. U. Thor " is not a valid RFC 2822 address; when placing it on From: line, we would need to quote it, like this: Signed-off-by: "Junio C. Hamano" --- git-send-email.perl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-send-email.perl b/git-send-email.perl index 2fd5e8793..21b3686b2 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -409,6 +409,11 @@ sub send_message $gitversion = Git::version(); } + my ($author_name) = ($from =~ /^(.*?)\s+ Date: Sat, 7 Oct 2006 03:09:05 -0700 Subject: Make git-send-email detect mbox-style patches more readily Earlier we insisted that mbox file to begin with "From ". That is fine as long as you feed format-patch output, but if you handcraft the input file, this is unnecessary burden. We should detect lines that look like e-mail headers and say that is also a mbox file. The other input file format is traditional "send lots of email", whose first line would never look like e-mail headers, so this is a safe change. The original patch was done by Matthew Wilcox, which checked explicitly for headers the script pays attention to. Signed-off-by: Junio C Hamano --- git-send-email.perl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/git-send-email.perl b/git-send-email.perl index 21b3686b2..eb9127089 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -481,15 +481,21 @@ foreach my $t (@files) { my $author_not_sender = undef; @cc = @initial_cc; @xh = (); - my $found_mbox = 0; + my $input_format = undef; my $header_done = 0; $message = ""; while() { 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; @@ -514,6 +520,7 @@ foreach my $t (@files) { # 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; -- cgit v1.2.1