Re: no-xmailer tests fail under Mac OS

2014-12-11 Thread Luis Henriques
Jeff King  writes:

> On Thu, Dec 11, 2014 at 02:11:04PM -0800, Junio C Hamano wrote:
>
>> Jeff King  writes:
>> 
>> > On Fri, Dec 05, 2014 at 11:07:37PM -0800, Michael Blume wrote:
>> >
>> >> > Ah, right, we might be looking for 0 sometimes. The right way to do it
>> >> > without destroying the &&-chaining is:
>> >> >
>> >> >   { grep ^X-Mailer: out || true } &&
>> >> >   test_line_count = $expected mailer
>> >> 
>> >> Hmm, it doesn't look like that helper is &&-chained though? So it
>> >> seems like we could just do without the &&
>> >
>> > You're right, but that is IMHO a bug. We would not notice if send-email
>> > or format-patch barfed, and we are expecting to find no X-Mailer (we
>> > wouldn't, but for the wrong reason).
>> 
>> Let me patch this up further by amending the SQUASH??? at the tip.
>> 
>>  t/t9001-send-email.sh | 11 +--
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>> [...]
>
> Yeah, looks good to me.
>
> -Peff

Same here.  Thanks a lot for fixing this.

Cheers,
--
Luís
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH] send-email: add --[no-]xmailer option

2014-12-04 Thread Luis Henriques
On Thu, Dec 04, 2014 at 11:33:24AM -0800, Junio C Hamano wrote:
> Luis Henriques  writes:
> 
> > On Wed, Dec 03, 2014 at 08:56:45AM -0800, Junio C Hamano wrote:
> >
> >> 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.

> 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,
-- 
Luís
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] test/send-email: --[no-]xmailer tests

2014-12-04 Thread Luis Henriques
Add tests for the --[no-]xmailer option.

Signed-off-by: Luis Henriques 
---
 t/t9001-send-email.sh | 32 
 1 file changed, 32 insertions(+)

diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index e37efef..7a3f996 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1556,5 +1556,37 @@ test_expect_success $PREREQ 
'sendemail.aliasfile=~/.mailrc' '
2>errors >out &&
grep "^!someone@example\.org!$" commandline1
 '
+do_xmailer_test() {
+   expected=$1
+   params=$2
+   git format-patch -1
+   git send-email \
+   --from="Example " \
+   --to=some...@example.com \
+   --smtp-server="$(pwd)/fake.sendmail" \
+   $params \
+   0001-*.patch \
+   2>errors >out
+   test "z$(grep ^X-Mailer: out | wc -l)" = "z$expected"
+   return $?
+}
+
+test_expect_success $PREREQ '--xmailer uses X-Mailer header' '
+   do_xmailer_test "1" "--xmailer"
+'
+
+test_expect_success $PREREQ '--no-xmailer supresses X-Mailer header' '
+   do_xmailer_test "0" "--no-xmailer"
+'
+
+test_expect_success $PREREQ 'sendemail.xmailer=true uses X-Mailer header' '
+   git config sendemail.xmailer true &&
+   do_xmailer_test "1" ""
+'
+
+test_expect_success $PREREQ 'sendemail.xmailer=false supresses X-Mailer 
header' '
+   git config sendemail.xmailer false &&
+   do_xmailer_test "0" ""
+'
 
 test_done
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH] send-email: add --[no-]xmailer option

2014-12-04 Thread Luis Henriques
On Wed, Dec 03, 2014 at 08:56:45AM -0800, Junio C Hamano wrote:
> Eric Wong  writes:
> 
> > Luis Henriques  wrote:
> >> On Mon, Mar 24, 2014 at 09:38:27PM +, Luis Henriques wrote:
> >> > 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 
> >
> >> 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.
> 
> 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,
-- 
Luís
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] send-email: add --[no-]xmailer option

2014-12-03 Thread Luis Henriques
Add --[no-]xmailer that allows a user to disable adding the 'X-Mailer:'
header to the email being sent.

Acked-by: Eric Wong 
Signed-off-by: Luis Henriques 
---
 Documentation/config.txt |  1 +
 Documentation/git-send-email.txt |  5 +
 git-send-email.perl  | 11 +--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 922072596fdd..3f9898931d3b 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2304,6 +2304,7 @@ sendemail.smtpserveroption::
 sendemail.smtpuser::
 sendemail.thread::
 sendemail.validate::
+sendemail.xmailer::
See linkgit:git-send-email[1] for description.
 
 sendemail.signedoffcc::
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index a60776eb579e..a0bd806cfed8 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -131,6 +131,11 @@ 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::
+--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
 ~~~
diff --git a/git-send-email.perl b/git-send-email.perl
index 9949db01e119..a6e66b9ae386 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -54,6 +54,7 @@ git send-email [options] 
 --[no-]bcc* Email Bcc:
 --subject * Email "Subject:"
 --in-reply-to * Email "In-Reply-To:"
