Skip to contentSkip to conversation

send-email: Add --delay for separating emails

RFC PATCH In review Michael Witten 8 participants 30 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/6 send-email: Add --delay for separating emails

When sending a patch series, the emails often arrive at the final destination out of order; though these emails should be chained via the In-Reply-To headers, some mail-viewing systems display by order of arrival instead.

The --delay option provides a means for specifying that there should be a certain number of seconds of delay between sending emails, so that the arrival order can be controlled better.

---
 Documentation/git-send-email.txt |    5 +++++
 git-send-email.perl              |   17 +++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)
Documentation/git-send-email.txt +5 -0
index 10dfd66..4b656ca 100644
@@ -97,6 +97,11 @@ The --to option must be repeated for each user you want on the to list.
 Sending
 ~~~~~~~
 
+--delay::
+	Specify the minimum number of seconds of delay that should occur
+	between sending emails. This number should be an integer >= zero.
+	Default is the value of the 'sendemail.delay' configuration variable.
+
 --envelope-sender::
 	Specify the envelope sender used to send the emails.
 	This is useful if your default address is not the address that is
git-send-email.perl +13 -4
index 172b53c..273c8c7 100755
@@ -56,6 +56,7 @@ git send-email [options] <file | directory | rev-list options >
     --compose                      * Open an editor for introduction.
 
   Sending:
+    --delay                 <int>  * Delay (seconds) between sending emails.
     --envelope-sender       <str>  * Email envelope sender.
     --smtp-server       <str:int>  * Outgoing SMTP server to use. The port
                                      is optional. Default 'localhost'.
@@ -180,7 +181,7 @@ sub do_edit {
 }
 
 # Variables with corresponding config settings
