git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 01/10] Docs: send-email: Put options back into alphabetical order
@ 2009-04-11 19:08 Michael Witten
  2009-04-11 19:08 ` [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION Michael Witten
  0 siblings, 1 reply; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

I also wrote a comment block as a warning to trespassers.

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 Documentation/git-send-email.txt |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 0b1f183..595c7ba 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -32,6 +32,10 @@ script
 This format expects the first line of the file to contain the "Cc:" value
 and the "Subject:" of the message as the second line.
 
+/////////////////////////////////////////////////////////////////////////////////////
+//// Within each category (Composing, Sending, Automating, and Administering),   ////
+//// options are to be given in alphabetical order. Please maintain this layout. ////
+/////////////////////////////////////////////////////////////////////////////////////
 
 OPTIONS
 -------
@@ -39,6 +43,11 @@ OPTIONS
 Composing
 ~~~~~~~~~
 
+--annotate::
+	Review each patch you're about to send in an editor. The setting
+	'sendemail.multiedit' defines if this will spawn one editor per patch
+	or one for all of them at once.
+
 --bcc=<address>::
 	Specify a "Bcc:" value for each email. Default is the value of
 	'sendemail.bcc'.
@@ -51,11 +60,6 @@ The --bcc option must be repeated for each user you want on the bcc list.
 +
 The --cc option must be repeated for each user you want on the cc list.
 
---annotate::
-	Review each patch you're about to send in an editor. The setting
-	'sendemail.multiedit' defines if this will spawn one editor per patch
-	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.
@@ -230,6 +234,12 @@ have been specified, in which case default to 'compose'.
 --dry-run::
 	Do everything except actually send the emails.
 
+--[no-]format-patch::
+	When an argument may be understood either as a reference or as a file name,
+	choose to understand it as a format-patch argument ('--format-patch')
+	or as a file name ('--no-format-patch'). By default, when such a conflict
+	occurs, git send-email will fail.
+
 --quiet::
 	Make git-send-email less verbose.  One line per email should be
 	all that is output.
@@ -246,12 +256,6 @@ have been specified, in which case default to 'compose'.
 Default is the value of 'sendemail.validate'; if this is not set,
 default to '--validate'.
 
---[no-]format-patch::
-	When an argument may be understood either as a reference or as a file name,
-	choose to understand it as a format-patch argument ('--format-patch')
-	or as a file name ('--no-format-patch'). By default, when such a conflict
-	occurs, git send-email will fail.
-
 
 CONFIGURATION
 -------------
-- 
1.6.2.2.479.g2aec

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

* [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION
  2009-04-11 19:08 [PATCH RFC 01/10] Docs: send-email: Put options back into alphabetical order Michael Witten
@ 2009-04-11 19:08 ` Michael Witten
  2009-04-11 19:08   ` [PATCH RFC 03/10] send-email: Cleanup the usage text and docs a bit Michael Witten
  2009-04-11 21:42   ` [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION Stephen Boyd
  0 siblings, 2 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

In particular, sendemail.confirm was removed, because it's already
described along with its corresponding option.

There is now a comment block warning trespassers.

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 Documentation/git-send-email.txt |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 595c7ba..7cdbdd6 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -257,6 +257,11 @@ Default is the value of 'sendemail.validate'; if this is not set,
 default to '--validate'.
 
 
+//////////////////////////////////////////////////////////////////////////////
+//// Only list configuration variables that can't be listed and described ////
+//// with a corresponding option above                                    ////
+//////////////////////////////////////////////////////////////////////////////
+
 CONFIGURATION
 -------------
 
@@ -274,12 +279,6 @@ sendemail.multiedit::
 	summary when '--compose' is used). If false, files will be edited one
 	after the other, spawning a new editor each time.
 
-sendemail.confirm::
-	Sets the default for whether to confirm before sending. Must be
-	one of 'always', 'never', 'cc', 'compose', or 'auto'. See '--confirm'
-	in the previous section for the meaning of these values.
-
-
 Author
 ------
 Written by Ryan Anderson <ryan@michonline.com>
-- 
1.6.2.2.479.g2aec

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

