git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] send-email: impose a delay while sending to appease GMail
@ 2018-03-25 18:28 Ævar Arnfjörð Bjarmason
  2018-03-25 18:28 ` [PATCH 1/2] send-email: add an option to impose delay sent E-Mails Ævar Arnfjörð Bjarmason
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-03-25 18:28 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Linux Kernel Mailing List,
	Ævar Arnfjörð Bjarmason

GMail doesn't sort E-Mail by the "Date" header, but by when the E-Mail
was received. As a result patches sent to the git ML and LKML (and
friends) show up out of order in GMail.

This series works around that issue by sleeping for 1 second between
sending E-Mails.

If you're on the LKML and wondering why you got this, I figured
feedback from the other big user (that I know of) of send-email would
be helpful.

Ævar Arnfjörð Bjarmason (2):
  send-email: add an option to impose delay sent E-Mails
  send-email: supply a --send-delay=1 by default

 Documentation/config.txt         | 17 ++++++++++
 Documentation/git-send-email.txt |  4 +++
 git-send-email.perl              | 15 +++++++--
 t/t9001-send-email.sh            | 55 ++++++++++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 2 deletions(-)

-- 
2.16.2.804.g6dcf76e118


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

* [PATCH 1/2] send-email: add an option to impose delay sent E-Mails
  2018-03-25 18:28 [PATCH 0/2] send-email: impose a delay while sending to appease GMail Ævar Arnfjörð Bjarmason
@ 2018-03-25 18:28 ` Ævar Arnfjörð Bjarmason
  2018-03-25 18:28 ` [PATCH 2/2] send-email: supply a --send-delay=1 by default Ævar Arnfjörð Bjarmason
  2018-08-14 18:15 ` [PATCH v2] send-email: add an option to impose delay sent E-Mails Ævar Arnfjörð Bjarmason
  2 siblings, 0 replies; 14+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-03-25 18:28 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Linux Kernel Mailing List,
	Ævar Arnfjörð Bjarmason

Add a --send-delay option with a corresponding sendemail.smtpSendDelay
configuration variable. When set to e.g. 2, this causes send-email to
sleep 2 seconds before sending the next E-Mail. We'll only sleep
between sends, not before the first send, or after the last.

This option is useful because certain popular E-Mail clients
completely ignore the "Date" header, which format-patch is careful to
set such that the patches will be displayed in order, and instead sort
by the time the E-mail was received.

Google's GMail is a good example of such a client. It ostensibly sorts
by some approximation of received time (although not by any "Received"
header). It's more usual than not to see patches showing out of order
in GMail. To take a few examples of orders seen on recent patches on
the Git mailing list:

    1 -> 3 -> 4 -> 2 -> 8 -> 7 (completion by Nguyễn Thái Ngọc Duy)
    2 -> 0 -> 1 -> 3 (pack search by Derrick Stolee)
    3 -> 2 -> 1 (fast-import by Jameson Miller)
    2 -> 3 -> 1 -> 5 -> 4 -> 6 (diff-highlight by Jeff King)

My own patches to Git are always in order because this bothers me
enough that I never use the "all" option to send-email, instead I wait
a second and manually type "y" for each one, so I have years of
anecdotal data showing that this works with GMail. This new option
will allow me to set a config to do what I've been doing manually.

I've also noticed that E-Mail from some other contributors tends to be
in order, e.g. Michael Haggerty's usually are. When I asked him about
he just uses the "all" option, but digging further revealed that the
details of his mail routing were imposing a similar delay, so his
mails similarly arrived at Google with some delay.

The reason to add the new "X-Mailer-Send-Delay" header is to make it
easy to tell what the imposed delay was, if any. A subsequent change
will seek to make this option the default, being able to see from the
headers how long the sleep was.

The reason for why the getopt format is "send-delay=s" instead of
"send-delay=d" is because we're doing manual validation of the value
we get passed, which getopt would corrupt in cases of e.g. float
values before we could show a sensible error message.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/config.txt         |  6 ++++
 Documentation/git-send-email.txt |  4 +++
 git-send-email.perl              | 14 ++++++--
 t/t9001-send-email.sh            | 55 ++++++++++++++++++++++++++++++++
 4 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index ce9102cea8..f155d349c0 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -3068,6 +3068,12 @@ sendemail.smtpReloginDelay::
 	Seconds wait before reconnecting to smtp server.
 	See also the `--relogin-delay` option of linkgit:git-send-email[1].
 
+sendemail.smtpSendDelay::
+	Seconds wait in between message sending before sending another
+	message. Set it to 0 to impose no extra delay, defaults to 0.
++
+See also the `--send-delay` option of linkgit:git-send-email[1].
+
 showbranch.default::
 	The default set of branches for linkgit:git-show-branch[1].
 	See linkgit:git-show-branch[1].
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 71ef97ba9b..169ad78a2b 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -268,6 +268,10 @@ must be used for each option.
 	with --batch-size option.  Defaults to the `sendemail.smtpReloginDelay`
 	configuration variable.
 
+--send-delay=<int>::
+	Wait $<int> between sending emails. Defaults to the
+	`sendemail.smtpSendDelay` configuration variable.
+
 Automating
 ~~~~~~~~~~
 
diff --git a/git-send-email.perl b/git-send-email.perl
index 2fa7818ca9..013277ede2 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -89,6 +89,7 @@ git send-email --dump-aliases
     --batch-size            <int>  * send max <int> message per connection.
     --relogin-delay         <int>  * delay <int> seconds between two successive login.
                                      This option can only be used with --batch-size
+    --send-delay            <int>  * ensure that <int> seconds pass between two successive sends.
 
   Automating:
     --identity              <str>  * Use the sendemail.<id> options.
@@ -225,7 +226,7 @@ my ($cover_cc, $cover_to);
 my ($to_cmd, $cc_cmd);
 my ($smtp_server, $smtp_server_port, @smtp_server_options);
 my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);
-my ($batch_size, $relogin_delay);
+my ($batch_size, $relogin_delay, $send_delay);
 my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);
 my ($validate, $confirm);
 my (@suppress_cc);
