{"thread":{"id":"5842","subject":"Make git-send-email detect mbox-style patches more readily","startedAt":"2006-10-06T20:24:14Z","lastAt":"2006-10-07T10:09:05Z","messageCount":2,"participants":["Matthew Wilcox","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"28327","messageId":"20061006202414.GR2563@parisc-linux.org","threadId":"5842","inReplyTo":null,"subject":"Make git-send-email detect mbox-style patches more readily","fromName":"Matthew Wilcox","fromEmail":"matthew@wil.cx","sentAt":"2006-10-06T20:24:14Z","receivedAt":"2006-10-06T20:24:14Z","isPatch":false,"sender":{"key":"matthew@wil.cx","avatar":null},"body":"\nEarlier today, I embarrassed myself by trying to construct a patch that\ngit-send-email would send, and I missed out the putting\n\n>From garbage\n\nline on the front, which led it to send the patches with a\nSubject: From: Matthew Wilcox <matthew@wil.cx>\nline.  Bad.\n\nThis patch makes git-send-email detect an mbox-style file more readily,\nand correctly handles the patches I constructed.\n\n--- git-core-willy/git-send-email.perl\t2006-07-24 23:45:08.000000000 -0400\n+++ git-core-1.4.1.1/git-send-email.perl\t2006-10-06 16:02:37.000000000 -0400\n@@ -451,6 +451,7 @@\n \t\tif (!$header_done) {\n \t\t\t$found_mbox = 1, next if (/^From /);\n \t\t\tchomp;\n+\t\t\t$found_mbox = 1 if (/^(From|Date|Cc|Subject):/);\n \n \t\t\tif ($found_mbox) {\n \t\t\t\tif (/^Subject:\\s+(.*)$/) {\n"},{"id":"28353","messageId":"7vy7rssaim.fsf@assigned-by-dhcp.cox.net","threadId":"5842","inReplyTo":"20061006202414.GR2563@parisc-linux.org","subject":"Re: Make git-send-email detect mbox-style patches more readily","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-07T10:09:05Z","receivedAt":"2006-10-07T10:09:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthew Wilcox <matthew@wil.cx> writes:\n\n> Earlier today, I embarrassed myself by trying to construct a patch that\n> git-send-email would send, and I missed out the putting\n>\n> From garbage\n>\n> line on the front, which led it to send the patches with a\n> Subject: From: Matthew Wilcox <matthew@wil.cx>\n> line.  Bad.\n\nI do not mind this patch per-se, but what do you prepare your\npatch with?  Straight \"diff -pu\" between two directories?\nquilt?\n\nSince the command deals with two formats (mbox and \"send lots of\nemail\"), I am wondering if it would be bettern to loosen the\nregexp you used further to catch something like this:\n\n\t/^[-A-Za-z]+:\\s/\n\nThe reason why I suspect it would be better to do this loosening\nis because I've queued the patch I did yesterday for Len to\nallow the prepared patch file to contain custom header fields,\nnot just the set of headers hardcoded in the send-email script.\n\nThe second line in the \"send lots of email\" format is e-mail\nsubject, and it is conceivable that would match the above\npattern, so this may not be workable, though.\n\nMaybe something like this?\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 3f50aba..ed8652c 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -472,15 +472,21 @@ foreach my $t (@files) {\n \n \tmy $author_not_sender = undef;\n \t@cc = @initial_cc;\n-\tmy $found_mbox = 0;\n+\tmy $input_format = undef;\n \tmy $header_done = 0;\n \t$message = \"\";\n \twhile(<F>) {\n \t\tif (!$header_done) {\n-\t\t\t$found_mbox = 1, next if (/^From /);\n+\t\t\tif (/^From /) {\n+\t\t\t\t$input_format = 'mbox';\n+\t\t\t\tnext;\n+\t\t\t}\n \t\t\tchomp;\n+\t\t\tif (!defined $input_format && /^[-A-Za-z]+:\\s/) {\n+\t\t\t\t$input_format = 'mbox';\n+\t\t\t}\n \n-\t\t\tif ($found_mbox) {\n+\t\t\tif (defined $input_format && $input_format eq 'mbox') {\n \t\t\t\tif (/^Subject:\\s+(.*)$/) {\n \t\t\t\t\t$subject = $1;\n \n@@ -502,6 +508,7 @@ foreach my $t (@files) {\n \t\t\t\t# line 1 = cc\n \t\t\t\t# line 2 = subject\n \t\t\t\t# So let's support that, too.\n+\t\t\t\t$input_format = 'lots';\n \t\t\t\tif (@cc == 0) {\n \t\t\t\t\tprintf(\"(non-mbox) Adding cc: %s from line '%s'\\n\",\n \t\t\t\t\t\t$_, $_) unless $quiet;\n"}]}