* [PATCH RFC 03/10] send-email: Cleanup the usage text and docs a bit
  2009-04-11 19:08 ` [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION Michael Witten
@ 2009-04-11 19:08   ` Michael Witten
  2009-04-11 19:08     ` [PATCH RFC 04/10] send-email: --smtp-server-port should take an integer Michael Witten
  2009-04-11 21:42   ` [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION Stephen Boyd
  1 sibling, 1 reply; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

All usage text lines should be < 80 characters.

A port number in --smtp-server is no longer handled,
so the suggestion has been removed.

--chain-reply-to doesn't take an argument.

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 Documentation/git-send-email.txt |   17 +++++++------
 git-send-email.perl              |   47 +++++++++++++++++++++-----------------
 2 files changed, 35 insertions(+), 29 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 7cdbdd6..12845d6 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -77,8 +77,9 @@ Missing From or In-Reply-To headers will be prompted for.
 	the value GIT_COMMITTER_IDENT, as returned by "git var -l".
 	The user will still be prompted to confirm this entry.
 
---in-reply-to=<identifier>::
-	Specify the contents of the first In-Reply-To header.
+--in-reply-to=<message-id>::
+	Specify the contents of the first In-Reply-To header;
+	include the angle brackets '<' and '>'.
 	Subsequent emails will refer to the previous email
 	instead of this if --chain-reply-to is set (the default)
 	Only necessary if --compose is also set.  If --compose
@@ -109,7 +110,7 @@ Sending
 	the 'sendemail.envelopesender' configuration variable; if that is
 	unspecified, choosing the envelope sender is left to your MTA.
 
---smtp-encryption=<encryption>::
+--smtp-encryption=<type>::
 	Specify the encryption to use, either 'ssl' or 'tls'.  Any other
 	value reverts to plain SMTP.  Default is the value of
 	'sendemail.smtpencryption'.
@@ -159,7 +160,7 @@ Automating
 	Output of this command must be single email address per line.
 	Default is the value of 'sendemail.cccmd' configuration value.
 
---[no-]chain-reply-to=<identifier>::
+--[no-]chain-reply-to::
 	If this is set, each email will be sent as a reply to the previous
 	email sent.  If disabled with "--no-chain-reply-to", all emails after
 	the first will be sent as replies to the first email sent.  When using
@@ -167,11 +168,11 @@ Automating
 	entire patch series. Default is the value of the 'sendemail.chainreplyto'
 	configuration value; if that is unspecified, default to --chain-reply-to.
 
---identity=<identity>::
+--identity=<id>::
 	A configuration identity. When given, causes values in the
-	'sendemail.<identity>' subsection to take precedence over
+	'sendemail.<id>' subsection to take precedence over
 	values in the 'sendemail' section. The default identity is
-	the value of 'sendemail.identity'.
+	the value of the 'sendemail.identity' configuration variable.
 
 --[no-]signed-off-by-cc::
 	If this is set, add emails found in Signed-off-by: or Cc: lines to the
@@ -215,7 +216,7 @@ specified, as well as 'body' if --no-signed-off-cc is specified.
 Administering
 ~~~~~~~~~~~~~
 
---confirm=<mode>::
+--confirm=<when>::
 	Confirm just before sending:
 +
 --
diff --git a/git-send-email.perl b/git-send-email.perl
index 172b53c..fb3e712 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -42,46 +42,51 @@ package main;
 
 
 sub usage {
+
+	# All printed lines should be less than 80 characters.
+
 	print <<EOT;
 git send-email [options] <file | directory | rev-list options >
 
   Composing:
-    --from                  <str>  * Email From:
-    --to                    <str>  * Email To:
-    --cc                    <str>  * Email Cc:
-    --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.
+    --from              <address>  * Email From:
+    --to                <address>  * Email To:
+    --cc                <address>  * Email Cc:
+    --bcc               <address>  * Email Bcc:
+    --subject            <string>  * Email "Subject:"
+    --in-reply-to    <message-id>  * Email "In-Reply-To:"; include '<' and '>'.
+    --annotate                     * Review each patch that will be sent in
+                                     an editor.
     --compose                      * Open an editor for introduction.
 
   Sending:
-    --envelope-sender       <str>  * Email envelope sender.
-    --smtp-server       <str:int>  * Outgoing SMTP server to use. The port
-                                     is optional. Default 'localhost'.
-    --smtp-server-port      <int>  * Outgoing SMTP server port.
-    --smtp-user             <str>  * Username for SMTP-AUTH.
-    --smtp-pass             <str>  * Password for SMTP-AUTH; not necessary.
-    --smtp-encryption       <str>  * tls or ssl; anything else disables.
+    --envelope-sender   <address>  * Email envelope sender.
+    --smtp-server          <host>  * Outgoing SMTP server to use.
+    --smtp-server-port     <port>  * Outgoing SMTP server port.
+    --smtp-user        <username>  * Username for SMTP-AUTH.
+    --smtp-pass       [<password>] * Password for SMTP-AUTH; not necessary.
+    --smtp-encryption      <type>  * tls or ssl; anything else disables.
     --smtp-ssl                     * Deprecated. Use '--smtp-encryption ssl'.
 
   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.
+    --identity               <id>  * Use the sendemail.<id> options.
+    --cc-cmd            <command>  * Email Cc: via `<command> \$patch_path`
+    --suppress-cc      <category>  * 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.
 
   Administering:
-    --confirm               <str>  * Confirm recipients before sending;
+    --confirm              <when>  * Confirm recipients before sending;
                                      auto, cc, compose, always, or never.
     --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);
-- 
1.6.2.2.479.g2aec

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

* [PATCH RFC 04/10] send-email: --smtp-server-port should take an integer
  2009-04-11 19:08   ` [PATCH RFC 03/10] send-email: Cleanup the usage text and docs a bit Michael Witten
@ 2009-04-11 19:08     ` Michael Witten
  2009-04-11 19:08       ` [PATCH RFC 05/10] send-email: Handle "GIT:" rather than "GIT: " during --compose Michael Witten
  0 siblings, 1 reply; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 git-send-email.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index fb3e712..b689cc7 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -253,7 +253,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "bcc=s" => \@bcclist,
 		    "chain-reply-to!" => \$chain_reply_to,
 		    "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' },
-- 
1.6.2.2.479.g2aec

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

* [PATCH RFC 05/10] send-email: Handle "GIT:" rather than "GIT: " during --compose
  2009-04-11 19:08     ` [PATCH RFC 04/10] send-email: --smtp-server-port should take an integer Michael Witten
@ 2009-04-11 19:08       ` Michael Witten
  2009-04-11 19:08         ` [PATCH RFC 06/10] send-email: References: should only reference what is actually sent Michael Witten
  0 siblings, 1 reply; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

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().

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 git-send-email.perl |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index b689cc7..502f5af 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -507,15 +507,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) {
@@ -534,7 +535,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:
@@ -545,7 +546,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);
 
