@matheusbsbs / matheus-bagliano / commits / e6b0964af5
Fork 0

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 <junkio@cox.net>

Junio C Hamano committed Oct 7, 2006 at 03:09 UTC e6b0964af595bbc4dab2a63c17bc4c8064a28073
1 file changed +10 -3
git-send-email.perl
+10 -3
@@ -481,15 +481,21 @@ foreach my $t (@files) {
481 my $author_not_sender = undef;
482 @cc = @initial_cc;
483 @xh = ();
484 - my $found_mbox = 0;
484 + my $input_format = undef;
485 my $header_done = 0;
486 $message = "";
487 while(<F>) {
488 if (!$header_done) {
489 - $found_mbox = 1, next if (/^From /);
489 + if (/^From /) {
490 + $input_format = 'mbox';
491 + next;
492 + }
493 chomp;
494 + if (!defined $input_format && /^[-A-Za-z]+:\s/) {
495 + $input_format = 'mbox';
496 + }
497
492 - if ($found_mbox) {
498 + if (defined $input_format && $input_format eq 'mbox') {
499 if (/^Subject:\s+(.*)$/) {
500 $subject = $1;
501
@@ -514,6 +520,7 @@ foreach my $t (@files) {
520 # line 1 = cc
521 # line 2 = subject
522 # So let's support that, too.
523 + $input_format = 'lots';
524 if (@cc == 0) {
525 printf("(non-mbox) Adding cc: %s from line '%s'\n",
526 $_, $_) unless $quiet;