send-email: add --[no-]xmailer option
RFC PATCH 1/1 send-email: add --[no-]xmailer option
Add --[no-]xmailer that allows a user to disable adding the 'X-Mailer:' header to the email being sent.
--- Documentation/config.txt | 1 + Documentation/git-send-email.txt | 3 +++ git-send-email.perl | 12 ++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-)
Documentation/config.txt +1 -0
@@ -2222,6 +2222,7 @@ sendemail.smtpserveroption:: sendemail.smtpuser:: sendemail.thread:: sendemail.validate:: +sendemail.xmailer:: See linkgit:git-send-email[1] for description. sendemail.signedoffcc::
Documentation/git-send-email.txt +3 -0
@@ -131,6 +131,9 @@ Note that no attempts whatsoever are made to validate the encoding. Specify encoding of compose message. Default is the value of the 'sendemail.composeencoding'; if that is unspecified, UTF-8 is assumed. +--xmailer:: + Prevent adding the "X-Mailer:" header. Default value is + 'sendemail.xmailer'. Sending ~~~~~~~
git-send-email.perl +10 -2
@@ -54,6 +54,7 @@ git send-email [options] <file | directory | rev-list options > --[no-]bcc <str> * Email Bcc: --subject <str> * Email "Subject:" --in-reply-to <str> * Email "In-Reply-To:" + --[no-]xmailer * Don't add "X-Mailer:" header. Default on. --[no-]annotate * Review each patch that will be sent in an editor. --compose * Open an editor for introduction. --compose-encoding <str> * Encoding to assume for introduction.
@@ -174,6 +175,9 @@ my $force = 0; my $multiedit; my $editor; +# Usage of X-Mailer email header +my $xmailer; + sub do_edit { if (!defined($editor)) { $editor = Git::command_oneline('var', 'GIT_EDITOR');
@@ -214,7 +218,8 @@ my %config_bool_settings = ( "signedoffcc" => [\$signed_off_by_cc, undef], # Deprecated "validate" => [\$validate, 1], "multiedit" => [\$multiedit, undef], - "annotate" => [\$annotate, undef] + "annotate" => [\$annotate, undef], + "xmailer" => [\$xmailer, 1] ); my %config_settings = (
@@ -311,6 +316,7 @@ my $rc = GetOptions("h" => \$help, "8bit-encoding=s" => \$auto_8bit_encoding, "compose-encoding=s" => \$compose_encoding, "force" => \$force, + "xmailer!" => \$xmailer, ); usage() if $help;
@@ -1144,8 +1150,10 @@ To: $to${ccline} Subject: $subject Date: $date Message-Id: $message_id -X-Mailer: git-send-email $gitversion "; + if ($xmailer) { + $header .= "X-Mailer: git-send-email $gitversion\n"; + } if ($reply_to) { $header .= "In-Reply-To: $reply_to\n";
Signature · 1 line
1.9.1
Quoted 3 lines · Luis Henriques
Add --[no-]xmailer that allows a user to disable adding the 'X-Mailer:' header to the email being sent.
Ping
It's been a while since I sent this patch. Is there any interest in having this switch in git-send-email?
I honestly don't like disclosing too much information about my system, in this case which MUA I'm using and its version.
Cheers,
Signature · 1 line
Luís
Quoted 87 lines
Signed-off-by Luis Henriques <[email protected]>--- Documentation/config.txt | 1 + Documentation/git-send-email.txt | 3 +++ git-send-email.perl | 12 ++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-)Documentation/config.txt +1
-0@@ -2222,6 +2222,7 @@ sendemail.smtpserveroption:: sendemail.smtpuser:: sendemail.thread:: sendemail.validate:: +sendemail.xmailer:: See linkgit:git-send-email[1] for description. sendemail.signedoffcc::Documentation/git-send-email.txt +3
-0@@ -131,6 +131,9 @@ Note that no attempts whatsoever are made to validate the encoding. Specify encoding of compose message. Default is the value of the 'sendemail.composeencoding'; if that is unspecified, UTF-8 is assumed. +--xmailer:: + Prevent adding the "X-Mailer:" header. Default value is + 'sendemail.xmailer'. Sending ~~~~~~~git-send-email.perl +10
-2@@ -54,6 +54,7 @@ git send-email [options] <file | directory | rev-list options > --[no-]bcc <str> * Email Bcc: --subject <str> * Email "Subject:" --in-reply-to <str> * Email "In-Reply-To:" + --[no-]xmailer * Don't add "X-Mailer:" header. Default on. --[no-]annotate * Review each patch that will be sent in an editor. --compose * Open an editor for introduction. --compose-encoding <str> * Encoding to assume for introduction.@@ -174,6 +175,9 @@ my $force = 0; my $multiedit; my $editor; +# Usage of X-Mailer email header +my $xmailer; + sub do_edit { if (!defined($editor)) { $editor = Git::command_oneline('var', 'GIT_EDITOR');@@ -214,7 +218,8 @@ my %config_bool_settings = ( "signedoffcc" => [\$signed_off_by_cc, undef], # Deprecated "validate" => [\$validate, 1], "multiedit" => [\$multiedit, undef], - "annotate" => [\$annotate, undef] + "annotate" => [\$annotate, undef], + "xmailer" => [\$xmailer, 1] ); my %config_settings = (@@ -311,6 +316,7 @@ my $rc = GetOptions("h" => \$help, "8bit-encoding=s" => \$auto_8bit_encoding, "compose-encoding=s" => \$compose_encoding, "force" => \$force, + "xmailer!" => \$xmailer, ); usage() if $help;@@ -1144,8 +1150,10 @@ To: $to${ccline} Subject: $subject Date: $date Message-Id: $message_id -X-Mailer: git-send-email $gitversion "; + if ($xmailer) { + $header .= "X-Mailer: git-send-email $gitversion\n"; + } if ($reply_to) { $header .= "In-Reply-To: $reply_to\n";Signature · 1 line
1.9.1
Eric Wong
Acked-byQuoted 9 lines · Luis Henriques
Quoted 3 lines · Luis Henriques
Add --[no-]xmailer that allows a user to disable adding the 'X-Mailer:' header to the email being sent.
Ping
It's been a while since I sent this patch. Is there any interest in having this switch in git-send-email?
I wasn't paying attention when the original was sent, but this looks good to me.
Quoted 2 lines
I honestly don't like disclosing too much information about my system, in this case which MUA I'm using and its version.
Right on. I would even favor this being the default.
Auto-generated Message-Id headers also shows the use of git-send-email; perhaps there can be a way to configure that, too. However, git-send-email respects manually-added Message-Id headers in the original patch, so it's less of a problem, I suppose.
Quoted 14 lines · Eric Wong
Quoted 9 lines · Luis Henriques
Quoted 3 lines · Luis Henriques
Add --[no-]xmailer that allows a user to disable adding the 'X-Mailer:' header to the email being sent.
Ping
It's been a while since I sent this patch. Is there any interest in having this switch in git-send-email?
I wasn't paying attention when the original was sent, but this looks good to me.
Quoted 6 lines
Acked-by Eric Wong <[email protected]>Quoted 2 lines
I honestly don't like disclosing too much information about my system, in this case which MUA I'm using and its version.
Right on. I would even favor this being the default.
I fully agree with you.
Quoted 4 lines
Auto-generated Message-Id headers also shows the use of git-send-email; perhaps there can be a way to configure that, too. However, git-send-email respects manually-added Message-Id headers in the original patch, so it's less of a problem, I suppose.
It can be hashed like so to avoid leaking information:
git-send-email.new renamed from git-send-email.orig +4 -1
@@ -27,6 +27,7 @@ use Data::Dumper; use Term::ANSIColor; use File::Temp qw/ tempdir tempfile /; use File::Spec::Functions qw(catfile); +use Digest::MD5 qw(md5_hex); use Error qw(:try); use Git;
@@ -901,8 +903,10 @@ sub make_message_id { require Sys::Hostname; $du_part = 'user@' . Sys::Hostname::hostname(); } - my $message_id_template = "<%s-git-send-email-%s>"; + my $message_id_template = "%s-git-send-email-%s"; $message_id = sprintf($message_id_template, $uniq, $du_part); + @_ = split /@/, $message_id; + $message_id = '<'.substr(md5_hex($_[0]),0,31).'@'.substr(md5_hex($_[1]),1,31).'>'; #print "new message id = $message_id\n"; # Was useful for debugging }
---
--Kyle
Quoted 23 lines · Kyle J. McKay
Quoted 14 lines · Eric Wong
Quoted 9 lines · Luis Henriques
Quoted 3 lines · Luis Henriques
Add --[no-]xmailer that allows a user to disable adding the 'X-Mailer:' header to the email being sent.
Ping
It's been a while since I sent this patch. Is there any interest in having this switch in git-send-email?
I wasn't paying attention when the original was sent, but this looks good to me.
Quoted 6 lines
Acked-by Eric Wong <[email protected]>Quoted 2 lines
I honestly don't like disclosing too much information about my system, in this case which MUA I'm using and its version.
Right on. I would even favor this being the default.
Quoted 8 lines
I fully agree with you.
Quoted 4 lines
Auto-generated Message-Id headers also shows the use of git-send-email; perhaps there can be a way to configure that, too. However, git-send-email respects manually-added Message-Id headers in the original patch, so it's less of a problem, I suppose.
It can be hashed like so to avoid leaking information:
Awesome, I like this idea too!
Cheers,
Signature · 1 line
Luís
Quoted 28 lines
git-send-email.new renamed from git-send-email.orig +4
-3@@ -27,6 +27,7 @@ use Data::Dumper; use Term::ANSIColor; use File::Temp qw/ tempdir tempfile /; use File::Spec::Functions qw(catfile); +use Digest::MD5 qw(md5_hex); use Error qw(:try); use Git;@@ -901,8 +903,10 @@ sub make_message_id { require Sys::Hostname; $du_part = 'user@' . Sys::Hostname::hostname(); } - my $message_id_template = "<%s-git-send-email-%s>"; + my $message_id_template = "%s-git-send-email-%s"; $message_id = sprintf($message_id_template, $uniq, $du_part); + @_ = split /@/, $message_id; + $message_id = '<'.substr(md5_hex($_[0]),0,31).'@'.substr(md5_hex($_[1]),1,31).'>'; #print "new message id = $message_id\n"; # Was useful for debugging } --- --Kyle
Quoted 19 lines · Eric Wong
Quoted 9 lines · Luis Henriques
Quoted 3 lines · Luis Henriques
Add --[no-]xmailer that allows a user to disable adding the 'X-Mailer:' header to the email being sent.
Ping
It's been a while since I sent this patch. Is there any interest in having this switch in git-send-email?
I wasn't paying attention when the original was sent, but this looks good to me.
Acked-by Eric Wong <[email protected]>Quoted 2 lines
I honestly don't like disclosing too much information about my system, in this case which MUA I'm using and its version.
Quoted 6 lines
Right on. I would even favor this being the default.
Auto-generated Message-Id headers also shows the use of git-send-email; perhaps there can be a way to configure that, too. However, git-send-email respects manually-added Message-Id headers in the original patch, so it's less of a problem, I suppose.
I actually do not think this is a good idea from debuggability.
Quoted 21 lines · Junio C Hamano
Quoted 19 lines · Eric Wong
Quoted 9 lines · Luis Henriques
Quoted 3 lines · Luis Henriques
Add --[no-]xmailer that allows a user to disable adding the 'X-Mailer:' header to the email being sent.
Ping
It's been a while since I sent this patch. Is there any interest in having this switch in git-send-email?
I wasn't paying attention when the original was sent, but this looks good to me.
Acked-by Eric Wong <[email protected]>Quoted 2 lines
I honestly don't like disclosing too much information about my system, in this case which MUA I'm using and its version.
Quoted 8 lines
Quoted 6 lines
Right on. I would even favor this being the default.
Auto-generated Message-Id headers also shows the use of git-send-email; perhaps there can be a way to configure that, too. However, git-send-email respects manually-added Message-Id headers in the original patch, so it's less of a problem, I suppose.
I actually do not think this is a good idea from debuggability.
Do you think this could be merged with yet another switch? I can't think of a name for the switch, something like... "--hide-msgid"?
Another option would be to re-work the --no-xmailer switch to change it into a "--hide-id" (or something), where both the "X-Mailer:" header would be dropped and the Message-id would be obfuscated.
Cheers,
Signature · 1 line
Luís
Quoted 6 lines · Luis Henriques
Quoted 1 line · Junio C Hamano
I actually do not think this is a good idea from debuggability.
Do you think this could be merged with yet another switch? I can't think of a name for the switch, something like... "--hide-msgid"?
In case it wasn't clear, by "this" I meant the removal of "X-Mailer:", iow, "Adding --no-xmailer option is a bad idea from debuggability's point of view".
Not adding message-id is not an option; MSAs are supposed to always add one if they want to be RFC compliant, aren't they?
Quoted 4 lines · Junio C Hamano
Quoted 2 lines · Luis Henriques
On Wed, Dec 03, 2014 at 08:56:45AM -0800, Junio C Hamano wrote:
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
I actually do not think this is a good idea from debuggability.
Do you think this could be merged with yet another switch? I can't think of a name for the switch, something like... "--hide-msgid"?
In case it wasn't clear, by "this" I meant the removal of "X-Mailer:", iow, "Adding --no-xmailer option is a bad idea from debuggability's point of view".
Oh, ok. I thought you were talking about the message-id.
Quoted 2 lines
Not adding message-id is not an option; MSAs are supposed to always add one if they want to be RFC compliant, aren't they?
Yes, of course -- having a message ID is a requirement. But I was hoping you could accept a solution similar to the one suggested by Kyle (adding him to Cc): he was suggesting hashing the message ID, which would be a good compromise, I believe.
Cheers,
Signature · 1 line
Luís
Documentation/git-send-email.txt Note that no attempts whatsoever are made to validate the encoding. · line 136
Quoted 3 lines · Luis Henriques
+--xmailer::
Documentation/git-send-email.txt +2
-0+ Prevent adding the "X-Mailer:" header. Default value is + 'sendemail.xmailer'.
Two problems here.
- "git send-email --xmailer" would _ADD_, not prevent adding, the header, regardless of the value of sendemail.xmailer.
- It is unspecified what happens when you do not have sendemail.xmailer and do not give the --xmailer option.
Perhaps
--xmailer::
--no-xmailer::
By default, git send-email adds an "X-Mailer:" header to the message to identify the version of itself. The --no-xmailer option can be used to turn this off (setting the sendemail.xmailer configuration to false has the same effect). The --xmailer option from the command line is useful to countermand sendemail.xmailer that is set to false.
or something?
git-send-email.perl git send-email [options] <file | directory | rev-list options > · line 57
Quoted 9 lines
git-send-email.perl +1
-0@@ -54,6 +54,7 @@ git send-email [options] <file | directory | rev-list options > --[no-]bcc <str> * Email Bcc: --subject <str> * Email "Subject:" --in-reply-to <str> * Email "In-Reply-To:" + --[no-]xmailer * Don't add "X-Mailer:" header. Default on.
The same confusion exists here. "Don't ... default on" hints that by default we won't see "X-mailer:" which is not true.
A way to avoid confusion is to describe what the option is about for the positive variant, just like it is done for "--[no-]annotate" option below.
Quoted 30 lines
git-send-email.perl +6
-1@@ -174,6 +175,9 @@ my $force = 0; my $multiedit; my $editor; +# Usage of X-Mailer email header +my $xmailer; + sub do_edit { if (!defined($editor)) { $editor = Git::command_oneline('var', 'GIT_EDITOR');@@ -214,7 +218,8 @@ my %config_bool_settings = ( "signedoffcc" => [\$signed_off_by_cc, undef], # Deprecated "validate" => [\$validate, 1], "multiedit" => [\$multiedit, undef], - "annotate" => [\$annotate, undef] + "annotate" => [\$annotate, undef], + "xmailer" => [\$xmailer, 1] ); my %config_settings = (@@ -311,6 +316,7 @@ my $rc = GetOptions("h" => \$help, "8bit-encoding=s" => \$auto_8bit_encoding, "compose-encoding=s" => \$compose_encoding, "force" => \$force, + "xmailer!" => \$xmailer, ); usage() if $help;@@ -1144,8 +1150,10 @@ To: $to${ccline} Subject: $subject
git-send-email.perl To: $to${ccline} · line 1159
Quoted 10 lines
git-send-email.perl +3
-1Date: $date Message-Id: $message_id -X-Mailer: git-send-email $gitversion "; + if ($xmailer) { + $header .= "X-Mailer: git-send-email $gitversion\n"; + } if ($reply_to) { $header .= "In-Reply-To: $reply_to\n";
tests?
Thanks.
Quoted 3 lines · Junio C Hamano
Two problems here.
...
tests?
Something like this squashed into the patch you posted earlier, perhaps, would be a good place to start.
Documentation/git-send-email.txt | 6 ++++-- git-send-email.perl | 11 +++++------ 2 files changed, 9 insertions(+), 8 deletions(-)
Documentation/git-send-email.txt +4 -2
@@ -132,8 +132,10 @@ Note that no attempts whatsoever are made to validate the encoding. 'sendemail.composeencoding'; if that is unspecified, UTF-8 is assumed. --xmailer:: - Prevent adding the "X-Mailer:" header. Default value is - 'sendemail.xmailer'. +--no-xmailer:: + Add (or prevent adding) the "X-Mailer:" header. By default, + the header is added, but it can be turned off by setting the + `sendemail.xmailer` configuration variable to `false`. Sending ~~~~~~~
git-send-email.perl +5 -6
@@ -54,7 +54,7 @@ sub usage { --[no-]bcc <str> * Email Bcc: --subject <str> * Email "Subject:" --in-reply-to <str> * Email "In-Reply-To:" - --[no-]xmailer * Don't add "X-Mailer:" header. Default on. + --[no-]xmailer * Add "X-Mailer:" header (default). --[no-]annotate * Review each patch that will be sent in an editor. --compose * Open an editor for introduction. --compose-encoding <str> * Encoding to assume for introduction.
@@ -177,8 +177,7 @@ sub format_2822_time { my $multiedit; my $editor; -# Usage of X-Mailer email header -my $xmailer; +my $use_xmailer; sub do_edit { if (!defined($editor)) {
@@ -224,7 +223,7 @@ sub do_edit { "validate" => [\$validate, 1], "multiedit" => [\$multiedit, undef], "annotate" => [\$annotate, undef], - "xmailer" => [\$xmailer, 1] + "xmailer" => [\$use_xmailer, 1] ); my %config_settings = (
@@ -323,7 +322,7 @@ sub signal_handler { "8bit-encoding=s" => \$auto_8bit_encoding, "compose-encoding=s" => \$compose_encoding, "force" => \$force, - "xmailer!" => \$xmailer, + "xmailer!" => \$use_xmailer, ); usage() if $help;
@@ -1170,7 +1169,7 @@ sub send_message { Date: $date Message-Id: $message_id "; - if ($xmailer) { + if ($use_xmailer) { $header .= "X-Mailer: git-send-email $gitversion\n"; } if ($reply_to) {
Signature · 1 line
2.2.0-141-gd3f4719
Quoted 9 lines · Junio C Hamano
Quoted 3 lines · Junio C Hamano
Two problems here.
...
tests?Something like this squashed into the patch you posted earlier, perhaps, would be a good place to start.
Awesome, thank you for your review. I'll post a new version of the patch including your suggestions. Regarding the tests, I'll need a bit more time to work on those.
Cheers,
Signature · 1 line
Luís
Quoted 74 lines
Documentation/git-send-email.txt | 6 ++++-- git-send-email.perl | 11 +++++------ 2 files changed, 9 insertions(+), 8 deletions(-)Documentation/git-send-email.txt +4
-2@@ -132,8 +132,10 @@ Note that no attempts whatsoever are made to validate the encoding. 'sendemail.composeencoding'; if that is unspecified, UTF-8 is assumed. --xmailer:: - Prevent adding the "X-Mailer:" header. Default value is - 'sendemail.xmailer'. +--no-xmailer:: + Add (or prevent adding) the "X-Mailer:" header. By default, + the header is added, but it can be turned off by setting the + `sendemail.xmailer` configuration variable to `false`. Sending ~~~~~~~git-send-email.perl +5
-6@@ -54,7 +54,7 @@ sub usage { --[no-]bcc <str> * Email Bcc: --subject <str> * Email "Subject:" --in-reply-to <str> * Email "In-Reply-To:" - --[no-]xmailer * Don't add "X-Mailer:" header. Default on. + --[no-]xmailer * Add "X-Mailer:" header (default). --[no-]annotate * Review each patch that will be sent in an editor. --compose * Open an editor for introduction. --compose-encoding <str> * Encoding to assume for introduction.@@ -177,8 +177,7 @@ sub format_2822_time { my $multiedit; my $editor; -# Usage of X-Mailer email header -my $xmailer; +my $use_xmailer; sub do_edit { if (!defined($editor)) {@@ -224,7 +223,7 @@ sub do_edit { "validate" => [\$validate, 1], "multiedit" => [\$multiedit, undef], "annotate" => [\$annotate, undef], - "xmailer" => [\$xmailer, 1] + "xmailer" => [\$use_xmailer, 1] ); my %config_settings = (@@ -323,7 +322,7 @@ sub signal_handler { "8bit-encoding=s" => \$auto_8bit_encoding, "compose-encoding=s" => \$compose_encoding, "force" => \$force, - "xmailer!" => \$xmailer, + "xmailer!" => \$use_xmailer, ); usage() if $help;@@ -1170,7 +1169,7 @@ sub send_message { Date: $date Message-Id: $message_id "; - if ($xmailer) { + if ($use_xmailer) { $header .= "X-Mailer: git-send-email $gitversion\n"; } if ($reply_to) {Signature · 1 line
2.2.0-141-gd3f4719
git-send-email.perl sub format_2822_time { · line 180
Quoted 7 lines · Junio C Hamano
git-send-email.perl +1
-2@@ -177,8 +177,7 @@ sub format_2822_time { my $multiedit; my $editor; -# Usage of X-Mailer email header -my $xmailer; +my $use_xmailer;
Just another small thing. The version of "SQUASH???" commit I will queue on 'pu' will have this next to where $annotate is defined.