git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Make git-send-email detect mbox-style patches more readily
@ 2006-10-06 20:24 Matthew Wilcox
  2006-10-07 10:09 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Wilcox @ 2006-10-06 20:24 UTC (permalink / raw)
  To: git


Earlier today, I embarrassed myself by trying to construct a patch that
git-send-email would send, and I missed out the putting

>From garbage

line on the front, which led it to send the patches with a
Subject: From: Matthew Wilcox <matthew@wil.cx>
line.  Bad.

This patch makes git-send-email detect an mbox-style file more readily,
and correctly handles the patches I constructed.

--- git-core-willy/git-send-email.perl	2006-07-24 23:45:08.000000000 -0400
+++ git-core-1.4.1.1/git-send-email.perl	2006-10-06 16:02:37.000000000 -0400
@@ -451,6 +451,7 @@
 		if (!$header_done) {
 			$found_mbox = 1, next if (/^From /);
 			chomp;
+			$found_mbox = 1 if (/^(From|Date|Cc|Subject):/);
 
 			if ($found_mbox) {
 				if (/^Subject:\s+(.*)$/) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Make git-send-email detect mbox-style patches more readily
  2006-10-06 20:24 Make git-send-email detect mbox-style patches more readily Matthew Wilcox
@ 2006-10-07 10:09 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2006-10-07 10:09 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: git

Matthew Wilcox <matthew@wil.cx> writes:

> Earlier today, I embarrassed myself by trying to construct a patch that
> git-send-email would send, and I missed out the putting
>
> From garbage
>
> line on the front, which led it to send the patches with a
> Subject: From: Matthew Wilcox <matthew@wil.cx>
> line.  Bad.

I do not mind this patch per-se, but what do you prepare your
patch with?  Straight "diff -pu" between two directories?
quilt?

Since the command deals with two formats (mbox and "send lots of
email"), I am wondering if it would be bettern to loosen the
regexp you used further to catch something like this:

	/^[-A-Za-z]+:\s/

The reason why I suspect it would be better to do this loosening
is because I've queued the patch I did yesterday for Len to
allow the prepared patch file to contain custom header fields,
not just the set of headers hardcoded in the send-email script.

The second line in the "send lots of email" format is e-mail
subject, and it is conceivable that would match the above
pattern, so this may not be workable, though.

Maybe something like this?

diff --git a/git-send-email.perl b/git-send-email.perl
index 3f50aba..ed8652c 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -472,15 +472,21 @@ foreach my $t (@files) {
 
 	my $author_not_sender = undef;
 	@cc = @initial_cc;
-	my $found_mbox = 0;
+	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;
 
@@ -502,6 +508,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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-10-07 10:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-06 20:24 Make git-send-email detect mbox-style patches more readily Matthew Wilcox
2006-10-07 10:09 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).