git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] send-mail: Add option to sleep between sending each email.
@ 2011-09-07 20:43 Georgi Chorbadzhiyski
  2011-09-08  8:43 ` Ramkumar Ramachandra
  0 siblings, 1 reply; 17+ messages in thread
From: Georgi Chorbadzhiyski @ 2011-09-07 20:43 UTC (permalink / raw)
  To: git

Sometimes when sending lots of changes it is not nice
to send emails as fast as possible. Of course you can
confirm each email after waiting couple of seconds but
this is not optimal. This patch adds --sleep option
to git-send-mail and corresponding sendmail.sleep config
variable to control how much seconds to wait between
sending each email. The default is 0 (not wait at all).

Signed-off-by: Georgi Chorbadzhiyski <gf@unixsol.org>
---
 Documentation/git-send-email.txt |    6 ++++++
 git-send-email.perl              |   13 ++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 327233c..2ceb69f 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -298,6 +298,9 @@ Default is the value of 'sendemail.confirm' configuration value; if that
 is unspecified, default to 'auto' unless any of the suppress options
 have been specified, in which case default to 'compose'.
 
+--sleep=<seconds>::
+	How many seconds to wait between sending each email.
+
 --dry-run::
 	Do everything except actually send the emails.
 
@@ -349,6 +352,9 @@ sendemail.confirm::
 	one of 'always', 'never', 'cc', 'compose', or 'auto'. See '--confirm'
 	in the previous section for the meaning of these values.
 
+sendemail.sleep::
+	Sets how many seconds to wait between sending each email.
+
 EXAMPLE
 -------
 Use gmail as the smtp server
diff --git a/git-send-email.perl b/git-send-email.perl
index 98ab33a..7239fd4 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -84,6 +84,7 @@ git send-email [options] <file | directory | rev-list options >
   Administering:
     --confirm               <str>  * Confirm recipients before sending;
                                      auto, cc, compose, always, or never.
+    --sleep                 <int>  * Sleep <int> seconds between sending mails.
     --quiet                        * Output one line of info per email.
     --dry-run                      * Don't actually send the emails.
     --[no-]validate                * Perform patch sanity checks. Default on.
@@ -195,7 +196,7 @@ my ($to_cmd, $cc_cmd);
 my ($smtp_server, $smtp_server_port, @smtp_server_options);
 my ($smtp_authuser, $smtp_encryption);
 my ($identity, $aliasfiletype, @alias_files, $smtp_domain);
-my ($validate, $confirm);
+my ($validate, $confirm, $sleep);
 my (@suppress_cc);
 my ($auto_8bit_encoding);
 
@@ -230,6 +231,7 @@ my %config_settings = (
     "envelopesender" => \$envelope_sender,
     "multiedit" => \$multiedit,
     "confirm"   => \$confirm,
+    "sleep" => \$sleep,
     "from" => \$sender,
     "assume8bitencoding" => \$auto_8bit_encoding,
 );
@@ -304,6 +306,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "suppress-cc=s" => \@suppress_cc,
 		    "signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
 		    "confirm=s" => \$confirm,
+		    "sleep:i" => \$sleep,
 		    "dry-run" => \$dry_run,
 		    "envelope-sender=s" => \$envelope_sender,
 		    "thread!" => \$thread,
@@ -405,6 +408,9 @@ if ($confirm_unconfigured) {
 die "Unknown --confirm setting: '$confirm'\n"
 	unless $confirm =~ /^(?:auto|cc|compose|always|never)/;
 
+# Set sleep's default value
+$sleep = 0 if (!defined $sleep);
+
 # Debugging, print out the suppressions.
 if (0) {
 	print "suppressions:\n";
@@ -1143,6 +1149,11 @@ X-Mailer: git-send-email $gitversion
 		}
 	}
 
+	if (!$dry_run && $sleep) {
+		print "Sleeping: $sleep second(s).\n" if (!$quiet);
+		sleep($sleep);
+	};
+
 	return 1;
 }
 
-- 
1.7.5.1

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

end of thread, other threads:[~2011-10-03 20:17 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-07 20:43 [PATCH] send-mail: Add option to sleep between sending each email Georgi Chorbadzhiyski
2011-09-08  8:43 ` Ramkumar Ramachandra
2011-09-08  9:03   ` Matthieu Moy
2011-09-08  9:28     ` Ramkumar Ramachandra
2011-09-08  9:35       ` Ramkumar Ramachandra
2011-09-08 10:44         ` Ramkumar Ramachandra
2011-09-08 10:57           ` Georgi Chorbadzhiyski
2011-09-08 11:15           ` Matthieu Moy
2011-09-08 13:58             ` Georgi Chorbadzhiyski
2011-09-08 14:07               ` Georgi Chorbadzhiyski
2011-10-03 20:17                 ` Jakub Narebski
2011-09-08 17:14                   ` Georgi Chorbadzhiyski
2011-09-08 17:12     ` Junio C Hamano
2011-09-08 20:50       ` Matthieu Moy
2011-09-09  2:12       ` mfwitten
2011-09-12  5:34       ` Ramkumar Ramachandra
2011-09-08  9:11   ` Georgi Chorbadzhiyski

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