-my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
+my ($delay, $thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
 my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
 my ($validate, $confirm);
@@ -196,6 +197,7 @@ my %config_bool_settings = (
 );
 
 my %config_settings = (
+    "delay" => \$delay,
     "smtpserver" => \$smtp_server,
     "smtpserverport" => \$smtp_server_port,
     "smtpuser" => \$smtp_authuser,
@@ -247,6 +249,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "cc=s" => \@initial_cc,
 		    "bcc=s" => \@bcclist,
 		    "chain-reply-to!" => \$chain_reply_to,
+		    "delay=i" => \$delay,
 		    "smtp-server=s" => \$smtp_server,
 		    "smtp-server-port=s" => \$smtp_server_port,
 		    "smtp-user=s" => \$smtp_authuser,
@@ -973,8 +976,9 @@ $references = $initial_reply_to || '';
 $subject = $initial_subject;
 $message_num = 0;
 
-foreach my $t (@files) {
-	open(F,"<",$t) or die "can't open file $t";
+for (my $index = 0; $index < @files; $index++) {
+	my $file = $files[$index];
+	open(F,"<",$file) or die "can't open file $file";
 
 	my $author = undef;
 	my $author_encoding;
@@ -1083,7 +1087,7 @@ foreach my $t (@files) {
 	close F;
 
 	if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
-		open(F, "$cc_cmd $t |")
+		open(F, "$cc_cmd $file |")
 			or die "(cc-cmd) Could not execute '$cc_cmd'";
 		while(<F>) {
 			my $c = $_;
@@ -1128,6 +1132,11 @@ foreach my $t (@files) {
 
 	send_message();
 
+	if ($delay && $index < $#files) {
+		my $this_long = $delay;
+		while (($this_long -= sleep $this_long) > 0) {}
+	}
+
 	# set up for the next message
 	if ($chain_reply_to || !defined $reply_to || length($reply_to) == 0) {
 		$reply_to = $message_id;
Signature · 1 line
1.6.2.2.448.g61445.dirty
#1 lore raw

RFC PATCH 2/6 send-email: --smtp-server-port should take an integer

---
 git-send-email.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
git-send-email.perl +1 -1
index 273c8c7..63d6063 100755
@@ -251,7 +251,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "chain-reply-to!" => \$chain_reply_to,
 		    "delay=i" => \$delay,
 		    "smtp-server=s" => \$smtp_server,
-		    "smtp-server-port=s" => \$smtp_server_port,
+		    "smtp-server-port=i" => \$smtp_server_port,
 		    "smtp-user=s" => \$smtp_authuser,
 		    "smtp-pass:s" => \$smtp_authpass,
 		    "smtp-ssl" => sub { $smtp_encryption = 'ssl' },
Signature · 1 line
1.6.2.2.448.g61445.dirty
#2 lore raw

RFC PATCH 3/6 send-email: Handle "GIT:" rather than "GIT: " during --compose

This should make things a little more robust in terms of user input; before, even the program got it wrong by outputting a line with only "GIT:", which was left in place as a header, because there would be no following space character.

Also, I cleaned up get_patch_subject().

---
 git-send-email.perl |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
git-send-email.perl +12 -11
index 63d6063..098c620 100755
@@ -505,15 +505,16 @@ if (@files) {
 }
 
 sub get_patch_subject($) {
-	my $fn = shift;
-	open (my $fh, '<', $fn);
-	while (my $line = <$fh>) {
-		next unless ($line =~ /^Subject: (.*)$/);
-		close $fh;
-		return "GIT: $1\n";
+
+	my $patch = shift;
+	open (my $fh, '<', $patch);
+
+	while (<$fh>) {
+		next unless (/^Subject: (.*)$/);
+		return $1;
 	}
-	close $fh;
-	die "No subject line in $fn ?";
+
+	die "'Subject:' line expected in '$patch'";
 }
 
 if ($compose) {
@@ -532,7 +533,7 @@ if ($compose) {
 
 	print C <<EOT;
 From $tpl_sender # This line is ignored.
-GIT: Lines beginning in "GIT: " will be removed.
+GIT: Lines beginning in "GIT:" will be removed.
 GIT: Consider including an overall diffstat or table of contents
 GIT: for the patch you are writing.
 GIT:
@@ -543,7 +544,7 @@ In-Reply-To: $tpl_reply_to
 
 EOT
 	for my $f (@files) {
-		print C get_patch_subject($f);
+		print C "GIT: ", get_patch_subject($f), "\n";
 	}
 	close(C);
 
@@ -565,7 +566,7 @@ EOT
 	my $in_body = 0;
 	my $summary_empty = 1;
 	while(<C>) {
-		next if m/^GIT: /;
+		next if m/^GIT:/;
 		if ($in_body) {
 			$summary_empty = 0 unless (/^\n$/);
 		} elsif (/^\n$/) {
Signature · 1 line
1.6.2.2.448.g61445.dirty
#3 lore raw

RFC PATCH 4/6 send-email: --compose takes optional argument to existing file

Now, a user may specify an existing (in-progress) file to use as the introductory/summary email.

The file is opened for any additional editing as usual.

---
 Documentation/git-send-email.txt |    7 ++-
 git-send-email.perl              |  112 ++++++++++++++++++++++----------------
 2 files changed, 71 insertions(+), 48 deletions(-)
Documentation/git-send-email.txt +5 -2
index 4b656ca..bc9ff13 100644
@@ -57,8 +57,11 @@ The --cc option must be repeated for each user you want on the cc list.
 	or one for all of them at once.
 
 --compose::
-	Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an
-	introductory message for the patch series.
+	Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR, or vi to edit an
+	introductory message for the patch series. An existing file may be
+	specified as the basis for the introductory email; it will be opened
+	for editing directly. Otherwise, a new temporary file is created with
+	some default contents.
 +
 When '--compose' is used, git send-email will use the From, Subject, and
 In-Reply-To headers specified in the message. If the body of the message
git-send-email.perl +66 -46

192 lines not on this page · raw message

Signature · 1 line
1.6.2.2.448.g61445.dirty
#4 lore raw

RFC PATCH 5/6 send-email: Cleanup the usage text a bit

All lines should be < 80 characters.

---
 git-send-email.perl |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
git-send-email.perl +11 -5
index 481bf36..c3e3598 100755
@@ -42,6 +42,9 @@ package main;
 
 
 sub usage {
+
+	# All printed lines should be less than 80 characters.
+
 	print <<EOT;
 git send-email [options] <file | directory | rev-list options >
 
@@ -52,7 +55,8 @@ git send-email [options] <file | directory | rev-list options >
     --bcc                   <str>  * Email Bcc:
     --subject               <str>  * Email "Subject:"
     --in-reply-to           <str>  * Email "In-Reply-To:"
-    --annotate                     * Review each patch that will be sent in an editor.
+    --annotate                     * Review each patch that will be sent in
+                                     an editor.
     --compose           opt <str>  * Open an editor for introduction.
 
   Sending:
@@ -69,8 +73,10 @@ git send-email [options] <file | directory | rev-list options >
   Automating:
     --identity              <str>  * Use the sendemail.<id> options.
     --cc-cmd                <str>  * Email Cc: via `<str> \$patch_path`
-    --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, all.
-    --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.
+    --suppress-cc           <str>  * author, self, sob, cc, cccmd, body,
+                                     bodycc, all.
+    --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses.
+                                     Default on.
     --[no-]suppress-from           * Send to self. Default off.
     --[no-]chain-reply-to          * Chain In-Reply-To: fields. Default on.
     --[no-]thread                  * Use In-Reply-To: field. Default on.
@@ -81,8 +87,8 @@ git send-email [options] <file | directory | rev-list options >
     --quiet                        * Output one line of info per email.
     --dry-run                      * Don't actually send the emails.
     --[no-]validate                * Perform patch sanity checks. Default on.
-    --[no-]format-patch            * understand any non optional arguments as
-                                     `git format-patch` ones.
+    --[no-]format-patch            * Understand any non-optional arguments as
+                                     `git format-patch' arguments.
 
 EOT
 	exit(1);
Signature · 1 line
1.6.2.2.448.g61445.dirty
#5 lore raw

RFC PATCH 6/6 send-email: Remove horrible mix of tabs and spaces

For the most part, I ran a search for all the lines that match:

    ^[\t]*[ ]+

and then I manually replaced the offending text with an appropriate number of tabs.

While scanning through the file, I also tried to format some of the code so as to obviate future mixing; I also fixed one horrendously egregious section of code, where someone was trying to be unnecessarily compact.

Currently, no lines match the following:

    [\t]+[ ]+
    [ ]+[\t]+

So, it should be reasonably clean.

The whole file is still horrendous.

---
 git-send-email.perl |  282 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 170 insertions(+), 112 deletions(-)
git-send-email.perl +170 -112
index c3e3598..a4c24f3 100755
@@ -16,6 +16,14 @@
 #    and second line is the subject of the message.
 #
 
+## WARNING! ACHTUNG! ATTENTION! ADVERTENCIA!
+##   Currently, this file uses tabs (like the rest of git source) to
+##   delineate code structure. Do NOT under any circumstances mix tabs
+##   and spaces across lines that share a relationship in terms of layout.
+##   In fact, it would currently be best to use only tabs, so please set
+##   your editor(s) accordingly. This code is already trashy enough. Please
+##   don't make it worse.
+
 use strict;
 use warnings;
 use Term::ReadLine;
@@ -118,19 +126,20 @@ sub format_2822_time {
 		die ("local time offset greater than or equal to 24 hours\n");
 	}
 
-	return sprintf("%s, %2d %s %d %02d:%02d:%02d %s%02d%02d",
-		       qw(Sun Mon Tue Wed Thu Fri Sat)[$localtm[6]],
-		       $localtm[3],
-		       qw(Jan Feb Mar Apr May Jun
-			  Jul Aug Sep Oct Nov Dec)[$localtm[4]],
-		       $localtm[5]+1900,
-		       $localtm[2],
-		       $localtm[1],
-		       $localtm[0],
-		       ($offset >= 0) ? '+' : '-',
-		       abs($offhour),
-		       $offmin,
-		       );
+	return sprintf(
+		"%s, %2d %s %d %02d:%02d:%02d %s%02d%02d",
+		qw(Sun Mon Tue Wed Thu Fri Sat)[$localtm[6]],
+		$localtm[3],
+		qw(Jan Feb Mar Apr May Jun
+		Jul Aug Sep Oct Nov Dec)[$localtm[4]],
+		$localtm[5]+1900,
+		$localtm[2],
+		$localtm[1],
+		$localtm[0],
+		($offset >= 0) ? '+' : '-',
+		abs($offhour),
+		$offmin,
+	);
 }
 
 my $have_email_valid = eval { require Email::Valid; 1 };
@@ -194,30 +203,30 @@ my ($validate, $confirm);
 my (@suppress_cc);
 
 my %config_bool_settings = (
-    "thread" => [\$thread, 1],
-    "chainreplyto" => [\$chain_reply_to, 1],
-    "suppressfrom" => [\$suppress_from, undef],
-    "signedoffbycc" => [\$signed_off_by_cc, undef],
-    "signedoffcc" => [\$signed_off_by_cc, undef],      # Deprecated
-    "validate" => [\$validate, 1],
+	"thread" => [\$thread, 1],
+	"chainreplyto" => [\$chain_reply_to, 1],
+	"suppressfrom" => [\$suppress_from, undef],
+	"signedoffbycc" => [\$signed_off_by_cc, undef],
+	"signedoffcc" => [\$signed_off_by_cc, undef],      # Deprecated
+	"validate" => [\$validate, 1],
 );
 
 my %config_settings = (
-    "delay" => \$delay,
-    "smtpserver" => \$smtp_server,
-    "smtpserverport" => \$smtp_server_port,
-    "smtpuser" => \$smtp_authuser,
-    "smtppass" => \$smtp_authpass,
-    "to" => \@to,
-    "cc" => \@initial_cc,
-    "cccmd" => \$cc_cmd,
-    "aliasfiletype" => \$aliasfiletype,
-    "bcc" => \@bcclist,
-    "aliasesfile" => \@alias_files,
-    "suppresscc" => \@suppress_cc,
-    "envelopesender" => \$envelope_sender,
-    "multiedit" => \$multiedit,
-    "confirm"   => \$confirm,
+	"delay" => \$delay,
+	"smtpserver" => \$smtp_server,
+	"smtpserverport" => \$smtp_server_port,
+	"smtpuser" => \$smtp_authuser,
+	"smtppass" => \$smtp_authpass,
+	"to" => \@to,
+	"cc" => \@initial_cc,
+	"cccmd" => \$cc_cmd,
+	"aliasfiletype" => \$aliasfiletype,
+	"bcc" => \@bcclist,
+	"aliasesfile" => \@alias_files,
+	"suppresscc" => \@suppress_cc,
+	"envelopesender" => \$envelope_sender,
+	"multiedit" => \$multiedit,
+	"confirm"   => \$confirm,
 );
 
 # Handle Uncouth Termination
@@ -247,38 +256,39 @@ $SIG{INT}  = \&signal_handler;
 # Begin by accumulating all the variables (defined above), that we will end up
 # needing, first, from the command line:
 
-my $rc = GetOptions("sender|from=s" => \$sender,
-                    "in-reply-to=s" => \$initial_reply_to,
-		    "subject=s" => \$initial_subject,
-		    "to=s" => \@to,
-		    "cc=s" => \@initial_cc,
-		    "bcc=s" => \@bcclist,
-		    "chain-reply-to!" => \$chain_reply_to,
-		    "delay=i" => \$delay,
-		    "smtp-server=s" => \$smtp_server,
-		    "smtp-server-port=i" => \$smtp_server_port,
-		    "smtp-user=s" => \$smtp_authuser,
-		    "smtp-pass:s" => \$smtp_authpass,
-		    "smtp-ssl" => sub { $smtp_encryption = 'ssl' },
-		    "smtp-encryption=s" => \$smtp_encryption,
-		    "identity=s" => \$identity,
-		    "annotate" => \$annotate,
-		    "compose:s" => \$compose,
-		    "quiet" => \$quiet,
-		    "cc-cmd=s" => \$cc_cmd,
-		    "suppress-from!" => \$suppress_from,
-		    "suppress-cc=s" => \@suppress_cc,
-		    "signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
-		    "confirm=s" => \$confirm,
-		    "dry-run" => \$dry_run,
-		    "envelope-sender=s" => \$envelope_sender,
-		    "thread!" => \$thread,
-		    "validate!" => \$validate,
-		    "format-patch!" => \$format_patch,
-	 );
+my $rc = GetOptions(
+	"sender|from=s" => \$sender,
+	"in-reply-to=s" => \$initial_reply_to,
+	"subject=s" => \$initial_subject,
+	"to=s" => \@to,
+	"cc=s" => \@initial_cc,
+	"bcc=s" => \@bcclist,
+	"chain-reply-to!" => \$chain_reply_to,
+	"delay=i" => \$delay,
+	"smtp-server=s" => \$smtp_server,
+	"smtp-server-port=i" => \$smtp_server_port,
+	"smtp-user=s" => \$smtp_authuser,
+	"smtp-pass:s" => \$smtp_authpass,
+	"smtp-ssl" => sub { $smtp_encryption = 'ssl' },
+	"smtp-encryption=s" => \$smtp_encryption,
+	"identity=s" => \$identity,
+	"annotate" => \$annotate,
+	"compose:s" => \$compose,
+	"quiet" => \$quiet,
+	"cc-cmd=s" => \$cc_cmd,
+	"suppress-from!" => \$suppress_from,
+	"suppress-cc=s" => \@suppress_cc,
+	"signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
+	"confirm=s" => \$confirm,
+	"dry-run" => \$dry_run,
+	"envelope-sender=s" => \$envelope_sender,
+	"thread!" => \$thread,
+	"validate!" => \$validate,
+	"format-patch!" => \$format_patch,
+);
 
 unless ($rc) {
-    usage();
+	usage();
 }
 
 die "Cannot run git format-patch from outside a repository\n"
@@ -407,29 +417,55 @@ sub split_addrs {
 my %aliases;
 my %parse_alias = (
 	# multiline formats can be supported in the future
-	mutt => sub { my $fh = shift; while (<$fh>) {
-		if (/^\s*alias\s+(\S+)\s+(.*)$/) {
-			my ($alias, $addr) = ($1, $2);
-			$addr =~ s/#.*$//; # mutt allows # comments
-			 # commas delimit multiple addresses
-			$aliases{$alias} = [ split_addrs($addr) ];
-		}}},
-	mailrc => sub { my $fh = shift; while (<$fh>) {
-		if (/^alias\s+(\S+)\s+(.*)$/) {
-			# spaces delimit multiple addresses
-			$aliases{$1} = [ split(/\s+/, $2) ];
-		}}},
-	pine => sub { my $fh = shift; my $f='\t[^\t]*';
-	        for (my $x = ''; defined($x); $x = $_) {
+	mutt => sub {
+
+		my $fh = shift;
+
+		while (<$fh>) {
+			if (/^\s*alias\s+(\S+)\s+(.*)$/) {
+				my ($alias, $addr) = ($1, $2);
+				$addr =~ s/#.*$//; # mutt allows # comments
+				# commas delimit multiple addresses
+				$aliases{$alias} = [ split_addrs($addr) ];
+			}
+		}
+	},
+
+	mailrc => sub {
+
+		my $fh = shift;
+
+		while (<$fh>) {
+			if (/^alias\s+(\S+)\s+(.*)$/) {
+				# spaces delimit multiple addresses
+				$aliases{$1} = [ split(/\s+/, $2) ];
+			}
+		}
+	},
+
+	pine => sub {
+
+		my $fh = shift;
+		my $f='\t[^\t]*';
+
+		for (my $x = ''; defined($x); $x = $_) {
 			chomp $x;
-		        $x .= $1 while(defined($_ = <$fh>) && /^ +(.*)$/);
+			$x .= $1 while(defined($_ = <$fh>) && /^ +(.*)$/);
 			$x =~ /^(\S+)$f\t\(?([^\t]+?)\)?(:?$f){0,2}$/ or next;
 			$aliases{$1} = [ split_addrs($2) ];
-		}},
-	gnus => sub { my $fh = shift; while (<$fh>) {
-		if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
-			$aliases{$1} = [ $2 ];
-		}}}
+		}
+	},
+
+	gnus => sub {
+
+		my $fh = shift;
+
+		while (<$fh>) {
+			if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
+				$aliases{$1} = [ $2 ];
+			}
+		}
+	}
 );
 
 if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
@@ -597,10 +633,11 @@ EOT
 		} elsif (/^\n$/) {
 			$in_body = 1;
 			if ($need_8bit_cte) {
-				print $compose_final_file "MIME-Version: 1.0\n",
-					 "Content-Type: text/plain; ",
-					   "charset=utf-8\n",
-					 "Content-Transfer-Encoding: 8bit\n";
+				print $compose_final_file
+					"MIME-Version: 1.0\n",
+					"Content-Type: text/plain; ",
+					"charset=utf-8\n",
+					"Content-Transfer-Encoding: 8bit\n";
 			}
 		} elsif (/^MIME-Version:/i) {
 			$need_8bit_cte = 0;
@@ -609,8 +646,8 @@ EOT
 			my $subject = $initial_subject;
 			$_ = "Subject: " .
 				($subject =~ /[^[:ascii:]]/ ?
-				 quote_rfc2047($subject) :
-				 $subject) .
+				quote_rfc2047($subject) :
+				$subject) .
 				"\n";
 		} elsif (/^In-Reply-To:\s*(.+)\s*$/i) {
 			$initial_reply_to = $1;
@@ -639,8 +676,10 @@ sub ask {
 	my $resp;
 	my $i = 0;
 	return defined $default ? $default : undef
-		unless defined $term->IN and defined fileno($term->IN) and
-		       defined $term->OUT and defined fileno($term->OUT);
+		unless defined $term->IN
+			and defined fileno($term->IN)
+			and defined $term->OUT
+			and defined fileno($term->OUT);
 	while ($i++ < 10) {
 		$resp = $term->readline($prompt);
 		if (!defined $resp) { # EOF
@@ -660,8 +699,12 @@ sub ask {
 my $prompting = 0;
 if (!defined $sender) {
 	$sender = $repoauthor || $repocommitter || '';
-	$sender = ask("Who should the emails appear to be from? [$sender] ",
-	              default => $sender);
+
+	$sender = ask(
+		"Who should the emails appear to be from? [$sender] ",
+		default => $sender
+	);
+
 	print "Emails will be sent from: ", $sender, "\n";
 	$prompting++;
 }
@@ -689,7 +732,8 @@ sub expand_aliases {
 
 if ($thread && !defined $initial_reply_to && $prompting) {
 	$initial_reply_to = ask(
-		"Message-ID to be used as In-Reply-To for the first email? ");
+		"Message-ID to be used as In-Reply-To for the first email? "
+	);
 }
 if (defined $initial_reply_to) {
 	$initial_reply_to =~ s/^\s*<?//;
@@ -823,18 +867,22 @@ sub sanitize_address
 sub send_message
 {
 	my @recipients = unique_email_list(@to);
-	@cc = (grep { my $cc = extract_valid_address($_);
-		      not grep { $cc eq $_ } @recipients
-		    }
-	       map { sanitize_address($_) }
-	       @cc);
+
+	@cc = (grep
+		{
+			my $cc = extract_valid_address($_);
+			not grep { $cc eq $_ } @recipients
+		}
+		map { sanitize_address($_) } @cc
+	);
+
 	my $to = join (",\n\t", @recipients);
 	@recipients = unique_email_list(@recipients,@cc,@bcclist);
 	@recipients = (map { extract_valid_address($_) } @recipients);
 	my $date = format_2822_time($time++);
 	my $gitversion = '@@GIT_VERSION@@';
 	if ($gitversion =~ m/..GIT_VERSION../) {
-	    $gitversion = Git::version();
+		$gitversion = Git::version();
 	}
 
 	my $cc = join(", ", unique_email_list(@cc));
@@ -883,9 +931,13 @@ X-Mailer: git-send-email $gitversion
 			print "    To retain the current behavior, but squelch this message,\n";
 			print "    run 'git config --global sendemail.confirm auto'.\n\n";
 		}
-		$_ = ask("Send this email? ([y]es|[n]o|[q]uit|[a]ll): ",
-		         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,
-		         default => $ask_default);
+
+		$_ = ask(
+			"Send this email? ([y]es|[n]o|[q]uit|[a]ll): ",
+			valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,
+			default => $ask_default
+		);
+
 		die "Send this email reply required" unless defined $_;
 		if (/^n/i) {
 			return;
@@ -920,9 +972,13 @@ X-Mailer: git-send-email $gitversion
 		}
 		else {
 			require Net::SMTP;
-			$smtp ||= Net::SMTP->new((defined $smtp_server_port)
-						 ? "$smtp_server:$smtp_server_port"
-						 : $smtp_server);
+
+			$smtp ||= Net::SMTP->new(
+				(defined $smtp_server_port)
+					? "$smtp_server:$smtp_server_port"
+					: $smtp_server
+			);
+
 			if ($smtp_encryption eq 'tls') {
 				require Net::SMTP::SSL;
 				$smtp->command('STARTTLS');
@@ -1018,7 +1074,7 @@ for (my $index = 0; $index < @files; $index++) {
 			chomp($header[$#header]);
 			s/^\s+/ /;
 			$header[$#header] .= $_;
-	    } else {
+		} else {
 			push(@header, $_);
 		}
 	}
@@ -1136,9 +1192,9 @@ for (my $index = 0; $index < @files; $index++) {
 			}
 			else {
 				push @xh,
-				  'MIME-Version: 1.0',
-				  "Content-Type: text/plain; charset=$author_encoding",
-				  'Content-Transfer-Encoding: 8bit';
+					'MIME-Version: 1.0',
+					"Content-Type: text/plain; charset=$author_encoding",
+					'Content-Transfer-Encoding: 8bit';
 			}
 		}
 	}
@@ -1146,7 +1202,9 @@ for (my $index = 0; $index < @files; $index++) {
 	$needs_confirm = (
 		$confirm eq "always" or
 		($confirm =~ /^(?:auto|cc)$/ && @cc) or
-		($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1));
+		($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1)
+	);
+
 	$needs_confirm = "inform" if ($needs_confirm && $confirm_unconfigured && @cc);
 
 	@cc = (@initial_cc, @cc);
Signature · 1 line
1.6.2.2.448.g61445.dirty
#6 lore raw

Re: [PATCH RFC 6/6] send-email: Remove horrible mix of tabs and spaces

2009/4/7 Michael Witten <[email protected]>:

git-send-email.perl line 25

Quoted 7 lines
git-send-email.perl +7 -0
+## WARNING! ACHTUNG! ATTENTION! ADVERTENCIA!
+##   Currently, this file uses tabs (like the rest of git source) to
+##   delineate code structure. Do NOT under any circumstances mix tabs
+##   and spaces across lines that share a relationship in terms of layout.
+##   In fact, it would currently be best to use only tabs, so please set
+##   your editor(s) accordingly. This code is already trashy enough. Please
+##   don't make it worse.

Perltidy the file?

Yves

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
#7 lore raw

Re: [PATCH RFC 6/6] send-email: Remove horrible mix of tabs and spaces

Quoted 11 lines · demerphq

2009/4/7 Michael Witten <[email protected]>:

git-send-email.perl line 25

Quoted 7 lines
git-send-email.perl +7 -0
+## WARNING! ACHTUNG! ATTENTION! ADVERTENCIA!
+##   Currently, this file uses tabs (like the rest of git source) to
+##   delineate code structure. Do NOT under any circumstances mix tabs
+##   and spaces across lines that share a relationship in terms of layout.
+##   In fact, it would currently be best to use only tabs, so please set
+##   your editor(s) accordingly. This code is already trashy enough. Please
+##   don't make it worse.

Perltidy the file?

Quoted 1 line

Yves

Oooh, that's sexy!

I'll have to give that a try. However, I've been entertaining the idea of rewriting the whole thing anyway; it's in need of much more than reformatting.

As a side note, Yves, I sent the patches to perl5-porters again about 1.6666666 hours ago, but nothing seems to have come through; I'll try again later.

Michael

#8 lore raw

Re: [PATCH RFC 6/6] send-email: Remove horrible mix of tabs and spaces

Quoted 3 lines · Michael Witten

I'll have to give that a try. However, I've been entertaining the idea of rewriting the whole thing anyway; it's in need of much more than reformatting.

Just my two cents, but if you are considering re-writing send-email, I would suggest two things:

1. Make much heavier use of existing CPAN libraries. A lot of the ugly code is trying to handle corner cases in rfc2822 and mime parsing and generation. And I would not be surprised if there were still bugs in that ugly code.

2. Make a new command to compete with send-email instead of using the same name. This means that people who are really put off by CPAN dependencies from (1) above won't be negatively impacted. And you can drop any historical interface warts if you want to.

-Peff

#9 lore raw

Re: [PATCH RFC 6/6] send-email: Remove horrible mix of tabs and spaces

Quoted 14 lines · Jeff King
Quoted 3 lines · Michael Witten

I'll have to give that a try. However, I've been entertaining the idea of rewriting the whole thing anyway; it's in need of much more than reformatting.

Just my two cents, but if you are considering re-writing send-email, I would suggest two things:

1. Make much heavier use of existing CPAN libraries. A lot of the ugly code is trying to handle corner cases in rfc2822 and mime parsing and generation. And I would not be surprised if there were still bugs in that ugly code.

Quoted 5 lines

2. Make a new command to compete with send-email instead of using the same name. This means that people who are really put off by CPAN dependencies from (1) above won't be negatively impacted. And you can drop any historical interface warts if you want to.

3. Make it capable of sending email directly from commits rather than than having to generate them as files first. For bonus-points, use git sequencer or some other "git rebase -i"-esque mangling thing first, with capabilities of adding a cover-letter for patch-series.

Signature · 7 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
#10 lore raw

Re: [PATCH RFC 6/6] send-email: Remove horrible mix of tabs and spaces

Quoted 10 lines · Andreas Ericsson
Quoted 5 lines

2. Make a new command to compete with send-email instead of using the same name. This means that people who are really put off by CPAN dependencies from (1) above won't be negatively impacted. And you can drop any historical interface warts if you want to.

3. Make it capable of sending email directly from commits rather than than having to generate them as files first. For bonus-points, use git sequencer or some other "git rebase -i"-esque mangling thing first, with capabilities of adding a cover-letter for patch-series.

As Tomas noted, this is already possible (this was due to some patches from Pierre a few months ago, I think). But IIRC, there are some corner cases where send-email has to guess whether you mean rev-list options or a file (or maybe there is some way to signal, I don't remember). And that is exactly the sort of thing that you could clean up via (2) above.

-Peff

#11 lore raw

Re: [PATCH RFC 6/6] send-email: Remove horrible mix of tabs and spaces

In reply to Andreas Ericsson
Quoted 2 lines · Andreas Ericsson

3. Make it capable of sending email directly from commits rather than than having to generate them as files first. For bonus-points, use

This is already possible:
git send-email [options] <file|directory|rev-list options>
You can pass it a rev-list and it will generate the patches on its own.

Quoted 2 lines

git sequencer or some other "git rebase -i"-esque mangling thing first, with capabilities of adding a cover-letter for patch-series.

tom

#12 lore raw

Re: [PATCH RFC 6/6] send-email: Remove horrible mix of tabs and spaces

In reply to Michael Witten

2009/4/7 Michael Witten <[email protected]>:

Quoted 12 lines · demerphq
Quoted 11 lines

2009/4/7 Michael Witten <[email protected]>:

git-send-email.perl line 25

Quoted 7 lines
git-send-email.perl +7 -0
+## WARNING! ACHTUNG! ATTENTION! ADVERTENCIA!
+##   Currently, this file uses tabs (like the rest of git source) to
+##   delineate code structure. Do NOT under any circumstances mix tabs
+##   and spaces across lines that share a relationship in terms of layout.
+##   In fact, it would currently be best to use only tabs, so please set
+##   your editor(s) accordingly. This code is already trashy enough. Please
+##   don't make it worse.

Perltidy the file?

Quoted 7 lines
Quoted 1 line

Yves

Oooh, that's sexy!

I'll have to give that a try. However, I've been entertaining the idea of rewriting the whole thing anyway; it's in need of much more than reformatting.

Yes. I notice evilness in there. Not necessarily dire burn your house down evilness, but evilness none the less.

Quoted 3 lines

As a side note, Yves, I sent the patches to perl5-porters again about 1.6666666 hours ago, but nothing seems to have come through; I'll try again later.

You mean the 14 patches I just applied and pushed to blead?

:-)

cheers,
Yves

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
#13 lore raw

Re: [PATCH RFC 6/6] send-email: Remove horrible mix of tabs and spaces

2009/4/7 demerphq <[email protected]>:

Quoted 15 lines

2009/4/7 Michael Witten <[email protected]>:

Quoted 14 lines · demerphq
Quoted 12 lines

2009/4/7 Michael Witten <[email protected]>:

git-send-email.perl line 25

Quoted 7 lines
git-send-email.perl +7 -0
+## WARNING! ACHTUNG! ATTENTION! ADVERTENCIA!
+##   Currently, this file uses tabs (like the rest of git source) to
+##   delineate code structure. Do NOT under any circumstances mix tabs
+##   and spaces across lines that share a relationship in terms of layout.
+##   In fact, it would currently be best to use only tabs, so please set
+##   your editor(s) accordingly. This code is already trashy enough. Please
+##   don't make it worse.

Perltidy the file?

Yves

Quoted 8 lines
Quoted 5 lines

Oooh, that's sexy!

I'll have to give that a try. However, I've been entertaining the idea of rewriting the whole thing anyway; it's in need of much more than reformatting.

Yes. I notice evilness in there. Not necessarily dire burn your house down evilness, but evilness none the less.

BTW, I'd be glad to help out if you want, as I suspect would some of the p5p folks.

Yves

Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
#14 lore raw

Re: [PATCH RFC 5/6] send-email: Cleanup the usage text a bit

In reply to Michael Witten
Quoted 12 lines · Michael Witten

All lines should be < 80 characters.

---
 git-send-email.perl |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
git-send-email.perl +0 -0
index 481bf36..c3e3598 100755

git-send-email.perl package main; · line 47

Quoted 6 lines
git-send-email.perl +3 -0
@@ -42,6 +42,9 @@ package main;
 
 
 sub usage {
+
+	# All printed lines should be less than 80 characters.
+

Perhaps a good idea. It would have been nicer if this were early in the series.

#15 lore raw

Re: [PATCH RFC 4/6] send-email: --compose takes optional argument to existing file

In reply to Michael Witten
Quoted 16 lines · Michael Witten

Now, a user may specify an existing (in-progress) file to use as the introductory/summary email.

The file is opened for any additional editing as usual.

---
 Documentation/git-send-email.txt |    7 ++-
 git-send-email.perl              |  112 ++++++++++++++++++++++----------------
 2 files changed, 71 insertions(+), 48 deletions(-)
Documentation/git-send-email.txt +0 -0
index 4b656ca..bc9ff13 100644

Documentation/git-send-email.txt The --cc option must be repeated for each user you want on the cc list. · line 60

Quoted 6 lines
Documentation/git-send-email.txt +1 -2
@@ -57,8 +57,11 @@ The --cc option must be repeated for each user you want on the cc list.
 	or one for all of them at once.
 
 --compose::
-	Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an
-	introductory message for the patch series.
+	Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR, or vi to edit an

I think addition of ", or vi" makes sense but the ", or $EDITOR" needs to change, and also the language needs to be clarified to say the first one of these is used.

The name of the new variable $compose_file that is used as a filehandle was confusing to read (almost everybody else in the program uses $fh, and it looked as if $compose_file is talking about the name of the file or indirectly pointing at an existing filehandle, but it was not).

#16 lore raw

Re: [PATCH RFC 3/6] send-email: Handle "GIT:" rather than "GIT: " during --compose

In reply to Michael Witten
Quoted 4 lines · Michael Witten

This should make things a little more robust in terms of user input; before, even the program got it wrong by outputting a line with only "GIT:", which was left in place as a header, because there would be no following space character.

An alternative could be to add an extra space after the "GIT:" on the lines the compose template generated by this program, but people can set their editors to strip trailing whitespaces, so I think yours is a better approach. I suspect this patch comes from your own experience of getting bitten by this once, perhaps?

Quoted 1 line

Also, I cleaned up get_patch_subject().

Which is a bit iffy. It does not belong to the primary topic of the patch to begin with, so it shouldn't be in here even if it weren't iffy.

Quoted 17 lines
git-send-email.perl +3 -6
index 63d6063..098c620 100755
@@ -505,15 +505,16 @@ if (@files) {
 }
 
 sub get_patch_subject($) {
-	my $fn = shift;
-	open (my $fh, '<', $fn);
-	while (my $line = <$fh>) {
-		next unless ($line =~ /^Subject: (.*)$/);
-		close $fh;
-		return "GIT: $1\n";
+
+	my $patch = shift;
+	open (my $fh, '<', $patch);

git-send-email.perl if (@files) { · line 518

Quoted 10 lines
git-send-email.perl +6 -2
+
+	while (<$fh>) {
+		next unless (/^Subject: (.*)$/);
+		return $1;
 	}
-	close $fh;
-	die "No subject line in $fn ?";
+
+	die "'Subject:' line expected in '$patch'";
 }

Because "while (<>)" does not localize $_, you are clobbering it in the caller's context. I do not know if any of the the existing callers cares, but it is a change in behaviour.

$ cat >/var/tmp/j.perl <<\EOF
#!/usr/bin/perl -w
use strict;
sub foo($) {
	my $name = shift;
	open my $fh, "<$name";
	while (my $line = <$fh>) {
		chomp $line;
		close $fh;
		return $line;
	}
	close $fh;
	return undef;
}
sub bar($) {
	my $name = shift;
	open my $fh, "<$name";
	while (<$fh>) {
		chomp;
		close $fh;
		return $_;
	}
	close $fh;
	return undef;
}
$_ = 'original';
foo($0);
print "after running foo: $_\n";

$_ = 'original';
bar($0);
print "after running bar: $_\n";
EOF

$ perl /var/tmp/j.perl
after running foo: original
after running bar: #!/usr/bin/perl -w
$ exit
#17 lore raw

Re: [PATCH RFC 3/6] send-email: Handle "GIT:" rather than "GIT: " during --compose

Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Michael Witten

This should make things a little more robust in terms of user input; before, even the program got it wrong by outputting a line with only "GIT:", which was left in place as a header, because there would be no following space character.

Quoted 5 lines

An alternative could be to add an extra space after the "GIT:" on the lines the compose template generated by this program, but people can set their editors to strip trailing whitespaces, so I think yours is a better approach.  I suspect this patch comes from your own experience of getting bitten by this once, perhaps?

My first thought was indeed just to add an extra space, but it occurred to me that it's not easily remembered. Consider the original documentation:

Quoted 6 lines

If the body of the message (what you type after the headers and a blank line) only contains blank (or GIT: prefixed) lines the summary won't be sent

Quoted 1 line

Also, I cleaned up get_patch_subject().

Which is a bit iffy.  It does not belong to the primary topic of the patch to begin with, so it shouldn't be in here even if it weren't iffy.

I can split it into another patch.

Quoted 3 lines

Because "while (<>)" does not localize $_, you are clobbering it in the caller's context.  I do not know if any of the the existing callers cares, but it is a change in behaviour.

How about:

    while (local $_ = <$fh>)

Or, in our case, this:

    while (my $_ = <$fh>)

In testing these, I came across behavior that I think is incorrect, and I have a mind to complain about it to the perl guys:

# Well! the print `function' doesn't seem to play by the rules.

# Example 0
# I expect the output to be:
# 1
# 1
# 3

# and I am right!

$_ = 3;

{
local $_ = 1;
print; print "\n";
print $_; print "\n";
}

print; print "\n";

##############################################

# Example 1
# I expect the output to be:
# 3
# 1
# 3
# But it is:
# 1
# 1
# 3

$_ = 3;

{
my $_ = 1;
print; print "\n";
print $_; print "\n";
}

print; print "\n";

###############################################

# Example 2
# I expect the output to be:
# 1
# 1
# 3

# and I am right!

sub my_print {
print(shift or $_);
}

$_ = 3;

{
local $_ = 1;
my_print; print "\n";
my_print $_; print "\n";
}

my_print; print "\n";

###############################################

# Example 3
# I expect the output to be:
# 3
# 1
# 3

# and I am right this time!

sub my_print {
print(shift or $_);
}

$_ = 3;

{
my $_ = 1;
my_print; print "\n";
my_print $_; print "\n";
}

my_print; print "\n";

#18 lore raw

Re: [PATCH RFC 3/6] send-email: Handle "GIT:" rather than "GIT: " during --compose

Quoted 11 lines · Michael Witten
Quoted 3 lines

Because "while (<>)" does not localize $_, you are clobbering it in the caller's context.  I do not know if any of the the existing callers cares, but it is a change in behaviour.

How about:

    while (local $_ = <$fh>)

Or, in our case, this:

    while (my $_ = <$fh>)

Special variables like $_ cannot be made into lexicals, unless you know you will only run with a very recent version of Perl (5.9.1, I think).

If you do not want to worry about portability, typically it is easiest to say "local ($_)" upfront in the beginning of a sub.

I do not understand why you want to change the original

	while (my $line = <$fh>) {
        	...
	}

though.

#19 lore raw

Re: [PATCH RFC 3/6] send-email: Handle "GIT:" rather than "GIT: " during --compose

Quoted 2 lines · Junio C Hamano

Special variables like $_ cannot be made into lexicals, unless you know you will only run with a very recent version of Perl (5.9.1, I think).

Ah. I wish Perl's docs were a little more forthcoming about such things. I ended up just trying it out, and indeed I am running 5.10.0.

Quoted 10 lines

If you do not want to worry about portability, typically it is easiest to say "local ($_)" upfront in the beginning of a sub.

I do not understand why you want to change the original

       while (my $line = <$fh>) {
               ...
       }

though.

I'm not terribly bent on it; I had already reshaped that function and I was curious about making what I had done work out of intellectual curiosity. In fact, my commits no longer have the refactored version.

#20 lore raw

Re: [PATCH RFC 2/6] send-email: --smtp-server-port should take an integer

In reply to Michael Witten

I think this makes sense but you made it depend on your --delay patch, so it won't apply without wiggling the patch by hand.

I can do that, but a good rule of thumb when preparing a series is to have this kind of obvious clean-up first, leaving enhancement patches later in the series.

#21 lore raw

Re: [PATCH RFC 2/6] send-email: --smtp-server-port should take an integer

In reply to Michael Witten
Quoted 10 lines · Michael Witten
---
 git-send-email.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
git-send-email.perl +0 -0
index 273c8c7..63d6063 100755

git-send-email.perl my $rc = GetOptions("sender|from=s" => \$sender, · line 257

Quoted 8 lines
git-send-email.perl +1 -1
@@ -251,7 +251,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "chain-reply-to!" => \$chain_reply_to,
 		    "delay=i" => \$delay,
 		    "smtp-server=s" => \$smtp_server,
-		    "smtp-server-port=s" => \$smtp_server_port,
+		    "smtp-server-port=i" => \$smtp_server_port,
 		    "smtp-user=s" => \$smtp_authuser,
 		    "smtp-pass:s" => \$smtp_authpass,
 		    "smtp-ssl" => sub { $smtp_encryption = 'ssl' },

Hmm, I have to wonder if there somebody who is using symbolic names for ports, e.g. --smtp-server-port=ssmtp which this patch may start rejecting.

#22 lore raw

Re: [PATCH RFC 2/6] send-email: --smtp-server-port should take an integer

Quoted 3 lines · On Saturday 11 April 2009 13:22:29 Junio C Hamano wrote:

Hmm, I have to wonder if there somebody who is using symbolic names for ports, e.g. --smtp-server-port=ssmtp which this patch may start rejecting.

An common example is --smtp-server-port=submission (for 587).

#23 lore raw

Re: [PATCH RFC 2/6] send-email: --smtp-server-port should take an integer

Quoted 6 lines · Wesley J. Landaker
Quoted 3 lines · On Saturday 11 April 2009 13:22:29 Junio C Hamano wrote:

Hmm, I have to wonder if there somebody who is using symbolic names for ports, e.g. --smtp-server-port=ssmtp which this patch may start rejecting.

An common example is --smtp-server-port=submission (for 587).

Clearly, then, this patch is no good. Consider it thrown out.

#24 lore raw
In reply to Michael Witten
Quoted 10 lines · Michael Witten

When sending a patch series, the emails often arrive at the final destination out of order; though these emails should be chained via the In-Reply-To headers, some mail-viewing systems display by order of arrival instead.

The --delay option provides a means for specifying that there should be a certain number of seconds of delay between sending emails, so that the arrival order can be controlled better.

I'm a little dubious how well this works in practice. Have you done any experiments?

The reason I am dubious is that you are presumably delaying only a few seconds (since anything more would be quite annoying to the user). This may deal with a short race condition in your local mail server. But what is the real cause of out-of-order delivery? Is it the local mail server seeing two messages essentially "simultaneously" and then reordering them randomly? Or is it other random delays that happen _after_ that, like network congestion, DNS lookups, down or congested servers, time it takes to deliver the actual message body (e.g., if your mail server sends two simultaneously, but the first one is much larger and takes longer to complete), etc.

Those delays can be much larger than a few seconds, and this won't help at all there.

I think it may still be reasonable to implement a solution that only covers some of the cases, but I what I am asking is if we know what percentage of the cases that is. If we are preventing only 1% of out-of-order deliveries with this, I question whether it is worth the bother.

-Peff

#25 lore raw
Quoted 9 lines · Jeff King
Quoted 9 lines

When sending a patch series, the emails often arrive at the final destination out of order; though these emails should be chained via the In-Reply-To headers, some mail-viewing systems display by order of arrival instead.

The --delay option provides a means for specifying that there should be a certain number of seconds of delay between sending emails, so that the arrival order can be controlled better.

Quoted 7 lines
Quoted 1 line

I think it may still be reasonable to implement a solution that only covers some of the cases, but I what I am asking is if we know what percentage of the cases that is. If we are preventing only 1% of out-of-order deliveries with this, I question whether it is worth the bother.

IMHO, this improvement is broken by design. We try to fix a receiver-only issue by a sender side fix.

If the receiver wants the patch series be in a good ordered _for sure_, he has to switch to a client mail supporting the In-Reply-To chains.

Signature · 1 line
Nicolas Sebrecht
#26 lore raw
Quoted 8 lines · Nicolas Sebrecht
Quoted 5 lines

I think it may still be reasonable to implement a solution that only covers some of the cases, but I what I am asking is if we know what percentage of the cases that is. If we are preventing only 1% of out-of-order deliveries with this, I question whether it is worth the bother.

IMHO, this improvement is broken by design. We try to fix a receiver-only issue by a sender side fix.

I almost said the same thing: it is really the receiver's problem. However, that doesn't mean the sender can't do simple things to help hint the right thing to the receiver. For example, we already munge the date fields to make sure the timestamp in each patch is increasing.

So there is precedent for giving hints to help the receiver sort the patches. But munging the date fields is relatively transparent to the sener. A multi-second delay is downright annoying. As a sender, I don't think I would enable this option.

Quoted 2 lines

If the receiver wants the patch series be in a good ordered _for sure_, he has to switch to a client mail supporting the In-Reply-To chains.

That's not enough for shallow-style patch series, like:

PATCH 0/3

    \->PATCH 1/3
    \->PATCH 2/3
    \->PATCH 3/3

which is the proposed default for v1.6.3.

Many readers will sort by rfc822 date within a single thread level, which is sufficient with what send-email currently generates. Sorting by subject should also work fine.

But apparently many readers sort by date received. See this subthread:

http://article.gmane.org/gmane.comp.version-control.git/110097

I am generally of the opinion that if it is a big problem for people, they should get a better mail client. But I am also open to suggestions for helping receivers on crappy mail clients as long as those suggestions do not put a burden on the sender.

-Peff

#27 lore raw
In reply to Nicolas Sebrecht
Quoted 19 lines · Nicolas Sebrecht
Quoted 9 lines · Jeff King
Quoted 9 lines

When sending a patch series, the emails often arrive at the final destination out of order; though these emails should be chained via the In-Reply-To headers, some mail-viewing systems display by order of arrival instead.

The --delay option provides a means for specifying that there should be a certain number of seconds of delay between sending emails, so that the arrival order can be controlled better.

Quoted 7 lines
Quoted 1 line

I think it may still be reasonable to implement a solution that only covers some of the cases, but I what I am asking is if we know what percentage of the cases that is. If we are preventing only 1% of out-of-order deliveries with this, I question whether it is worth the bother.

Quoted 6 lines

IMHO, this improvement is broken by design. We try to fix a receiver-only issue by a sender side fix.

If the receiver wants the patch series be in a good ordered _for sure_, he has to switch to a client mail supporting the In-Reply-To chains.

The biggest problem with in-reply-to chains is that they're absolutely horrible for patch-series of more than five or so messages. The "worst" one this week was a series of 14 patches, I believe. If any of the deeper nested patches gets any sort of commentary, it usually eats so much horizontal screen estate that it becomes hopeless to actually find anything.

Besides that, most mua's I've worked with list emails in a thread like this:

First

 +------ second
 |         +------ third
 |         |
 |         +---- reply to second
 |                 +
 |                 |
 |                 + reply to reply to second
 |
 +-- reply to first

etc. etc, but when asked for "next unread message in thread", they jump to the *deepest* message in the thread first, so you end up reading the replies to the patches in the wrong order anyway.

For those two reasons, I absolutely loathe deeply nested in-reply-to chains.

Signature · 7 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
#29 lore raw
In reply to Michael Witten
Quoted 8 lines · Michael Witten

When sending a patch series, the emails often arrive at the final destination out of order; though these emails should be chained via the In-Reply-To headers, some mail-viewing systems display by order of arrival instead.

The --delay option provides a means for specifying that there should be a certain number of seconds of delay between sending emails, so that the arrival order can be controlled better.

If you are trying to force the order of messages that the client MUA physically receives the messages, I do not think giving N second interval at the sending end would help much in the real world. Between your submitting MUA (that's "git-send-email") and the client MUA, there are many hops involved:

* Your outgoing MSA (typically your ISP's sendmail) your MUA hands messages to;

* Your ISP's internal mail routing chain of MTAs that forward the messages around;

* The recipient's ISP's incoming MTA that receives the messages from your ISP's outgoing MTA;

* The recipient's ISP's internal mail routing chain of MTAs that forward the messages around, until they reach...

* ... the mailbox at recipient's ISP that stores the messages until the recipient picks them up;

* And finally the recipient's MUA that reads from the mailbox.

Messages your MUA sends out can take different paths in the above chain even though the final destination (mailbox at the recipient's ISP) may be the same, and different mailpaths can and do have different latencies. Even if all the messages sent out by a single invocation of your submitting MUA happened to take the same mailpath, any single hop can batch the messages that arrive within a small time window before passing them to the next hop, and it can reorder the messages when it does so.

In short, the only thing your --delay can control is the arrival interval at your outgoing MSA. The arrival interval and order of messages are outside your control for later hops.

On the other hand, I think send-email already has hacks to timestamp the messages at least one-second apart by shifting the Date: field, so that the recipient MUA can sort by the departure timestamp if it wants to (and if it can), instead of the arrival timestamp. Is it not working well for you?