@@ -567,7 +568,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$/) {
-- 
1.6.2.2.479.g2aec

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

* [PATCH RFC 06/10] send-email: References: should only reference what is actually sent
  2009-04-11 19:08       ` [PATCH RFC 05/10] send-email: Handle "GIT:" rather than "GIT: " during --compose Michael Witten
@ 2009-04-11 19:08         ` Michael Witten
  2009-04-11 19:08           ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Michael Witten
  2009-04-11 21:52           ` [PATCH RFC 06/10] send-email: References: should only reference what is actually sent Stephen Boyd
  0 siblings, 2 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

If someone responded with a negative (n|no) to the confirmation,
then the Message-ID of the discarded email is no longer used
in the References: header of subsequent emails.

Consequently, send_message() now returns 1 if the message was
sent and 0 otherwise.

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 git-send-email.perl |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 502f5af..d90c76e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -802,6 +802,10 @@ sub sanitize_address
 
 }
 
+# returns 1 of the message was sent, 0 otherwise.
+# In actuality, the whole program dies when a there
+# is an error sending a message.
+
 sub send_message
 {
 	my @recipients = unique_email_list(@to);
@@ -870,7 +874,7 @@ X-Mailer: git-send-email $gitversion
 		         default => $ask_default);
 		die "Send this email reply required" unless defined $_;
 		if (/^n/i) {
-			return;
+			return 0;
 		} elsif (/^q/i) {
 			cleanup_compose_files();
 			exit(0);
@@ -951,7 +955,7 @@ X-Mailer: git-send-email $gitversion
 		$smtp->data or die $smtp->message;
 		$smtp->datasend("$header\n$message") or die $smtp->message;
 		$smtp->dataend() or die $smtp->message;
-		$smtp->ok or die "Failed to send $subject\n".$smtp->message;
+		$smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message;
 	}
 	if ($quiet) {
 		printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
@@ -972,6 +976,8 @@ X-Mailer: git-send-email $gitversion
 			print "Result: OK\n";
 		}
 	}
+
+	return 1;
 }
 
 $reply_to = $initial_reply_to;
@@ -1132,10 +1138,10 @@ foreach my $t (@files) {
 
 	@cc = (@initial_cc, @cc);
 
-	send_message();
+	my $message_was_sent = send_message();
 
 	# set up for the next message
-	if ($chain_reply_to || !defined $reply_to || length($reply_to) == 0) {
+	if ($message_was_sent and $chain_reply_to || not defined $reply_to || length($reply_to) == 0) {
 		$reply_to = $message_id;
 		if (length $references > 0) {
 			$references .= "\n $message_id";
-- 
1.6.2.2.479.g2aec

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

* [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces
  2009-04-11 19:08         ` [PATCH RFC 06/10] send-email: References: should only reference what is actually sent Michael Witten
@ 2009-04-11 19:08           ` Michael Witten
  2009-04-11 19:08             ` [PATCH RFC 08/10] send-email: Add --sleep for email throttling Michael Witten
  2009-04-11 19:17             ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Sverre Rabbelier
  2009-04-11 21:52           ` [PATCH RFC 06/10] send-email: References: should only reference what is actually sent Stephen Boyd
  1 sibling, 2 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

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.

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 git-send-email.perl |  278 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 168 insertions(+), 110 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index d90c76e..4f0462f 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -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;
@@ -116,19 +124,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 };
@@ -192,29 +201,29 @@ 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 = (
-    "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,
+	"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
@@ -245,37 +254,38 @@ $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,
-		    "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" => \$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,
+	"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" => \$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"
@@ -404,29 +414,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}) {
@@ -574,10 +610,11 @@ EOT
 		} elsif (/^\n$/) {
 			$in_body = 1;
 			if ($need_8bit_cte) {
-				print C2 "MIME-Version: 1.0\n",
-					 "Content-Type: text/plain; ",
-					   "charset=utf-8\n",
-					 "Content-Transfer-Encoding: 8bit\n";
+				print C2
+					"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;
@@ -586,8 +623,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;
@@ -619,8 +656,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
@@ -640,8 +679,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++;
 }
@@ -669,7 +712,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*<?//;
@@ -809,18 +853,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));
@@ -869,9 +917,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 0;
@@ -906,9 +958,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');
@@ -1005,7 +1061,7 @@ foreach my $t (@files) {
 			chomp($header[$#header]);
 			s/^\s+/ /;
 			$header[$#header] .= $_;
-	    } else {
+		} else {
 			push(@header, $_);
 		}
 	}
@@ -1123,9 +1179,9 @@ foreach my $t (@files) {
 			}
 			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';
 			}
 		}
 	}
@@ -1133,7 +1189,9 @@ foreach my $t (@files) {
 	$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);
-- 
1.6.2.2.479.g2aec

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

* [PATCH RFC 08/10] send-email: Add --sleep for email throttling
  2009-04-11 19:08           ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Michael Witten
@ 2009-04-11 19:08             ` Michael Witten
  2009-04-11 19:08               ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Michael Witten
                                 ` (2 more replies)
  2009-04-11 19:17             ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Sverre Rabbelier
  1 sibling, 3 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

The --sleep option provides a means for specifying that there
should be a certain number of seconds of delay after sending
a certain number of emails; see Documentation/git-send-email.txt

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 Documentation/git-send-email.txt |   30 +++++++++++++++
 git-send-email.perl              |   74 +++++++++++++++++++++++++++++++++++---
 2 files changed, 99 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 12845d6..f0c2e7b 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -168,6 +168,36 @@ Automating
 	entire patch series. Default is the value of the 'sendemail.chainreplyto'
 	configuration value; if that is unspecified, default to --chain-reply-to.
 
+--sleep=<seconds>[,<burst>]::
+	This option specfies that send-email should sleep for <seconds>
+	after sending <burst> messages as quickly as possible; <seconds>
+	should be an integer >= 0 and <burst> should be an integer >= 1.
+	This mode of operation attacks 2 problems: email throttling and
+	arrival disorder. Default is the value of the 'sendemail.sleep'
+	configuration variable, or '0' if that does not exist.
++
+By default, send-email tries to send one patch per email as quickly as
+possible. Unfortunately, some email services restrict a user by refusing
+to send more than some maximum number of email messages, M, in a given
+period of seconds, S. This can be troublesome if the patch series has
+more than M patches, because the server will ultimately refuse to send
+some of them. In this case, simply pass '--sleep=S,M' or '--sleep S,M'
+or set sendemail.sleep to 'S,M'.
++
+Moreover, the emails often arrive at the final destination out of order;
+though send-email manipulates the date fields and usually chains subsequent
+emails via the In-Reply-To headers, some mail viewers nevertheless insist
+on presenting them by order of arrival. This may be mitigated by using
+something like '--sleep 60' (the equivalent of '--sleep 60,1'), so that
+there is a 60 second delay between sending each patch.
++
+*Note*: Because of varying routes and batching schemes, there is no delay
+that can guarantee the correct arrival order. Obviously, one solution is to
+choose an obscenely large number, so be prepared to run send-email in the
+background. Of course, spreading emails across time makes it more likely
+that unrelated email messages arrive between patches. Therefore, send-email
+warns you if both --sleep and --no-chain-reply-to are used.
+
 --identity=<id>::
 	A configuration identity. When given, causes values in the
 	'sendemail.<id>' subsection to take precedence over
diff --git a/git-send-email.perl b/git-send-email.perl
index 4f0462f..c26a1b5 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -77,6 +77,7 @@ git send-email [options] <file | directory | rev-list options >
     --smtp-ssl                     * Deprecated. Use '--smtp-encryption ssl'.
 
   Automating:
+    --sleep      <secs>[,<burst>]  * Delay <secs> every <burst> email(s).
     --identity               <id>  * Use the sendemail.<id> options.
     --cc-cmd            <command>  * Email Cc: via `<command> \$patch_path`
     --suppress-cc      <category>  * author, self, sob, cc, cccmd, body,
@@ -194,7 +195,7 @@ sub do_edit {
 }
 
 # Variables with corresponding config settings
-my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
+my ($sleep, $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);
@@ -210,6 +211,7 @@ my %config_bool_settings = (
 );
 
 my %config_settings = (
+	"sleep" => \$sleep,
 	"smtpserver" => \$smtp_server,
 	"smtpserverport" => \$smtp_server_port,
 	"smtpuser" => \$smtp_authuser,
@@ -262,6 +264,7 @@ my $rc = GetOptions(
 	"cc=s" => \@initial_cc,
 	"bcc=s" => \@bcclist,
 	"chain-reply-to!" => \$chain_reply_to,
+	"sleep=s" => \$sleep,
 	"smtp-server=s" => \$smtp_server,
 	"smtp-server-port=i" => \$smtp_server_port,
 	"smtp-user=s" => \$smtp_authuser,
@@ -334,6 +337,43 @@ foreach my $setting (values %config_bool_settings) {
 	${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]}));
 }
 
+#### Parse input
+
+my ($sleep_seconds, $sleep_burst);
+
+if (defined $sleep) {{
+
+	unless ($chain_reply_to) {
+
+		print "Both --sleep and --no-chain-reply-to are in effect.\n";
+		print "Therefore, it is much more likely that unrelated\n";
+		print "email messages will appear between any 2 of your\n";
+		print "patches.\n\n";
+
+		$_ = ask(
+			"How to proceed? ([q]uit | --[s]leep | --no-[c]hain | [n]either | [b]oth): ",
+			valid_re => qr/^(?:b|s|c|n|q)/i,
+			default => 'b'
+		);
+
+		/^b/                                               or
+		/^s/ and $chain_reply_to = 1                       or
+		/^c/ and $sleep = undef, last                      or
+		/^n/ and $chain_reply_to = 1, $sleep = undef, last or
+		/^q/ and exit;
+	}
+
+	$sleep =~ /^(\d+)(?:,(\d+))?$/
+		or  print "Should be '--sleep=<seconds>[,<burst>]', but got '--sleep=\"$sleep\"'\n"
+		and exit;
+
+	# Explicitly convert to integers to avoid repeated conversion:
+	# (<burst> = 0 is not defined, but let's be nice and absorb it)
+
+	$sleep_seconds = 0+$1;
+	$sleep_burst   = $2 ? 0+$2 : 1;
+}}
+
 # 'default' encryption is none -- this only prevents a warning
 $smtp_encryption = '' unless (defined $smtp_encryption);
 
@@ -1041,8 +1081,12 @@ $references = $initial_reply_to || '';
 $subject = $initial_subject;
 $message_num = 0;
 
-foreach my $t (@files) {
-	open(F,"<",$t) or die "can't open file $t";
+my $burst_count = $sleep_burst;
+my $time_of_last_message;
+
+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;
@@ -1151,7 +1195,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 = $_;
@@ -1198,7 +1242,27 @@ foreach my $t (@files) {
 
 	my $message_was_sent = send_message();
 
-	# set up for the next message
+	# Throttle the outgoing rate:
+
+	if ($sleep_seconds && $message_was_sent) {
+
+		$time_of_last_message = time;
+
+		unless (--$burst_count) {  # unless we can send more
+
+			$burst_count = $sleep_burst;
+
+			my $already_elapsed = time - $time_of_last_message;
+
+			if ($already_elapsed < $sleep_seconds && $index < $#files) {
+				my $this_long = $sleep_seconds - $already_elapsed;
+				while (($this_long -= sleep $this_long) > 0) {}
+			}
+		}
+	}
+
+	# set up for the next message:
+
 	if ($message_was_sent and $chain_reply_to || not defined $reply_to || length($reply_to) == 0) {
 		$reply_to = $message_id;
 		if (length $references > 0) {
-- 
1.6.2.2.479.g2aec

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

* [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message()
  2009-04-11 19:08             ` [PATCH RFC 08/10] send-email: Add --sleep for email throttling Michael Witten
@ 2009-04-11 19:08               ` Michael Witten
  2009-04-11 19:08                 ` [PATCH RFC 10/10] send-email: --compose takes optional argument to existing file Michael Witten
  2009-04-11 21:58                 ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Stephen Boyd
  2009-04-12  2:27               ` [PATCH RFC 08/10] send-email: Add --sleep for email throttling Jay Soffian
  2009-04-12  2:59               ` Michael Witten
  2 siblings, 2 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

Note that the output has been changed; the server return code
now appears after the `(Sendmail|Server):' line, rather than
after the headers.

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 Documentation/git-send-email.txt |    3 +-
 git-send-email.perl              |   39 +++++++++++++++++++++++--------------
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index f0c2e7b..07c831e 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -135,7 +135,8 @@ user is prompted for a password while the input is masked for privacy.
 	be specified by the 'sendemail.smtpserver' configuration
 	option; the built-in default is `/usr/sbin/sendmail` or
 	`/usr/lib/sendmail` if such program is available, or
-	`localhost` otherwise.
+	`127.0.0.1` otherwise. Also, if <host> is the empty string,
+	then a built-in default is used.
 
 --smtp-server-port=<port>::
 	Specifies a port different from the default port (SMTP
diff --git a/git-send-email.perl b/git-send-email.perl
index c26a1b5..e771720 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -196,7 +196,8 @@ sub do_edit {
 
 # Variables with corresponding config settings
 my ($sleep, $thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
-my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
+my ($smtp_server, $smtp_server_is_a_command);
+my ($smtp_server_port, $smtp_authuser, $smtp_encryption);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
 my ($validate, $confirm);
 my (@suppress_cc);
@@ -761,14 +762,18 @@ if (defined $initial_reply_to) {
 	$initial_reply_to = "<$initial_reply_to>" if $initial_reply_to ne '';
 }
 
-if (!defined $smtp_server) {
+if (defined $smtp_server and $smtp_server ne '') {
+	$smtp_server_is_a_command = ($smtp_server =~ m{^/});
+} else {
 	foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {
 		if (-x $_) {
 			$smtp_server = $_;
+			$smtp_server_is_a_command = 1;
 			last;
 		}
 	}
-	$smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*
+	$smtp_server_is_a_command = 0;
+	$smtp_server ||= '127.0.0.1';
 }
 
 if ($compose && $compose > 0) {
@@ -977,7 +982,7 @@ X-Mailer: git-send-email $gitversion
 
 	if ($dry_run) {
 		# We don't want to send the email.
-	} elsif ($smtp_server =~ m#^/#) {
+	} elsif ($smtp_server_is_a_command) {
 		my $pid = open my $sm, '|-';
 		defined $pid or die $!;
 		if (!$pid) {
@@ -1053,24 +1058,28 @@ X-Mailer: git-send-email $gitversion
 		$smtp->dataend() or die $smtp->message;
 		$smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message;
 	}
+
+	print 'Dry-' if $dry_run;
+
 	if ($quiet) {
-		printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
+		print "Sent $subject\n";
 	} else {
-		print (($dry_run ? "Dry-" : "")."OK. Log says:\n");
-		if ($smtp_server !~ m#^/#) {
+		print "OK. Log says:\n";
+
+		if ($smtp_server_is_a_command) {
+			print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
+			print "Result: OK\n";
+		} else {
 			print "Server: $smtp_server\n";
+
+			$dry_run and print "Result: OK\n" or
+			print "Result: ", $smtp->code, ' ', ($smtp->message =~ /\n([^\n]+\n)$/s), "\n";
+
 			print "MAIL FROM:<$raw_from>\n";
 			print "RCPT TO:".join(',',(map { "<$_>" } @recipients))."\n";
-		} else {
-			print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
 		}
+
 		print $header, "\n";
-		if ($smtp) {
-			print "Result: ", $smtp->code, ' ',
-				($smtp->message =~ /\n([^\n]+\n)$/s), "\n";
-		} else {
-			print "Result: OK\n";
-		}
 	}
 
 	return 1;
-- 
1.6.2.2.479.g2aec

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

* [PATCH RFC 10/10] send-email: --compose takes optional argument to existing file
  2009-04-11 19:08               ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Michael Witten
@ 2009-04-11 19:08                 ` Michael Witten
  2009-04-11 19:25                   ` Sverre Rabbelier
  2009-04-11 21:58                 ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Stephen Boyd
  1 sibling, 1 reply; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:08 UTC (permalink / raw)
  To: git

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, but it
is not deleted upon normal termination.

There are also a number of fixes to how the internals and
temporaries are handled.

Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 Documentation/git-send-email.txt |   39 ++++++--
 git-send-email.perl              |  190 ++++++++++++++++++++++++--------------
 2 files changed, 151 insertions(+), 78 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 07c831e..a2af3e5 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -60,17 +60,38 @@ The --bcc option must be repeated for each user you want on the bcc list.
 +
 The --cc option must be repeated for each user you want on the cc list.
 
---compose::
-	Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an
-	introductory message for the patch series.
+--compose[=<path>]::
+	Use `$GIT_EDITOR`, 'core.editor', `$VISUAL`, or `$EDITOR`, or
+	`vi` to edit an introductory message for the patch series. A
+	path for the intermediate composition may be given. If the path
+	doesn't exist, a file with default contents is created at the
+	path and opened for editing. If the path does exist, then the
+	file at that path is opened for editing as-is. If no path is
+	specified, a new temporary file is created with some default
+	contents. Upon the successful completion of send-email, all
+	temporary files are automatically unlinked (deleted). However,
+	if send-email is terminated by a trappable signal, then this
+	temporary file is not unlinked, and the user is informed of its
+	path.
 +
-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
-(what you type after the headers and a blank line) only contains blank
-(or GIT: prefixed) lines the summary won't be sent, but From, Subject,
-and In-Reply-To headers will be used unless they are removed.
+The user actually composes what will become a valid email message;
+therefore, the message must have the following form (as described in
+`RFC 822`):
 +
-Missing From or In-Reply-To headers will be prompted for.
+	<headers>
+	<blank line>
+	<body>
++
+In particular, `<headers>` must contain the "`Subject`" header. Once the
+user saves the message and quits the editor, this intermediate message is
+transformed into the final email message by removing all lines that begin
+with "`GIT:`". If the `<body>` of the final version is empty, then the
+email is not sent, and send-email proceeds as if '--compose' had never been
+used.
++
+The "`From`", "`Subject`", and "`In-Reply-To`" headers are taken directly
+from the message; missing "`From`" or "`In-Reply-To`" headers will be
+prompted for.
 
 --from=<address>::
 	Specify the sender of the emails.  This will default to
diff --git a/git-send-email.perl b/git-send-email.perl
index e771720..877732f 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -63,10 +63,9 @@ git send-email [options] <file | directory | rev-list options >
     --bcc               <address>  * Email Bcc:
     --subject            <string>  * Email "Subject:"
     --in-reply-to    <message-id>  * Email "In-Reply-To:"; include '<' and '>'.
+    --compose             [<path>] * Open an editor for introduction.
     --annotate                     * Review each patch that will be sent in
                                      an editor.
-    --compose                      * Open an editor for introduction.
-
   Sending:
     --envelope-sender   <address>  * Email envelope sender.
     --smtp-server          <host>  * Outgoing SMTP server to use.
@@ -173,7 +172,7 @@ if ($@) {
 # Behavior modification variables
 my ($quiet, $dry_run) = (0, 0);
 my $format_patch;
-my $compose_filename;
+my ($compose_filename, $compose_final_filename);
 
 # Handle interactive edition of files.
 my $multiedit;
@@ -239,16 +238,15 @@ sub signal_handler {
 	system "stty echo";
 
 	# tmp files from --compose
-	if (defined $compose_filename) {
-		if (-e $compose_filename) {
-			print "'$compose_filename' contains an intermediate version of the email you were composing.\n";
-		}
-		if (-e ($compose_filename . ".final")) {
-			print "'$compose_filename.final' contains the composed email.\n"
-		}
+	if (defined $compose_filename and -f $compose_filename) {
+		print "'$compose_filename' contains an intermediate version of the email you were composing.\n";
+	}
+
+	if (defined $compose_final_filename) {
+		unlink $compose_final_filename if defined $compose_final_filename;
 	}
 
-	exit;
+	exit 1;
 };
 
 $SIG{TERM} = \&signal_handler;
@@ -273,8 +271,8 @@ my $rc = GetOptions(
 	"smtp-ssl" => sub { $smtp_encryption = 'ssl' },
 	"smtp-encryption=s" => \$smtp_encryption,
 	"identity=s" => \$identity,
+	"compose:s" => \$compose,
 	"annotate" => \$annotate,
-	"compose" => \$compose,
 	"quiet" => \$quiet,
 	"cc-cmd=s" => \$cc_cmd,
 	"suppress-from!" => \$suppress_from,
@@ -596,36 +594,69 @@ sub get_patch_subject($) {
 	die "'Subject:' line expected in '$patch'";
 }
 
-if ($compose) {
-	# Note that this does not need to be secure, but we will make a small
-	# effort to have it be unique
-	$compose_filename = ($repo ?
-		tempfile(".gitsendemail.msg.XXXXXX", DIR => $repo->repo_path()) :
-		tempfile(".gitsendemail.msg.XXXXXX", DIR => "."))[1];
-	open(C,">",$compose_filename)
-		or die "Failed to open for writing $compose_filename: $!";
-
-
-	my $tpl_sender = $sender || $repoauthor || $repocommitter || '';
-	my $tpl_subject = $initial_subject || '';
-	my $tpl_reply_to = $initial_reply_to || '';
-
-	print C <<EOT;
-From $tpl_sender # This line is ignored.
-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:
-GIT: Clear the body content if you don't wish to send a summary.
-From: $tpl_sender
-Subject: $tpl_subject
-In-Reply-To: $tpl_reply_to
+if (defined $compose) {{
 
-EOT
-	for my $f (@files) {
-		print C "GIT: ", get_patch_subject($f), "\n";
+	# Some parameters for creating temporary files:
+
+	my $template = ".gitsendemail.msg.XXXXXX";
+	my @dir = (DIR => ($repo ? $repo->repo_path() : "."));
+	my @suffix = (SUFFIX => ".final");
+
+	# Figure out the file that the user should be editing:
+
+	my $compose_file;
+	my $needs_default_contents;
+
+	if ($compose eq '') { # if no path was given
+		$needs_default_contents = 1;
+		($compose_file, $compose_filename) = tempfile($template, @dir)
+			or die "--compose: Could not create temporary file for the user to edit: $!\n";
+	} else {
+		$compose_filename = $compose;
+		$needs_default_contents = not -f $compose_filename;
 	}
-	close(C);
+
+	# Fill in default contents if necessary:
+
+	if ($needs_default_contents) {
+
+		open $compose_file, ">", $compose_filename;
+
+		# For convenience:
+
+		local *STDOUT = $compose_file;
+
+		# Help the user out with some instruction and initial headers:
+
+		my $from = $sender || $repoauthor || $repocommitter || '';
+		my $subject = $initial_subject || '';
+		my $reply_to = $initial_reply_to || '';
+
+		print "From $from # This line is ignored.\n";
+		print "GIT:\n";
+		print "GIT: Lines beginning in 'GIT:' will be removed.\n";
+		print "GIT:\n";
+		print "GIT: Consider including an overall diffstat\n";
+		print "GIT: (git diff --stat) or table of contents\n";
+		print "GIT: (as provide below).\n";
+		print "GIT:\n";
+		print "GIT: Clear the body content if you decide not\n";
+		print "GIT: to send this message.\n";
+		print "GIT:\n";
+		print "GIT: Here are the <headers>:\n";
+		print "From: $from\n";
+		print "Subject: $subject\n";
+		print "In-Reply-To: $reply_to\n";
+		print "\n";
+		print "GIT: This is the first line of the <body>:\n";
+		print "\n";
+
+		for my $f (@files) {
+			print "GIT: ", get_patch_subject($f), "\n";
+		}
+	}
+
+	# Do the editing:
 
 	my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
 
@@ -635,23 +666,40 @@ EOT
 		do_edit($compose_filename);
 	}
 
-	open(C2,">",$compose_filename . ".final")
-		or die "Failed to open $compose_filename.final : " . $!;
+	# Now transform the user-edited introduction into something
+	# suitable for sending via email; the user's editor may have
+	# unlinked the original file and replaced it with an entirely
+	# new one. If this be the case, then it wouldn't do just to seek
+	# to the beginning and start reading, because then only the
+	# original content would be retrieved. Consequently, the file
+	# must be reopened to be safe (note, the original filehandle is
+	# closed automatically):
+
+	unless (-f $compose_filename) {
+		print "--compose: File '$compose_filename' doesn't exist; not sending.\n";
+		last;
+	}
+
+	open $compose_file, "<", $compose_filename
+		or die "--compose: Failed to open '$compose_filename' for reading: $!";
 
-	open(C,"<",$compose_filename)
-		or die "Failed to open $compose_filename : " . $!;
+	# Create the final version:
 
+	(my $compose_final_file, $compose_final_filename) = tempfile($template, @dir, @suffix)
+		or die "--compose: Could not create temporary file for final version: $!\n";
+
+	my ($subject, $reply_to, $from);
 	my $need_8bit_cte = file_has_nonascii($compose_filename);
 	my $in_body = 0;
 	my $summary_empty = 1;
-	while(<C>) {
+	while(<$compose_file>) {
 		next if m/^GIT:/;
 		if ($in_body) {
 			$summary_empty = 0 unless (/^\n$/);
 		} elsif (/^\n$/) {
 			$in_body = 1;
 			if ($need_8bit_cte) {
-				print C2
+				print $compose_final_file
 					"MIME-Version: 1.0\n",
 					"Content-Type: text/plain; ",
 					"charset=utf-8\n",
@@ -660,33 +708,31 @@ EOT
 		} elsif (/^MIME-Version:/i) {
 			$need_8bit_cte = 0;
 		} elsif (/^Subject:\s*(.+)\s*$/i) {
-			$initial_subject = $1;
-			my $subject = $initial_subject;
-			$_ = "Subject: " .
-				($subject =~ /[^[:ascii:]]/ ?
-				quote_rfc2047($subject) :
-				$subject) .
-				"\n";
+			$subject = $1;
+			next;
 		} elsif (/^In-Reply-To:\s*(.+)\s*$/i) {
-			$initial_reply_to = $1;
+			$reply_to = $1;
 			next;
 		} elsif (/^From:\s*(.+)\s*$/i) {
-			$sender = $1;
+			$from = $1;
 			next;
 		} elsif (/^(?:To|Cc|Bcc):/i) {
 			print "To/Cc/Bcc fields are not interpreted yet, they have been ignored\n";
 			next;
 		}
-		print C2 $_;
-	}
-	close(C);
-	close(C2);
 
-	if ($summary_empty) {
-		print "Summary email is empty, skipping it\n";
-		$compose = -1;
+		print $compose_final_file $_;
 	}
-} elsif ($annotate) {
+
+	print("Summary email is empty, skipping it.\n"), last if ($summary_empty);
+
+	$initial_subject = $subject;
+	$initial_reply_to = $reply_to;
+	$sender = $from;
+
+	unshift(@files, $compose_final_filename);
+
+}} elsif ($annotate) {
 	do_edit(@files);
 }
 
@@ -776,10 +822,6 @@ if (defined $smtp_server and $smtp_server ne '') {
 	$smtp_server ||= '127.0.0.1';
 }
 
-if ($compose && $compose > 0) {
-	@files = ($compose_filename . ".final", @files);
-}
-
 # Variables we set as part of the loop over files
 our ($message_id, %mail, $subject, $reply_to, $references, $message,
 	$needs_confirm, $message_num, $ask_default);
@@ -924,9 +966,12 @@ sub send_message
 	my $sanitized_sender = sanitize_address($sender);
 	make_message_id() unless defined($message_id);
 
+	my $has_non_ascii = ($subject =~ /[^[:ascii:]]/);
+	my $sanitized_subject = $has_non_ascii ? quote_rfc2047($subject) : $subject;
+
 	my $header = "From: $sanitized_sender
 To: $to${ccline}
-Subject: $subject
+Subject: $sanitized_subject
 Date: $date
 Message-Id: $message_id
 X-Mailer: git-send-email $gitversion
@@ -1286,7 +1331,14 @@ for (my $index = 0; $index < @files; $index++) {
 cleanup_compose_files();
 
 sub cleanup_compose_files() {
-	unlink($compose_filename, $compose_filename . ".final") if $compose;
+
+	if (defined $compose_final_filename) {
+		unlink $compose_final_filename;
+	}
+
+	if (defined $compose_filename and not $compose) {
+		unlink $compose_filename;
+	}
 }
 
 $smtp->quit if $smtp;
-- 
1.6.2.2.479.g2aec

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

* Re: [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and  spaces
  2009-04-11 19:08           ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Michael Witten
  2009-04-11 19:08             ` [PATCH RFC 08/10] send-email: Add --sleep for email throttling Michael Witten
@ 2009-04-11 19:17             ` Sverre Rabbelier
  2009-04-11 19:31               ` Michael Witten
  2009-04-13  1:49               ` Miles Bader
  1 sibling, 2 replies; 23+ messages in thread
From: Sverre Rabbelier @ 2009-04-11 19:17 UTC (permalink / raw)
  To: Michael Witten; +Cc: git

Heya,

On Sat, Apr 11, 2009 at 21:08, Michael Witten <mfwitten@gmail.com> wrote:
> +## 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.

Isn't this a bit overkill? In fact, isn't it overkill a lot?

-- 
Cheers,

Sverre Rabbelier

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

* Re: [PATCH RFC 10/10] send-email: --compose takes optional argument  to existing file
  2009-04-11 19:08                 ` [PATCH RFC 10/10] send-email: --compose takes optional argument to existing file Michael Witten
@ 2009-04-11 19:25                   ` Sverre Rabbelier
  2009-04-11 19:38                     ` Michael Witten
  0 siblings, 1 reply; 23+ messages in thread
From: Sverre Rabbelier @ 2009-04-11 19:25 UTC (permalink / raw)
  To: Michael Witten; +Cc: git

Heya,

On Sat, Apr 11, 2009 at 21:08, Michael Witten <mfwitten@gmail.com> wrote:
> Now, a user may specify an existing (in-progress) file to use as
> +with "`GIT:`". If the `<body>` of the final version is empty, then the
> +email is not sent, and send-email proceeds as if '--compose' had never been
> +used.

Ouch! Wouldn't it be better to abort instead? Allover git we abort on
empty commit messages and the like, why not here?

-- 
Cheers,

Sverre Rabbelier

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

* Re: [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and  spaces
  2009-04-11 19:17             ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Sverre Rabbelier
@ 2009-04-11 19:31               ` Michael Witten
  2009-04-13  1:49               ` Miles Bader
  1 sibling, 0 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:31 UTC (permalink / raw)
  To: Sverre Rabbelier; +Cc: git

On Sat, Apr 11, 2009 at 14:17, Sverre Rabbelier <srabbelier@gmail.com> wrote:
> Isn't this a bit overkill? In fact, isn't it overkill a lot?

;-D

In my experience... NO.

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

* Re: [PATCH RFC 10/10] send-email: --compose takes optional argument  to existing file
  2009-04-11 19:25                   ` Sverre Rabbelier
@ 2009-04-11 19:38                     ` Michael Witten
  0 siblings, 0 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-11 19:38 UTC (permalink / raw)
  To: Sverre Rabbelier; +Cc: git

On Sat, Apr 11, 2009 at 14:25, Sverre Rabbelier <srabbelier@gmail.com> wrote:
> Ouch! Wouldn't it be better to abort instead? Allover git we abort on
> empty commit messages and the like, why not here?

I was just following the original behavior. I don't really mind either way.

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

* Re: [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION
  2009-04-11 19:08 ` [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION Michael Witten
  2009-04-11 19:08   ` [PATCH RFC 03/10] send-email: Cleanup the usage text and docs a bit Michael Witten
@ 2009-04-11 21:42   ` Stephen Boyd
  1 sibling, 0 replies; 23+ messages in thread
From: Stephen Boyd @ 2009-04-11 21:42 UTC (permalink / raw)
  To: git

Michael Witten <mfwitten <at> gmail.com> writes:
> 
> There is now a comment block warning trespassers.

This patch and the previous have these comment block warnings which look ugly to
me. Maybe we should make a DocumentationGuidelines, in the same spirit as
CodingGuidelines where we can place these policies.

Also, the alphabetical ordering of patch 1 is nice, but if we want to do this we
should probably change every git-<command>.txt to be consistent.

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

* Re: [PATCH RFC 06/10] send-email: References: should only reference what is actually sent
  2009-04-11 19:08         ` [PATCH RFC 06/10] send-email: References: should only reference what is actually sent Michael Witten
  2009-04-11 19:08           ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Michael Witten
@ 2009-04-11 21:52           ` Stephen Boyd
  2009-04-11 22:42             ` Michael Witten
  1 sibling, 1 reply; 23+ messages in thread
From: Stephen Boyd @ 2009-04-11 21:52 UTC (permalink / raw)
  To: git

Michael Witten <mfwitten <at> gmail.com> writes:

> 
> +# returns 1 of the message was sent, 0 otherwise.

s/of/if/

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

* Re: [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message()
  2009-04-11 19:08               ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Michael Witten
  2009-04-11 19:08                 ` [PATCH RFC 10/10] send-email: --compose takes optional argument to existing file Michael Witten
@ 2009-04-11 21:58                 ` Stephen Boyd
  2009-04-11 22:13                   ` Michael Witten
  1 sibling, 1 reply; 23+ messages in thread
From: Stephen Boyd @ 2009-04-11 21:58 UTC (permalink / raw)
  To: git

Michael Witten <mfwitten <at> gmail.com> writes:

> 
>  	be specified by the 'sendemail.smtpserver' configuration
>  	option; the built-in default is `/usr/sbin/sendmail` or
>  	`/usr/lib/sendmail` if such program is available, or
> -	`localhost` otherwise.
> +	`127.0.0.1` otherwise. Also, if <host> is the empty string,
> +	then a built-in default is used.

Does this help anyone? localhost at least doesn't change when/if ipv6 is used,
whereas '127.0.0.1' is only for ipv4.

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

* Re: [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage  and send_message()
  2009-04-11 21:58                 ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Stephen Boyd
@ 2009-04-11 22:13                   ` Michael Witten
  0 siblings, 0 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-11 22:13 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: git

On Sat, Apr 11, 2009 at 16:58, Stephen Boyd <bebarino@gmail.com> wrote:
> Michael Witten <mfwitten <at> gmail.com> writes:
>
>>
>>       be specified by the 'sendemail.smtpserver' configuration
>>       option; the built-in default is `/usr/sbin/sendmail` or
>>       `/usr/lib/sendmail` if such program is available, or
>> -     `localhost` otherwise.
>> +     `127.0.0.1` otherwise. Also, if <host> is the empty string,
>> +     then a built-in default is used.
>
> Does this help anyone? localhost at least doesn't change when/if ipv6 is used,
> whereas '127.0.0.1' is only for ipv4.

Ah. Good point. I'll get rid of that change.

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

* Re: [PATCH RFC 06/10] send-email: References: should only reference  what is actually sent
  2009-04-11 21:52           ` [PATCH RFC 06/10] send-email: References: should only reference what is actually sent Stephen Boyd
@ 2009-04-11 22:42             ` Michael Witten
  0 siblings, 0 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-11 22:42 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: git

On Sat, Apr 11, 2009 at 16:52, Stephen Boyd <bebarino@gmail.com> wrote:
> Michael Witten <mfwitten <at> gmail.com> writes:
>
>>
>> +# returns 1 of the message was sent, 0 otherwise.
>
> s/of/if/

Woops! Thanks!

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

* Re: [PATCH RFC 08/10] send-email: Add --sleep for email throttling
  2009-04-11 19:08             ` [PATCH RFC 08/10] send-email: Add --sleep for email throttling Michael Witten
  2009-04-11 19:08               ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Michael Witten
@ 2009-04-12  2:27               ` Jay Soffian
  2009-04-12  2:59               ` Michael Witten
  2 siblings, 0 replies; 23+ messages in thread
From: Jay Soffian @ 2009-04-12  2:27 UTC (permalink / raw)
  To: Michael Witten; +Cc: git

On Sat, Apr 11, 2009 at 3:08 PM, Michael Witten <mfwitten@gmail.com> wrote:
> +if (defined $sleep) {{
> +}}

What's the double-brackets about?

j.

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

* Re: [PATCH RFC 08/10] send-email: Add --sleep for email throttling
  2009-04-11 19:08             ` [PATCH RFC 08/10] send-email: Add --sleep for email throttling Michael Witten
  2009-04-11 19:08               ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Michael Witten
  2009-04-12  2:27               ` [PATCH RFC 08/10] send-email: Add --sleep for email throttling Jay Soffian
@ 2009-04-12  2:59               ` Michael Witten
  2 siblings, 0 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-12  2:59 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

On Sat, Apr 11, 2009 at 21:27, Jay Soffian <jaysoffian@gmail.com> wrote:
> On Sat, Apr 11, 2009 at 3:08 PM, Michael Witten <mfwitten@gmail.com> wrote:
>> +if (defined $sleep) {{
>> +}}
>
> What's the double-brackets about?

The {} that form the true-body of the if statement don't actually
denote a block. The extra layer of {} is explicitly creating a block.
This is done, because in Perl, blocks can be thought of as loops that
execute one iteration, so you can use all of the loop flow-control
operators 'redo', 'last', and 'next'.

In this case, I wanted to use 'last' to jump out of --sleep setup
should the user decide to do so, because I think it's cleaner than a
goto or variable check or superfluous loop:

if (defined $sleep) {{

	unless ($chain_reply_to) {
		...
		/^b/                                               or
		/^s/ and $chain_reply_to = 1                       or
		/^c/ and $sleep = undef, last                      or  # forget --sleep was ever used
		/^n/ and $chain_reply_to = 1, $sleep = undef, last or  # forget --sleep was ever used
		/^q/ and exit;
	}
	...
}}
# last jumps to here

Anyway, this particular behavior was requested (and seems reasonable):

	http://marc.info/?l=git&m=123929919621279&w=2

Sincerely,
Michael Witten

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

* Re: [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and  spaces
  2009-04-11 19:17             ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Sverre Rabbelier
  2009-04-11 19:31               ` Michael Witten
@ 2009-04-13  1:49               ` Miles Bader
  2009-04-13  2:15                 ` Michael Witten
  1 sibling, 1 reply; 23+ messages in thread
From: Miles Bader @ 2009-04-13  1:49 UTC (permalink / raw)
  To: Sverre Rabbelier; +Cc: Michael Witten, git

Sverre Rabbelier <srabbelier@gmail.com> writes:
>> +## 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.
>
> Isn't this a bit overkill? In fact, isn't it overkill a lot?

"Bizarre" is the word I'd use...

[There are places to whine about whitespace conventions, but that place
isn't giant screaming comments in individual source files...]

-miles

-- 
Admiration, n. Our polite recognition of another's resemblance to ourselves.

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

* Re: [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and  spaces
  2009-04-13  1:49               ` Miles Bader
@ 2009-04-13  2:15                 ` Michael Witten
  0 siblings, 0 replies; 23+ messages in thread
From: Michael Witten @ 2009-04-13  2:15 UTC (permalink / raw)
  To: Miles Bader; +Cc: git

On Sun, Apr 12, 2009 at 20:49, Miles Bader <miles@gnu.org> wrote:
> Sverre Rabbelier <srabbelier@gmail.com> writes:
>>> +## 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.
>>
>> Isn't this a bit overkill? In fact, isn't it overkill a lot?
>
> "Bizarre" is the word I'd use...

Whatever you say, Master Bader.

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

end of thread, other threads:[~2009-04-13  2:17 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-11 19:08 [PATCH RFC 01/10] Docs: send-email: Put options back into alphabetical order Michael Witten
2009-04-11 19:08 ` [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION Michael Witten
2009-04-11 19:08   ` [PATCH RFC 03/10] send-email: Cleanup the usage text and docs a bit Michael Witten
2009-04-11 19:08     ` [PATCH RFC 04/10] send-email: --smtp-server-port should take an integer Michael Witten
2009-04-11 19:08       ` [PATCH RFC 05/10] send-email: Handle "GIT:" rather than "GIT: " during --compose Michael Witten
2009-04-11 19:08         ` [PATCH RFC 06/10] send-email: References: should only reference what is actually sent Michael Witten
2009-04-11 19:08           ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Michael Witten
2009-04-11 19:08             ` [PATCH RFC 08/10] send-email: Add --sleep for email throttling Michael Witten
2009-04-11 19:08               ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Michael Witten
2009-04-11 19:08                 ` [PATCH RFC 10/10] send-email: --compose takes optional argument to existing file Michael Witten
2009-04-11 19:25                   ` Sverre Rabbelier
2009-04-11 19:38                     ` Michael Witten
2009-04-11 21:58                 ` [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message() Stephen Boyd
2009-04-11 22:13                   ` Michael Witten
2009-04-12  2:27               ` [PATCH RFC 08/10] send-email: Add --sleep for email throttling Jay Soffian
2009-04-12  2:59               ` Michael Witten
2009-04-11 19:17             ` [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces Sverre Rabbelier
2009-04-11 19:31               ` Michael Witten
2009-04-13  1:49               ` Miles Bader
2009-04-13  2:15                 ` Michael Witten
2009-04-11 21:52           ` [PATCH RFC 06/10] send-email: References: should only reference what is actually sent Stephen Boyd
2009-04-11 22:42             ` Michael Witten
2009-04-11 21:42   ` [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION Stephen Boyd

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).