{"thread":{"id":"11198","subject":"[PATCH] send-email: Allow sleeping between sending mails","startedAt":"2007-12-08T17:12:07Z","lastAt":"2007-12-08T17:12:07Z","messageCount":1,"participants":["Dan Nicholson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"62422","messageId":"1197133927-32547-1-git-send-email-dbn.lists@gmail.com","threadId":"11198","inReplyTo":null,"subject":"[PATCH] send-email: Allow sleeping between sending mails","fromName":"Dan Nicholson","fromEmail":"dbn.lists@gmail.com","sentAt":"2007-12-08T17:12:07Z","receivedAt":"2007-12-08T17:12:07Z","isPatch":true,"sender":{"key":"dbn.lists@gmail.com","avatar":null},"body":"Sometimes when sending many mails, the thread appears out of order for\nthe recipient. This adds a simple workaround by sleeping between sending\nmails. This is controlled by the option --sleep, which defaults to 0.\n\nSince the perl builtin function sleep is used, only integer granularity\nis offered. GetOptions seems to perform the necessary checking for this.\n\nSigned-off-by: Dan Nicholson <dbn.lists@gmail.com>\n---\n Documentation/git-send-email.txt |    5 +++++\n git-send-email.perl              |   14 +++++++++++++-\n 2 files changed, 18 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 659215a..45341db 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -71,6 +71,11 @@ The --cc option must be repeated for each user you want on the cc list.\n         Default is the value of 'sendemail.signedoffcc' configuration value;\n         if that is unspecified, default to --signed-off-by-cc.\n \n+--sleep::\n+\tSpecify an integer number of seconds to sleep between sending\n+\tmails. This can help when sending many mails at once and they\n+\tappear out of order for the recipient. Defaults to 0.\n+\n --quiet::\n \tMake git-send-email less verbose.  One line per email should be\n \tall that is output.\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 76baa8e..a105306 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -100,6 +100,9 @@ Options:\n \n    --envelope-sender\tSpecify the envelope sender used to send the emails.\n \n+   --sleep        Specify an integer number of seconds to sleep between\n+                  sending mails. Defaults to 0.\n+\n EOT\n \texit(1);\n }\n@@ -158,6 +161,7 @@ my (@to,@cc,@initial_cc,@bcclist,@xh,\n \t$initial_reply_to,$initial_subject,@files,$author,$sender,$compose,$time);\n \n my $envelope_sender;\n+my $mail_index;\n \n # Example reply to:\n #$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';\n@@ -171,7 +175,7 @@ if ($@) {\n }\n \n # Behavior modification variables\n-my ($quiet, $dry_run) = (0, 0);\n+my ($quiet, $dry_run, $sleep_time) = (0, 0, 0);\n \n # Variables with corresponding config settings\n my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);\n@@ -222,6 +226,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"dry-run\" => \\$dry_run,\n \t\t    \"envelope-sender=s\" => \\$envelope_sender,\n \t\t    \"thread!\" => \\$thread,\n+\t\t    \"sleep=i\" => \\$sleep_time,\n \t );\n \n unless ($rc) {\n@@ -669,6 +674,7 @@ X-Mailer: git-send-email $gitversion\n $reply_to = $initial_reply_to;\n $references = $initial_reply_to || '';\n $subject = $initial_subject;\n+$mail_index = 0;\n \n foreach my $t (@files) {\n \topen(F,\"<\",$t) or die \"can't open file $t\";\n@@ -803,6 +809,12 @@ foreach my $t (@files) {\n \t\t\t$references = \"$message_id\";\n \t\t}\n \t}\n+\n+\t# sleep if requested and there are any mails left\n+\tif ($sleep_time > 0 && $mail_index < $#files) {\n+\t\tsleep $sleep_time;\n+\t}\n+\t$mail_index++;\n }\n \n if ($compose) {\n-- \n1.5.3.2\n"}]}