+--[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* Encoding to assume for introduction.
@@ -176,6 +177,8 @@ my $force = 0;
 my $multiedit;
 my $editor;
 
+my $use_xmailer;
+
 sub do_edit {
if (!defined($editor)) {
$editor = Git::command_oneline('var', 'GIT_EDITOR');
@@ -219,7 +222,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" => [\$use_xmailer, 1]
 );
 
 my %config_settings = (
@@ -318,6 +322,7 @@ my $rc = GetOptions("h" => \$help,
"8bit-encoding=s" => \$auto_8bit_encoding,
"compose-encoding=s" => \$compose_encoding,
"force" => \$force,
+   "xmailer!" => \$use_xmailer,
 );
 
 usage() if $help;
@@ -1163,8 +1168,10 @@ To: $to${ccline}
 Subject: $subject
 Date: $date
 Message-Id: $message_id
-X-Mailer: git-send-email $gitversion
 ";
+   if ($use_xmailer) {
+   $header .= "X-Mailer: git-send-email $gitversion\n";
+   }
if ($reply_to) {
 
$header .= "In-Reply-To: $reply_to\n";
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH] send-email: add --[no-]xmailer option

2014-12-03 Thread Luis Henriques
On Wed, Dec 03, 2014 at 09:23:11AM -0800, Junio C Hamano wrote:
> Junio C Hamano  writes:
> 
> > 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,
-- 
Luís


>  Documentation/git-send-email.txt |  6 --
>  git-send-email.perl  | 11 +--
>  2 files changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/git-send-email.txt 
> b/Documentation/git-send-email.txt
> index f2425ef..a0bd806 100644
> --- a/Documentation/git-send-email.txt
> +++ b/Documentation/git-send-email.txt
> @@ -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
>  ~~~
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 9ca7c5b..a6e66b9 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -54,7 +54,7 @@ sub usage {
>  --[no-]bcc* Email Bcc:
>  --subject * Email "Subject:"
>  --in-reply-to * 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* 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) {
> -- 
> 2.2.0-141-gd3f4719
> 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH] send-email: add --[no-]xmailer option

2014-12-03 Thread Luis Henriques
On Tue, Dec 02, 2014 at 07:22:10PM -0800, Kyle J. McKay wrote:
> On Dec 2, 2014, at 18:34, Eric Wong wrote:
> 
> >Luis Henriques  wrote:
> >>On Mon, Mar 24, 2014 at 09:38:27PM +, Luis Henriques wrote:
> >>>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 
> >
> >>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.
> 
> >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,
-- 
Luís

> 
> diff --git a/git-send-email.orig b/git-send-email.new
> index f3d75e8..d0b4bff 100755
> --- a/git-send-email.orig
> +++ b/git-send-email.new
> @@ -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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH] send-email: add --[no-]xmailer option

2014-12-02 Thread Luis Henriques
On Mon, Mar 24, 2014 at 09:38:27PM +, Luis Henriques wrote:
> 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,
-- 
Luís

> Signed-off-by: Luis Henriques 
> ---
>  Documentation/config.txt |  1 +
>  Documentation/git-send-email.txt |  3 +++
>  git-send-email.perl  | 12 ++--
>  3 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 73c8973..c33d5a1 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -,6 +,7 @@ sendemail.smtpserveroption::
>  sendemail.smtpuser::
>  sendemail.thread::
>  sendemail.validate::
> +sendemail.xmailer::
>   See linkgit:git-send-email[1] for description.
>  
>  sendemail.signedoffcc::
> diff --git a/Documentation/git-send-email.txt 
> b/Documentation/git-send-email.txt
> index f0e57a5..fab6264 100644
> --- a/Documentation/git-send-email.txt
> +++ b/Documentation/git-send-email.txt
> @@ -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
>  ~~~
> diff --git a/git-send-email.perl b/git-send-email.perl
> index fdb0029..8789124 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -54,6 +54,7 @@ git send-email [options]  options >
>  --[no-]bcc* Email Bcc:
>  --subject * Email "Subject:"
>  --in-reply-to * 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* 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";
> -- 
> 1.9.1
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH] send-email: add --[no-]xmailer option

2014-03-24 Thread Luis Henriques
Add --[no-]xmailer that allows a user to disable adding the 'X-Mailer:'
header to the email being sent.

Signed-off-by: Luis Henriques 
---
 Documentation/config.txt |  1 +
 Documentation/git-send-email.txt |  3 +++
 git-send-email.perl  | 12 ++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 73c8973..c33d5a1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -,6 +,7 @@ sendemail.smtpserveroption::
 sendemail.smtpuser::
 sendemail.thread::
 sendemail.validate::
+sendemail.xmailer::
See linkgit:git-send-email[1] for description.
 
 sendemail.signedoffcc::
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index f0e57a5..fab6264 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -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
 ~~~
diff --git a/git-send-email.perl b/git-send-email.perl
index fdb0029..8789124 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -54,6 +54,7 @@ git send-email [options] 
 --[no-]bcc* Email Bcc:
 --subject * Email "Subject:"
 --in-reply-to * 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* 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";
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html