@@ -259,6 +260,7 @@ my %config_settings = (
     "smtpauth" => \$smtp_auth,
     "smtpbatchsize" => \$batch_size,
     "smtprelogindelay" => \$relogin_delay,
+    "smtpsenddelay" => \$send_delay,
     "to" => \@initial_to,
     "tocmd" => \$to_cmd,
     "cc" => \@initial_cc,
@@ -373,6 +375,7 @@ $rc = GetOptions(
 		    "no-xmailer" => sub {$use_xmailer = 0},
 		    "batch-size=i" => \$batch_size,
 		    "relogin-delay=i" => \$relogin_delay,
+		    "send-delay=s" => \$send_delay,
 	 );
 
 usage() if $help;
@@ -484,6 +487,8 @@ if ($confirm_unconfigured) {
 };
 die sprintf(__("Unknown --confirm setting: '%s'\n"), $confirm)
 	unless $confirm =~ /^(?:auto|cc|compose|always|never)/;
+die sprintf(__("Invalid --send-delay setting: '%s'\n"), $send_delay)
+	if defined $send_delay and $send_delay !~ /^[0-9]+$/s;
 
 # Debugging, print out the suppressions.
 if (0) {
@@ -1552,7 +1557,8 @@ $references = $initial_in_reply_to || '';
 $subject = $initial_subject;
 $message_num = 0;
 
-foreach my $t (@files) {
+foreach my $i (0 .. $#files) {
+	my $t = $files[$i];
 	open my $fh, "<", $t or die sprintf(__("can't open file %s"), $t);
 
 	my $author = undef;
@@ -1732,6 +1738,10 @@ foreach my $t (@files) {
 	if (defined $xfer_encoding or $has_content_type) {
 		unshift @xh, 'MIME-Version: 1.0' unless $has_mime_version;
 	}
+	if ($send_delay && $i > 0) {
+		push @xh, "X-Mailer-Send-Delay: $send_delay";
+		sleep $send_delay;
+	}
 
 	$needs_confirm = (
 		$confirm eq "always" or
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index e80eacbb1b..fafa61c5d6 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1702,6 +1702,61 @@ test_expect_success '--dump-aliases must be used alone' '
 	test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
 '
 
+test_expect_success '--send-delay expects whole non-negative seconds' '
+	test_must_fail git send-email --send-delay=-1 HEAD~ 2>errors &&
+	test_i18ngrep "Invalid --send-delay setting" errors &&
+	test_must_fail git send-email --send-delay=1.5 HEAD~ 2>errors &&
+	test_i18ngrep "Invalid --send-delay setting" errors &&
+	test_must_fail git -c sendemail.smtpSendDelay=-1 send-email HEAD~ 2>errors &&
+	test_i18ngrep "Invalid --send-delay setting" errors &&
+	test_must_fail git -c sendemail.smtpSendDelay=1.5 send-email HEAD~ 2>errors &&
+	test_i18ngrep "Invalid --send-delay setting" errors
+'
+
+test_expect_success $PREREQ "there is no default --send-delay" '
+	clean_fake_sendmail &&
+	rm -fr outdir &&
+	git format-patch -3 -o outdir &&
+	git send-email \
+		--from="Example <nobody@example.com>" \
+		--to=nobody@example.com \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		outdir/*.patch \
+		2>stderr >stdout &&
+	test $(grep -c "X-Mailer:" stdout) = 3 &&
+	test $(grep -c "X-Mailer-Send-Delay:" stdout) = 0
+'
+
+test_expect_success $PREREQ '--send-delay adds a X-Mailer-Send-Delay header to affected E-Mails' '
+	clean_fake_sendmail &&
+	rm -fr outdir &&
+	git format-patch -3 -o outdir &&
+	git send-email \
+		--from="Example <nobody@example.com>" \
+		--to=nobody@example.com \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		--send-delay=2 \
+		outdir/*.patch \
+		2>stderr >stdout &&
+	test $(grep -c "X-Mailer:" stdout) = 3 &&
+	test $(grep -c "X-Mailer-Send-Delay:" stdout) = 2
+'
+
+test_expect_success $PREREQ '--send-delay=0 disables any imposed delay on E-Mail sending' '
+	clean_fake_sendmail &&
+	rm -fr outdir &&
+	git format-patch -3 -o outdir &&
+	git -c sendemail.smtpSendDelay=3 send-email \
+		--from="Example <nobody@example.com>" \
+		--to=nobody@example.com \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		--send-delay=0 \
+		outdir/*.patch \
+		2>stderr >stdout &&
+	test $(grep -c "X-Mailer:" stdout) = 3 &&
+	test $(grep -c "X-Mailer-Send-Delay:" stdout) = 0
+'
+
 test_sendmail_aliases () {
 	msg="$1" && shift &&
 	expect="$@" &&
-- 
2.16.2.804.g6dcf76e118


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

* [PATCH 2/2] send-email: supply a --send-delay=1 by default
  2018-03-25 18:28 [PATCH 0/2] send-email: impose a delay while sending to appease GMail Ævar Arnfjörð Bjarmason
  2018-03-25 18:28 ` [PATCH 1/2] send-email: add an option to impose delay sent E-Mails Ævar Arnfjörð Bjarmason
@ 2018-03-25 18:28 ` Ævar Arnfjörð Bjarmason
  2018-03-25 21:01   ` brian m. carlson
  2018-03-26  0:11   ` Eric Sunshine
  2018-08-14 18:15 ` [PATCH v2] send-email: add an option to impose delay sent E-Mails Ævar Arnfjörð Bjarmason
  2 siblings, 2 replies; 14+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-03-25 18:28 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Linux Kernel Mailing List,
	Ævar Arnfjörð Bjarmason

The earlier change to add this option described the problem this
option is trying to solve.

This turns it on by default with a value of 1 second, which'll
hopefully solve it, and if not user reports as well as the
X-Mailer-Send-Delay header should help debug it.

I think the trade-off of slowing down E-Mail sending to turn this on
makes sense because:

 * GMail is a really common client, git.git's own unique authors by
   %aE are ~30% @gmail.com, ~20% for linux.git. That's just patch
   submitters, my guess is this it's much more common among those who
   mostly read the list, and those users who aren't using mu4e / mutt
   etc. anyway.

 * There's really no point in having this feature at all if it's not
   made the default, since the entire point is to be able to read a
   list like the git ML or the LKML and have patches from others show
   up in order.

 * I don't think anyone's really sensitive to the sending part of
   send-email taking longer. You just choose "all" and then switch to
   another terminal while it does its thing if you have a huge series,
   and for 1-3 patches I doubt anyone would notice this anyway.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/config.txt | 13 ++++++++++++-
 git-send-email.perl      |  1 +
 t/t9001-send-email.sh    |  4 ++--
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index f155d349c0..bd578642c1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -3070,7 +3070,18 @@ sendemail.smtpReloginDelay::
 
 sendemail.smtpSendDelay::
 	Seconds wait in between message sending before sending another
-	message. Set it to 0 to impose no extra delay, defaults to 0.
+	message. Set it to 0 to impose no extra delay, defaults to 1
+	to wait 1 second.
++
+The reason for imposing a default delay is because certain popular
+E-Mail clients such as Google's GMail completely ignore the "Date"
+header, which format-patch is careful to set such that the patches
+will be displayed in order, and instead sort by the time the E-mail
+was received.
++
+This causes sent E-Mail to be shown completely out of order in such
+clients, imposing the delay is a workaround that should usually work
+(although it's by no means guaranteed).
 +
 See also the `--send-delay` option of linkgit:git-send-email[1].
 
diff --git a/git-send-email.perl b/git-send-email.perl
index 013277ede2..ddbc44f1c9 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -489,6 +489,7 @@ die sprintf(__("Unknown --confirm setting: '%s'\n"), $confirm)
 	unless $confirm =~ /^(?:auto|cc|compose|always|never)/;
 die sprintf(__("Invalid --send-delay setting: '%s'\n"), $send_delay)
 	if defined $send_delay and $send_delay !~ /^[0-9]+$/s;
+$send_delay = 1 unless defined $send_delay;
 
 # Debugging, print out the suppressions.
 if (0) {
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index fafa61c5d6..1580e00fce 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1713,7 +1713,7 @@ test_expect_success '--send-delay expects whole non-negative seconds' '
 	test_i18ngrep "Invalid --send-delay setting" errors
 '
 
-test_expect_success $PREREQ "there is no default --send-delay" '
+test_expect_success $PREREQ "there is a default --send-delay" '
 	clean_fake_sendmail &&
 	rm -fr outdir &&
 	git format-patch -3 -o outdir &&
@@ -1724,7 +1724,7 @@ test_expect_success $PREREQ "there is no default --send-delay" '
 		outdir/*.patch \
 		2>stderr >stdout &&
 	test $(grep -c "X-Mailer:" stdout) = 3 &&
-	test $(grep -c "X-Mailer-Send-Delay:" stdout) = 0
+	test $(grep -c "X-Mailer-Send-Delay:" stdout) = 2
 '
 
 test_expect_success $PREREQ '--send-delay adds a X-Mailer-Send-Delay header to affected E-Mails' '
-- 
2.16.2.804.g6dcf76e118


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

* Re: [PATCH 2/2] send-email: supply a --send-delay=1 by default
  2018-03-25 18:28 ` [PATCH 2/2] send-email: supply a --send-delay=1 by default Ævar Arnfjörð Bjarmason
@ 2018-03-25 21:01   ` brian m. carlson
  2018-03-25 22:01     ` Ævar Arnfjörð Bjarmason
  2018-03-26  1:48     ` Junio C Hamano
  2018-03-26  0:11   ` Eric Sunshine
  1 sibling, 2 replies; 14+ messages in thread
From: brian m. carlson @ 2018-03-25 21:01 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 2591 bytes --]

On Sun, Mar 25, 2018 at 06:28:03PM +0000, Ævar Arnfjörð Bjarmason wrote:
> The earlier change to add this option described the problem this
> option is trying to solve.
> 
> This turns it on by default with a value of 1 second, which'll
> hopefully solve it, and if not user reports as well as the
> X-Mailer-Send-Delay header should help debug it.
> 
> I think the trade-off of slowing down E-Mail sending to turn this on
> makes sense because:
> 
>  * GMail is a really common client, git.git's own unique authors by
>    %aE are ~30% @gmail.com, ~20% for linux.git. That's just patch
>    submitters, my guess is this it's much more common among those who
>    mostly read the list, and those users who aren't using mu4e / mutt
>    etc. anyway.
> 
>  * There's really no point in having this feature at all if it's not
>    made the default, since the entire point is to be able to read a
>    list like the git ML or the LKML and have patches from others show
>    up in order.
> 
>  * I don't think anyone's really sensitive to the sending part of
>    send-email taking longer. You just choose "all" and then switch to
>    another terminal while it does its thing if you have a huge series,
>    and for 1-3 patches I doubt anyone would notice this anyway.

I'm not sure that this is going to have the effect you want it to have.
Let me give an example to demonstrate why.

If I send a series to the list, in order for this to work, you need my
SMTP server (Postfix) to essentially send mails slowly enough to
vger.kernel.org (ZMailer) that it doesn't batch them when it sends them
to GMail.  The problem is that with my mail server, due to filtering and
such, already takes at least a second to accept, process, and relay
submitted messages.  vger still batched them and delivered them back to
me out of order.  This will be even worse with large series.

You are also assuming that my mail server will not have batched them and
delivered them out of order, which it might well do, since Postfix uses
a connection cache to machines that don't do STARTTLS (which, much to my
annoyance, vger doesn't offer).

In short, I don't think this is going to be especially helpful because
it won't change the status quo for a lot of senders.  You'd have to
insert some significant delay in order to get the effect you desire, and
even then things could still be delivered out of order.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 867 bytes --]

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

* Re: [PATCH 2/2] send-email: supply a --send-delay=1 by default
  2018-03-25 21:01   ` brian m. carlson
@ 2018-03-25 22:01     ` Ævar Arnfjörð Bjarmason
  2018-03-28  1:26       ` Eric Wong
  2018-03-26  1:48     ` Junio C Hamano
  1 sibling, 1 reply; 14+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-03-25 22:01 UTC (permalink / raw)
  To: brian m. carlson
  Cc: git, Junio C Hamano, Linux Kernel Mailing List, Eric Wong


On Sun, Mar 25 2018, brian m. carlson wrote:

> On Sun, Mar 25, 2018 at 06:28:03PM +0000, Ævar Arnfjörð Bjarmason wrote:
>> The earlier change to add this option described the problem this
>> option is trying to solve.
>>
>> This turns it on by default with a value of 1 second, which'll
>> hopefully solve it, and if not user reports as well as the
>> X-Mailer-Send-Delay header should help debug it.
>>
>> I think the trade-off of slowing down E-Mail sending to turn this on
>> makes sense because:
>>
>>  * GMail is a really common client, git.git's own unique authors by
>>    %aE are ~30% @gmail.com, ~20% for linux.git. That's just patch
>>    submitters, my guess is this it's much more common among those who
>>    mostly read the list, and those users who aren't using mu4e / mutt
>>    etc. anyway.
>>
>>  * There's really no point in having this feature at all if it's not
>>    made the default, since the entire point is to be able to read a
>>    list like the git ML or the LKML and have patches from others show
>>    up in order.
>>
>>  * I don't think anyone's really sensitive to the sending part of
>>    send-email taking longer. You just choose "all" and then switch to
>>    another terminal while it does its thing if you have a huge series,
>>    and for 1-3 patches I doubt anyone would notice this anyway.
>
> I'm not sure that this is going to have the effect you want it to have.
> Let me give an example to demonstrate why.
>
> If I send a series to the list, in order for this to work, you need my
> SMTP server (Postfix) to essentially send mails slowly enough to
> vger.kernel.org (ZMailer) that it doesn't batch them when it sends them
> to GMail.  The problem is that with my mail server, due to filtering and
> such, already takes at least a second to accept, process, and relay
> submitted messages.  vger still batched them and delivered them back to
> me out of order.  This will be even worse with large series.
>
> You are also assuming that my mail server will not have batched them and
> delivered them out of order, which it might well do, since Postfix uses
> a connection cache to machines that don't do STARTTLS (which, much to my
> annoyance, vger doesn't offer).
>
> In short, I don't think this is going to be especially helpful because
> it won't change the status quo for a lot of senders.  You'd have to
> insert some significant delay in order to get the effect you desire, and
> even then things could still be delivered out of order.

Good point. I also see that (via git log --author=Ævar --grep='^\[PATCH
') that this series itself arrived out of order (0 -> 2 -> 1), but I
don't know to what extent public-inbox itself might be batching things.

It would be interesting to get reports from other GMail users as to what
order these mails were shown in, but I think as soon as they're replied
to that info's gone, at least for 2/2, which is the potentially out of
order one in this case.

In general I realize that this won't be a general solution that'll work
in all cases. E.g. I have a local SMTP on my laptop, if I'm on a plane
it wouldn't matter if the delay was 2 hours, it would be batched up
locally and sent all at once.

I was hoping we could find some sweet spot where the systems along the
way (common smtpd's, majordomo, public-inbox's git repo) would as a
result get this right most of the time for the purposes of appeasing
this really common mail client, but maybe that's not going to work out.

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

* Re: [PATCH 2/2] send-email: supply a --send-delay=1 by default
  2018-03-25 18:28 ` [PATCH 2/2] send-email: supply a --send-delay=1 by default Ævar Arnfjörð Bjarmason
  2018-03-25 21:01   ` brian m. carlson
@ 2018-03-26  0:11   ` Eric Sunshine
  2018-03-26  1:56     ` Junio C Hamano
  1 sibling, 1 reply; 14+ messages in thread
From: Eric Sunshine @ 2018-03-26  0:11 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Git List, Junio C Hamano, Linux Kernel Mailing List

On Sun, Mar 25, 2018 at 2:28 PM, Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> The earlier change to add this option described the problem this
> option is trying to solve.
>
> This turns it on by default with a value of 1 second, which'll
> hopefully solve it, and if not user reports as well as the
> X-Mailer-Send-Delay header should help debug it.
> [...]
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> @@ -3070,7 +3070,18 @@ sendemail.smtpReloginDelay::
>  sendemail.smtpSendDelay::
>         Seconds wait in between message sending before sending another
> -       message. Set it to 0 to impose no extra delay, defaults to 0.
> +       message. Set it to 0 to impose no extra delay, defaults to 1
> +       to wait 1 second.
> ++
> +The reason for imposing a default delay is because certain popular
> +E-Mail clients such as Google's GMail completely ignore the "Date"
> +header, which format-patch is careful to set such that the patches
> +will be displayed in order, and instead sort by the time the E-mail
> +was received.

A minor point: Are you sure that it's git-format-patch that's being
careful about arranging Date: to display in the desired order, and not
git-send-email? Looking at old patches I still have hanging around
which were created with git-format-patch, I see the Date: headers are
wildly out of order, presumably because the date is taken from
Author-Date: and the patches were heavily rebased.

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

* Re: [PATCH 2/2] send-email: supply a --send-delay=1 by default
  2018-03-25 21:01   ` brian m. carlson
  2018-03-25 22:01     ` Ævar Arnfjörð Bjarmason
@ 2018-03-26  1:48     ` Junio C Hamano
  1 sibling, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2018-03-26  1:48 UTC (permalink / raw)
  To: brian m. carlson
  Cc: Ævar Arnfjörð Bjarmason, git,
	Linux Kernel Mailing List

"brian m. carlson" <sandals@crustytoothpaste.net> writes:

> I'm not sure that this is going to have the effect you want it to have.
> Let me give an example to demonstrate why.
> ...
> In short, I don't think this is going to be especially helpful because
> it won't change the status quo for a lot of senders.  You'd have to
> insert some significant delay in order to get the effect you desire, and
> even then things could still be delivered out of order.

Thanks for explaining it clearly.

In the past on this list those who do not get the store-and-forward
nature of e-mail transport have brought this up a few times, but
this approach fundamentally do not work, at least for the purpose of
forcing ordering of messages at the receiving end.


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

* Re: [PATCH 2/2] send-email: supply a --send-delay=1 by default
  2018-03-26  0:11   ` Eric Sunshine
@ 2018-03-26  1:56     ` Junio C Hamano
  0 siblings, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2018-03-26  1:56 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Ævar Arnfjörð Bjarmason, Git List,
	Linux Kernel Mailing List

Eric Sunshine <sunshine@sunshineco.com> writes:

> A minor point: Are you sure that it's git-format-patch that's being
> careful about arranging Date: to display in the desired order, and not
> git-send-email? Looking at old patches I still have hanging around
> which were created with git-format-patch, I see the Date: headers are
> wildly out of order, presumably because the date is taken from
> Author-Date: and the patches were heavily rebased.

send-email uses the current time as the timestamp it lets MTA to see
(and for a N-patch series, the first patch gets current time minus
N, and later patches get newer timestamps with 1 second increment).

The Date: field in the input file to the command has nothing to
participate in this process; sending a series that has patches that
have been shuffled with "rebase -i" would still give older timestamp
to the earlier message while sending the series out.

That is sufficient for any MUA that is capable of sorting the
messages in the sender's timestamp order; even though there is no
way to force the actual order in which an MTA on the receiving end
sees the messages, it is not necessary and it would not help X-<.

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

* Re: [PATCH 2/2] send-email: supply a --send-delay=1 by default
  2018-03-25 22:01     ` Ævar Arnfjörð Bjarmason
@ 2018-03-28  1:26       ` Eric Wong
  0 siblings, 0 replies; 14+ messages in thread
From: Eric Wong @ 2018-03-28  1:26 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: brian m. carlson, git, Junio C Hamano, Linux Kernel Mailing List

Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> Good point. I also see that (via git log --author=Ævar --grep='^\[PATCH
> ') that this series itself arrived out of order (0 -> 2 -> 1), but I
> don't know to what extent public-inbox itself might be batching things.

public-inbox doesn't batch, aside from when the
public-inbox-watch process gets restarted and needs to catch up
using readdir.  Once it's done catching up with readdir, it
gets into an inotify loop which injects messages in the order
the MTA (or offlineimap) puts them in a Maildir.

Right now, public-inbox only sorts by Date: header in the mail.

The next Xapian schema revision of public-inbox will use
internally sorts search results(*) by the date in the newest
Received: header.  That is analogous to git committer date.  The
displayed message date will still be sorted by the Date: header
(analogous to git author date); since git-send-email already
alters the Date: in a series for sorting.

This allow messages/threads which are actually new get bumped to
the top of the homepage; regardless of how wrong the original
sender's clock was.

It should help prevent kernel developers from crafting message
dates with optimization for classic^Wextra reviews in mind :)


(*) all the look-at-a-bunch-of-messages operations, including
    the landing page (e.g. https://public-inbox.org/git/)
    is a Xapian search query, nowadays; but "git log"

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

* [PATCH v2] send-email: add an option to impose delay sent E-Mails
  2018-03-25 18:28 [PATCH 0/2] send-email: impose a delay while sending to appease GMail Ævar Arnfjörð Bjarmason
  2018-03-25 18:28 ` [PATCH 1/2] send-email: add an option to impose delay sent E-Mails Ævar Arnfjörð Bjarmason
  2018-03-25 18:28 ` [PATCH 2/2] send-email: supply a --send-delay=1 by default Ævar Arnfjörð Bjarmason
@ 2018-08-14 18:15 ` Ævar Arnfjörð Bjarmason
  2018-08-14 18:39   ` Stefan Beller
  2018-08-14 18:45   ` Eric Wong
  2 siblings, 2 replies; 14+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-08-14 18:15 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, brian m . carlson, Eric Wong, Eric Sunshine,
	Ævar Arnfjörð Bjarmason

Add a --send-delay option with a corresponding sendemail.smtpSendDelay
configuration variable. When set to e.g. 2, this causes send-email to
sleep 2 seconds before sending the next E-Mail. We'll only sleep
between sends, not before the first send, or after the last.

This option has two uses. Firstly, to be able to Ctrl+C a long send
with "all" if you have a change of heart. Secondly, as a hack in some
mail setups to, with a sufficiently high delay, force the receiving
client to sort the E-Mails correctly.

Some popular E-Mail clients completely ignore the "Date" header, which
format-patch is careful to set such that the patches will be displayed
in order, and instead sort by the time the E-mail was received.

Google's GMail is a good example of such a client. It ostensibly sorts
by some approximation of received time (although not by any "Received"
header). It's more usual than not to see patches showing out of order
in GMail. To take a few examples of orders seen on patches on the Git
mailing list:

    1 -> 3 -> 4 -> 2 -> 8 -> 7 (completion by Nguyễn Thái Ngọc Duy)
    2 -> 0 -> 1 -> 3 (pack search by Derrick Stolee)
    3 -> 2 -> 1 (fast-import by Jameson Miller)
    2 -> 3 -> 1 -> 5 -> 4 -> 6 (diff-highlight by Jeff King)

The reason to add the new "X-Mailer-Send-Delay" header is to make it
easy to tell what the imposed delay was, if any. This allows for
gathering some data on how the transfer of E-Mails with & without this
option behaves. This may not be workable without really long delays,
see [1] and [2].

The reason for why the getopt format is "send-delay=s" instead of
"send-delay=d" is because we're doing manual validation of the value
we get passed, which getopt would corrupt in cases of e.g. float
values before we could show a sensible error message.

1. https://public-inbox.org/git/20180325210132.GE74743@genre.crustytoothpaste.net/
2. https://public-inbox.org/git/xmqqpo3rehe4.fsf@gitster-ct.c.googlers.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

I submitted this back in March hoping it would solve mail ordering
problems, but the other motive I had for this is that I'm paranoid
that I'm sending out bad E-Mails, and tend to "y" to each one because
"a" is too fast.

So I'm re-sending this with an updated commit message & rationale, and
not sending 2/2 to toggle this on by default. I'd still like to have
this feature.

 Documentation/config.txt         |  6 ++++
 Documentation/git-send-email.txt |  4 +++
 git-send-email.perl              | 18 ++++++++---
 t/t9001-send-email.sh            | 55 ++++++++++++++++++++++++++++++++
 4 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 63365dcf3d..5eb81b64a7 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -3216,6 +3216,12 @@ sendemail.smtpReloginDelay::
 	Seconds wait before reconnecting to smtp server.
 	See also the `--relogin-delay` option of linkgit:git-send-email[1].
 
+sendemail.smtpSendDelay::
+	Seconds wait in between message sending before sending another
+	message. Set it to 0 to impose no extra delay, defaults to 0.
++
+See also the `--send-delay` option of linkgit:git-send-email[1].
+
 showbranch.default::
 	The default set of branches for linkgit:git-show-branch[1].
 	See linkgit:git-show-branch[1].
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 465a4ecbed..98fdd9b803 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -270,6 +270,10 @@ must be used for each option.
 	with --batch-size option.  Defaults to the `sendemail.smtpReloginDelay`
 	configuration variable.
 
+--send-delay=<int>::
+	Wait $<int> between sending emails. Defaults to the
+	`sendemail.smtpSendDelay` configuration variable.
+
 Automating
 ~~~~~~~~~~
 
diff --git a/git-send-email.perl b/git-send-email.perl
index 2be5dac337..65b53ee9f1 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -89,6 +89,7 @@ sub usage {
     --batch-size            <int>  * send max <int> message per connection.
     --relogin-delay         <int>  * delay <int> seconds between two successive login.
                                      This option can only be used with --batch-size
+    --send-delay            <int>  * ensure that <int> seconds pass between two successive sends.
 
   Automating:
     --identity              <str>  * Use the sendemail.<id> options.
@@ -225,7 +226,7 @@ sub do_edit {
 my ($to_cmd, $cc_cmd);
 my ($smtp_server, $smtp_server_port, @smtp_server_options);
 my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);
-my ($batch_size, $relogin_delay);
+my ($batch_size, $relogin_delay, $send_delay);
 my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);
 my ($validate, $confirm);
 my (@suppress_cc);
@@ -259,6 +260,7 @@ sub do_edit {
     "smtpauth" => \$smtp_auth,
     "smtpbatchsize" => \$batch_size,
     "smtprelogindelay" => \$relogin_delay,
+    "smtpsenddelay" => \$send_delay,
     "to" => \@initial_to,
     "tocmd" => \$to_cmd,
     "cc" => \@initial_cc,
@@ -373,6 +375,7 @@ sub signal_handler {
 		    "no-xmailer" => sub {$use_xmailer = 0},
 		    "batch-size=i" => \$batch_size,
 		    "relogin-delay=i" => \$relogin_delay,
+		    "send-delay=s" => \$send_delay,
 	 );
 
 usage() if $help;
@@ -484,6 +487,8 @@ sub read_config {
 };
 die sprintf(__("Unknown --confirm setting: '%s'\n"), $confirm)
 	unless $confirm =~ /^(?:auto|cc|compose|always|never)/;
+die sprintf(__("Invalid --send-delay setting: '%s'\n"), $send_delay)
+	if defined $send_delay and $send_delay !~ /^[0-9]+$/s;
 
 # Debugging, print out the suppressions.
 if (0) {
@@ -1562,7 +1567,8 @@ sub send_message {
 # Returns 0 if an edit was done and the function should be called again, or 1
 # otherwise.
 sub process_file {
-	my ($t) = @_;
+	my ($i) = @_;
+	my $t = $files[$i];
 
 	open my $fh, "<", $t or die sprintf(__("can't open file %s"), $t);
 
@@ -1741,6 +1747,10 @@ sub process_file {
 		$message, $xfer_encoding, $target_xfer_encoding);
 	push @xh, "Content-Transfer-Encoding: $xfer_encoding";
 	unshift @xh, 'MIME-Version: 1.0' unless $has_mime_version;
+	if ($send_delay && $i > 0) {
+		push @xh, "X-Mailer-Send-Delay: $send_delay";
+		sleep $send_delay;
+	}
 
 	$needs_confirm = (
 		$confirm eq "always" or
@@ -1793,8 +1803,8 @@ sub process_file {
 	return 1;
 }
 
-foreach my $t (@files) {
-	while (!process_file($t)) {
+foreach my $i (0 .. $#files) {
+	while (!process_file($i)) {
 		# user edited the file
 	}
 }
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index b8e919e25d..791461fabd 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1759,6 +1759,61 @@ test_expect_success '--dump-aliases must be used alone' '
 	test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
 '
 
+test_expect_success '--send-delay expects whole non-negative seconds' '
+	test_must_fail git send-email --send-delay=-1 HEAD~ 2>errors &&
+	test_i18ngrep "Invalid --send-delay setting" errors &&
+	test_must_fail git send-email --send-delay=1.5 HEAD~ 2>errors &&
+	test_i18ngrep "Invalid --send-delay setting" errors &&
+	test_must_fail git -c sendemail.smtpSendDelay=-1 send-email HEAD~ 2>errors &&
+	test_i18ngrep "Invalid --send-delay setting" errors &&
+	test_must_fail git -c sendemail.smtpSendDelay=1.5 send-email HEAD~ 2>errors &&
+	test_i18ngrep "Invalid --send-delay setting" errors
+'
+
+test_expect_success $PREREQ "there is no default --send-delay" '
+	clean_fake_sendmail &&
+	rm -fr outdir &&
+	git format-patch -3 -o outdir &&
+	git send-email \
+		--from="Example <nobody@example.com>" \
+		--to=nobody@example.com \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		outdir/*.patch \
+		2>stderr >stdout &&
+	test $(grep -c "X-Mailer:" stdout) = 3 &&
+	test $(grep -c "X-Mailer-Send-Delay:" stdout) = 0
+'
+
+test_expect_success $PREREQ '--send-delay adds a X-Mailer-Send-Delay header to affected E-Mails' '
+	clean_fake_sendmail &&
+	rm -fr outdir &&
+	git format-patch -3 -o outdir &&
+	git send-email \
+		--from="Example <nobody@example.com>" \
+		--to=nobody@example.com \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		--send-delay=2 \
+		outdir/*.patch \
+		2>stderr >stdout &&
+	test $(grep -c "X-Mailer:" stdout) = 3 &&
+	test $(grep -c "X-Mailer-Send-Delay:" stdout) = 2
+'
+
+test_expect_success $PREREQ '--send-delay=0 disables any imposed delay on E-Mail sending' '
+	clean_fake_sendmail &&
+	rm -fr outdir &&
+	git format-patch -3 -o outdir &&
+	git -c sendemail.smtpSendDelay=3 send-email \
+		--from="Example <nobody@example.com>" \
+		--to=nobody@example.com \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		--send-delay=0 \
+		outdir/*.patch \
+		2>stderr >stdout &&
+	test $(grep -c "X-Mailer:" stdout) = 3 &&
+	test $(grep -c "X-Mailer-Send-Delay:" stdout) = 0
+'
+
 test_sendmail_aliases () {
 	msg="$1" && shift &&
 	expect="$@" &&
-- 
2.18.0.865.gffc8e1a3cd6


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

* Re: [PATCH v2] send-email: add an option to impose delay sent E-Mails
  2018-08-14 18:15 ` [PATCH v2] send-email: add an option to impose delay sent E-Mails Ævar Arnfjörð Bjarmason
@ 2018-08-14 18:39   ` Stefan Beller
  2018-08-14 18:45   ` Eric Wong
  1 sibling, 0 replies; 14+ messages in thread
From: Stefan Beller @ 2018-08-14 18:39 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, brian m. carlson, Eric Wong, Eric Sunshine

On Tue, Aug 14, 2018 at 11:15 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> Add a --send-delay option with a corresponding sendemail.smtpSendDelay
> configuration variable. When set to e.g. 2, this causes send-email to
> sleep 2 seconds before sending the next E-Mail. We'll only sleep
> between sends, not before the first send, or after the last.
>
> This option has two uses. Firstly, to be able to Ctrl+C a long send
> with "all" if you have a change of heart. Secondly, as a hack in some
> mail setups to, with a sufficiently high delay, force the receiving
> client to sort the E-Mails correctly.
>
> Some popular E-Mail clients completely ignore the "Date" header, which
> format-patch is careful to set such that the patches will be displayed
> in order, and instead sort by the time the E-mail was received.
>
> Google's GMail is a good example of such a client. It ostensibly sorts
> by some approximation of received time (although not by any "Received"
> header). It's more usual than not to see patches showing out of order
> in GMail. To take a few examples of orders seen on patches on the Git
> mailing list:
>
>     1 -> 3 -> 4 -> 2 -> 8 -> 7 (completion by Nguyễn Thái Ngọc Duy)
>     2 -> 0 -> 1 -> 3 (pack search by Derrick Stolee)
>     3 -> 2 -> 1 (fast-import by Jameson Miller)
>     2 -> 3 -> 1 -> 5 -> 4 -> 6 (diff-highlight by Jeff King)
>
> The reason to add the new "X-Mailer-Send-Delay" header is to make it
> easy to tell what the imposed delay was, if any. This allows for
> gathering some data on how the transfer of E-Mails with & without this
> option behaves. This may not be workable without really long delays,
> see [1] and [2].
>
> The reason for why the getopt format is "send-delay=s" instead of
> "send-delay=d" is because we're doing manual validation of the value
> we get passed, which getopt would corrupt in cases of e.g. float
> values before we could show a sensible error message.
>
> 1. https://public-inbox.org/git/20180325210132.GE74743@genre.crustytoothpaste.net/
> 2. https://public-inbox.org/git/xmqqpo3rehe4.fsf@gitster-ct.c.googlers.com/
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>
> I submitted this back in March hoping it would solve mail ordering
> problems, but the other motive I had for this is that I'm paranoid
> that I'm sending out bad E-Mails, and tend to "y" to each one because
> "a" is too fast.'

Heh. GMail seems to have added an Undo button in their UI, which
would be the same feature as this one. (Hit Ctrl+C in time to "undo"
the sending command)

I have been bitten quite a few times by using "a" as I had old
series still laying around, such that it would send a new series and parts
of the old series (or when you changed subjects and resend another
iteration of a series, you may end up with two "patch 1"s).
So I learned to be careful before pressing "a" on sending.

Maybe the underlying issue is that you really only want to send a series
and not "all" as send-email asks for.
So maybe that dialog could learn a [s]eries switch, which would
check either filenames to count up, or if the base that is recorded
(base-commit for first and prerequisite-patch-id for followups)
is consistent.

    Send this email? ([y]es|[n]o|[e]dit|[q]uit|[a]ll|[s]eries):

Another note:
I personally never use no/quit, but Ctrl+C for both cases.

This is also different than the feature of 5453b83bdf9 (send-email
--batch-size to work around some SMTP server limit, 2017-05-21)
which introduced sendemail.smtpReloginDelay, which would offer the
same functionality when the batch-size is set to 1. (Although this would
keep you connected to the server as well as add the X-Mailer-Send-Delay
header, which is nothing from the official email RFC, but your own invention?)

Having sorted mails in GMail would be nice!

Thanks,
Stefan

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

* Re: [PATCH v2] send-email: add an option to impose delay sent E-Mails
  2018-08-14 18:15 ` [PATCH v2] send-email: add an option to impose delay sent E-Mails Ævar Arnfjörð Bjarmason
  2018-08-14 18:39   ` Stefan Beller
@ 2018-08-14 18:45   ` Eric Wong
  2018-08-14 19:53     ` Junio C Hamano
  2018-08-14 21:02     ` Ævar Arnfjörð Bjarmason
  1 sibling, 2 replies; 14+ messages in thread
From: Eric Wong @ 2018-08-14 18:45 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, brian m . carlson, Eric Sunshine

Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> Add a --send-delay option with a corresponding sendemail.smtpSendDelay
> configuration variable. When set to e.g. 2, this causes send-email to
> sleep 2 seconds before sending the next E-Mail. We'll only sleep
> between sends, not before the first send, or after the last.
> 
> This option has two uses. Firstly, to be able to Ctrl+C a long send
> with "all" if you have a change of heart. Secondly, as a hack in some
> mail setups to, with a sufficiently high delay, force the receiving
> client to sort the E-Mails correctly.
> 
> Some popular E-Mail clients completely ignore the "Date" header, which
> format-patch is careful to set such that the patches will be displayed
> in order, and instead sort by the time the E-mail was received.
> 
> Google's GMail is a good example of such a client. It ostensibly sorts
> by some approximation of received time (although not by any "Received"
> header). It's more usual than not to see patches showing out of order
> in GMail. To take a few examples of orders seen on patches on the Git
> mailing list:
> 
>     1 -> 3 -> 4 -> 2 -> 8 -> 7 (completion by Nguyễn Thái Ngọc Duy)
>     2 -> 0 -> 1 -> 3 (pack search by Derrick Stolee)
>     3 -> 2 -> 1 (fast-import by Jameson Miller)
>     2 -> 3 -> 1 -> 5 -> 4 -> 6 (diff-highlight by Jeff King)
> 
> The reason to add the new "X-Mailer-Send-Delay" header is to make it
> easy to tell what the imposed delay was, if any. This allows for
> gathering some data on how the transfer of E-Mails with & without this
> option behaves. This may not be workable without really long delays,
> see [1] and [2].

Aside from the new header, I think this is better implemented
using the existing $relogin_delay and $batch_size=1.

Disconnecting during the delay might be more sympathetic to
existing mail servers (which aren't C10K-optimized).  If the
client sleeps, the server may disconnect the client anyways
to save resources.

> @@ -1741,6 +1747,10 @@ sub process_file {
>  		$message, $xfer_encoding, $target_xfer_encoding);
>  	push @xh, "Content-Transfer-Encoding: $xfer_encoding";
>  	unshift @xh, 'MIME-Version: 1.0' unless $has_mime_version;
> +	if ($send_delay && $i > 0) {
> +		push @xh, "X-Mailer-Send-Delay: $send_delay";
> +		sleep $send_delay;
> +	}

We can add this header for relogin_delay + batch_size

But maybe --send-delay can be a shortcut for
--relogin-delay and --batch-size=1

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

* Re: [PATCH v2] send-email: add an option to impose delay sent E-Mails
  2018-08-14 18:45   ` Eric Wong
@ 2018-08-14 19:53     ` Junio C Hamano
  2018-08-14 21:02     ` Ævar Arnfjörð Bjarmason
  1 sibling, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2018-08-14 19:53 UTC (permalink / raw)
  To: Eric Wong
  Cc: Ævar Arnfjörð Bjarmason, git, brian m . carlson,
	Eric Sunshine

Eric Wong <e@80x24.org> writes:

>> Some popular E-Mail clients completely ignore the "Date" header, which
>> format-patch is careful to set such that the patches will be displayed
>> in order, and instead sort by the time the E-mail was received.

It is send-email that carefully shows monotonically increasing
timestamps so that the sender's datestamp can be used for sorting by
the recipient, not format-patch, which records author-date,
primarily meant for local replaying, in the generated messages but
discarded by send-email.

> Disconnecting during the delay might be more sympathetic to
> existing mail servers (which aren't C10K-optimized).  If the
> client sleeps, the server may disconnect the client anyways
> to save resources.
>
> But maybe --send-delay can be a shortcut for
> --relogin-delay and --batch-size=1

Both good points to point at a simpler and better solution, I guess.



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

* Re: [PATCH v2] send-email: add an option to impose delay sent E-Mails
  2018-08-14 18:45   ` Eric Wong
  2018-08-14 19:53     ` Junio C Hamano
@ 2018-08-14 21:02     ` Ævar Arnfjörð Bjarmason
  1 sibling, 0 replies; 14+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-08-14 21:02 UTC (permalink / raw)
  To: Eric Wong; +Cc: git, Junio C Hamano, brian m . carlson, Eric Sunshine


On Tue, Aug 14 2018, Eric Wong wrote:

> Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>> Add a --send-delay option with a corresponding sendemail.smtpSendDelay
>> configuration variable. When set to e.g. 2, this causes send-email to
>> sleep 2 seconds before sending the next E-Mail. We'll only sleep
>> between sends, not before the first send, or after the last.
>>
>> This option has two uses. Firstly, to be able to Ctrl+C a long send
>> with "all" if you have a change of heart. Secondly, as a hack in some
>> mail setups to, with a sufficiently high delay, force the receiving
>> client to sort the E-Mails correctly.
>>
>> Some popular E-Mail clients completely ignore the "Date" header, which
>> format-patch is careful to set such that the patches will be displayed
>> in order, and instead sort by the time the E-mail was received.
>>
>> Google's GMail is a good example of such a client. It ostensibly sorts
>> by some approximation of received time (although not by any "Received"
>> header). It's more usual than not to see patches showing out of order
>> in GMail. To take a few examples of orders seen on patches on the Git
>> mailing list:
>>
>>     1 -> 3 -> 4 -> 2 -> 8 -> 7 (completion by Nguyễn Thái Ngọc Duy)
>>     2 -> 0 -> 1 -> 3 (pack search by Derrick Stolee)
>>     3 -> 2 -> 1 (fast-import by Jameson Miller)
>>     2 -> 3 -> 1 -> 5 -> 4 -> 6 (diff-highlight by Jeff King)
>>
>> The reason to add the new "X-Mailer-Send-Delay" header is to make it
>> easy to tell what the imposed delay was, if any. This allows for
>> gathering some data on how the transfer of E-Mails with & without this
>> option behaves. This may not be workable without really long delays,
>> see [1] and [2].
>
> Aside from the new header, I think this is better implemented
> using the existing $relogin_delay and $batch_size=1.
>
> Disconnecting during the delay might be more sympathetic to
> existing mail servers (which aren't C10K-optimized).

Yeah that's a good point, maybe we're being wasteful on remote resources
here.

> If the client sleeps, the server may disconnect the client anyways to
> save resources.

Seems like something we'd need to deal with anyway, do we?

>> @@ -1741,6 +1747,10 @@ sub process_file {
>>  		$message, $xfer_encoding, $target_xfer_encoding);
>>  	push @xh, "Content-Transfer-Encoding: $xfer_encoding";
>>  	unshift @xh, 'MIME-Version: 1.0' unless $has_mime_version;
>> +	if ($send_delay && $i > 0) {
>> +		push @xh, "X-Mailer-Send-Delay: $send_delay";
>> +		sleep $send_delay;
>> +	}
>
> We can add this header for relogin_delay + batch_size
>
> But maybe --send-delay can be a shortcut for
> --relogin-delay and --batch-size=1

I need to enter a password when sending a batch with my SMTP server now,
once. With relogin I'd need to enter this N times unless I use whatever
auth save facility there is in git-send-email (which I don't use now).

I don't think it makes sense to conflate these two modes.

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

end of thread, other threads:[~2018-08-14 21:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-25 18:28 [PATCH 0/2] send-email: impose a delay while sending to appease GMail Ævar Arnfjörð Bjarmason
2018-03-25 18:28 ` [PATCH 1/2] send-email: add an option to impose delay sent E-Mails Ævar Arnfjörð Bjarmason
2018-03-25 18:28 ` [PATCH 2/2] send-email: supply a --send-delay=1 by default Ævar Arnfjörð Bjarmason
2018-03-25 21:01   ` brian m. carlson
2018-03-25 22:01     ` Ævar Arnfjörð Bjarmason
2018-03-28  1:26       ` Eric Wong
2018-03-26  1:48     ` Junio C Hamano
2018-03-26  0:11   ` Eric Sunshine
2018-03-26  1:56     ` Junio C Hamano
2018-08-14 18:15 ` [PATCH v2] send-email: add an option to impose delay sent E-Mails Ævar Arnfjörð Bjarmason
2018-08-14 18:39   ` Stefan Beller
2018-08-14 18:45   ` Eric Wong
2018-08-14 19:53     ` Junio C Hamano
2018-08-14 21:02     ` Ævar Arnfjörð Bjarmason

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).