Merge branch 'jw/send-email-no-auth'
authorJunio C Hamano <gitster@pobox.com>
Tue, 6 Nov 2018 06:50:20 +0000 (15:50 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Nov 2018 06:50:20 +0000 (15:50 +0900)
"git send-email" learned to disable SMTP authentication via the
"--smtp-auth=none" option, even when the smtp username is given
(which turns the authentication on by default).

* jw/send-email-no-auth:
send-email: explicitly disable authentication

1  2 
Documentation/git-send-email.txt
git-send-email.perl
index f6010ac68b9a683fd9821b13ca10f52db00b096c,17993e3c9c189c81ade1daa81a47795746a123af..62c6c76f2736e0ee2dd61d3ac25a4962a9db0fc7
@@@ -190,7 -190,9 +190,9 @@@ $ git send-email --smtp-auth="PLAIN LOG
  If at least one of the specified mechanisms matches the ones advertised by the
  SMTP server and if it is supported by the utilized SASL library, the mechanism
  is used for authentication. If neither 'sendemail.smtpAuth' nor `--smtp-auth`
- is specified, all mechanisms supported by the SASL library can be used.
+ is specified, all mechanisms supported by the SASL library can be used. The
+ special value 'none' maybe specified to completely disable authentication
+ independently of `--smtp-user`
  
  --smtp-pass[=<password>]::
        Password for SMTP-AUTH. The argument is optional: If no
@@@ -204,6 -206,9 +206,9 @@@ or on the command line. If a username h
  specified (with `--smtp-pass` or `sendemail.smtpPass`), then
  a password is obtained using 'git-credential'.
  
+ --no-smtp-auth::
+       Disable SMTP authentication. Short hand for `--smtp-auth=none`
  --smtp-server=<host>::
        If set, specifies the outgoing SMTP server to use (e.g.
        `smtp.example.com` or a raw IP address).  Alternatively it can
@@@ -321,19 -326,16 +326,19 @@@ Automatin
        auto-cc of:
  +
  --
 -- 'author' will avoid including the patch author
 -- 'self' will avoid including the sender
 +- 'author' will avoid including the patch author.
 +- 'self' will avoid including the sender.
  - 'cc' will avoid including anyone mentioned in Cc lines in the patch header
    except for self (use 'self' for that).
  - 'bodycc' will avoid including anyone mentioned in Cc lines in the
    patch body (commit message) except for self (use 'self' for that).
  - 'sob' will avoid including anyone mentioned in Signed-off-by lines except
 -   for self (use 'self' for that).
 +  for self (use 'self' for that).
 +- 'misc-by' will avoid including anyone mentioned in Acked-by,
 +  Reviewed-by, Tested-by and other "-by" lines in the patch body,
 +  except Signed-off-by (use 'sob' for that).
  - 'cccmd' will avoid running the --cc-cmd.
 -- 'body' is equivalent to 'sob' + 'bodycc'
 +- 'body' is equivalent to 'sob' + 'bodycc' + 'misc-by'.
  - 'all' will suppress all auto cc values.
  --
  +
diff --combined git-send-email.perl
index 58c6aa9d0eca3e692e5c8c5df538afdb8f8fe63d,a7067948421f94b36820a8b288e6575b0f911916..dc7e738e9ce462c85378b82b396dbda0728b971f
@@@ -82,8 -82,11 +82,11 @@@ git send-email --dump-aliase
                                       Pass an empty string to disable certificate
                                       verification.
      --smtp-domain           <str>  * The domain name sent to HELO/EHLO handshake
-     --smtp-auth             <str>  * Space-separated list of allowed AUTH mechanisms.
+     --smtp-auth             <str>  * Space-separated list of allowed AUTH mechanisms, or
+                                      "none" to disable authentication.
                                       This setting forces to use one of the listed mechanisms.
+     --no-smtp-auth                   Disable SMTP authentication. Shorthand for
+                                      `--smtp-auth=none`
      --smtp-debug            <0|1>  * Disable, enable Net::SMTP debug.
  
      --batch-size            <int>  * send max <int> message per connection.
@@@ -94,7 -97,7 +97,7 @@@
      --identity              <str>  * Use the sendemail.<id> options.
      --to-cmd                <str>  * Email To: via `<str> \$patch_path`
      --cc-cmd                <str>  * Email Cc: via `<str> \$patch_path`
 -    --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, all.
 +    --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, misc-by, all.
      --[no-]cc-cover                * Email Cc: addresses in the cover letter.
      --[no-]to-cover                * Email To: addresses in the cover letter.
      --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.
@@@ -341,6 -344,7 +344,7 @@@ $rc = GetOptions
                    "smtp-debug:i" => \$debug_net_smtp,
                    "smtp-domain:s" => \$smtp_domain,
                    "smtp-auth=s" => \$smtp_auth,
+                   "no-smtp-auth" => sub {$smtp_auth = 'none'},
                    "identity=s" => \$identity,
                    "annotate!" => \$annotate,
                    "no-annotate" => sub {$annotate = 0},
@@@ -454,13 -458,13 +458,13 @@@ my(%suppress_cc)
  if (@suppress_cc) {
        foreach my $entry (@suppress_cc) {
                die sprintf(__("Unknown --suppress-cc field: '%s'\n"), $entry)
 -                      unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc)$/;
 +                      unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc|misc-by)$/;
                $suppress_cc{$entry} = 1;
        }
  }
  
  if ($suppress_cc{'all'}) {
 -      foreach my $entry (qw (cccmd cc author self sob body bodycc)) {
 +      foreach my $entry (qw (cccmd cc author self sob body bodycc misc-by)) {
                $suppress_cc{$entry} = 1;
        }
        delete $suppress_cc{'all'};
@@@ -471,7 -475,7 +475,7 @@@ $suppress_cc{'self'} = $suppress_from i
  $suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc;
  
  if ($suppress_cc{'body'}) {
 -      foreach my $entry (qw (sob bodycc)) {
 +      foreach my $entry (qw (sob bodycc misc-by)) {
                $suppress_cc{$entry} = 1;
        }
        delete $suppress_cc{'body'};
@@@ -1241,7 -1245,7 +1245,7 @@@ sub smtp_host_string 
  # (smtp_user was not specified), and 0 otherwise.
  
  sub smtp_auth_maybe {
-       if (!defined $smtp_authuser || $auth) {
+       if (!defined $smtp_authuser || $auth || (defined $smtp_auth && $smtp_auth eq "none")) {
                return 1;
        }
  
@@@ -1681,7 -1685,7 +1685,7 @@@ sub process_file 
        # Now parse the message body
        while(<$fh>) {
                $message .=  $_;
 -              if (/^(Signed-off-by|Cc): (.*)/i) {
 +              if (/^([a-z-]*-by|Cc): (.*)/i) {
                        chomp;
                        my ($what, $c) = ($1, $2);
                        # strip garbage for the address we'll use:
                        if ($sc eq $sender) {
                                next if ($suppress_cc{'self'});
                        } else {
 -                              next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
 -                              next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
 +                              if ($what =~ /^Signed-off-by$/i) {
 +                                      next if $suppress_cc{'sob'};
 +                              } elsif ($what =~ /-by$/i) {
 +                                      next if $suppress_cc{'misc-by'};
 +                              } elsif ($what =~ /Cc/i) {
 +                                      next if $suppress_cc{'bodycc'};
 +                              }
 +                      }
 +                      if ($c !~ /.+@.+|<.+>/) {
 +                              printf("(body) Ignoring %s from line '%s'\n",
 +                                      $what, $_) unless $quiet;
 +                              next;
                        }
                        push @cc, $c;
                        printf(__("(body) Adding cc: %s from line '%s'\n"),