Merge branch 'mt/send-email-cover-to-cc'
authorJunio C Hamano <gitster@pobox.com>
Fri, 20 Jun 2014 20:12:19 +0000 (13:12 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Jun 2014 20:12:20 +0000 (13:12 -0700)
* mt/send-email-cover-to-cc:
t9001: avoid non-portable '\n' with sed
test/send-email: to-cover, cc-cover tests
git-send-email: two new options: to-cover, cc-cover

1  2 
Documentation/git-send-email.txt
git-send-email.perl
index d0fa18aaa8b14f9171800a05742fb1fe326b547b,b983053f8598e47ed033ea30cbcd46a4b008db59..a60776eb579e10507814c643cc292dfa99750aa9
@@@ -20,7 -20,7 +20,7 @@@ files in the directory), or directly a
  last case, any format accepted by linkgit:git-format-patch[1] can
  be passed to git send-email.
  
 -The header of the email is configurable by command line options.  If not
 +The header of the email is configurable via command-line options.  If not
  specified on the command line, the user will be prompted with a ReadLine
  enabled interface to provide the necessary information.
  
@@@ -68,7 -68,7 +68,7 @@@ The --cc option must be repeated for ea
  When '--compose' is used, git send-email will use the From, Subject, and
  In-Reply-To headers specified in the message. If the body of the message
  (what you type after the headers and a blank line) only contains blank
 -(or Git: prefixed) lines the summary won't be sent, but From, Subject,
 +(or Git: prefixed) lines, the summary won't be sent, but From, Subject,
  and In-Reply-To headers will be used unless they are removed.
  +
  Missing From or In-Reply-To headers will be prompted for.
@@@ -78,7 -78,7 +78,7 @@@ See the CONFIGURATION section for 'send
  --from=<address>::
        Specify the sender of the emails.  If not specified on the command line,
        the value of the 'sendemail.from' configuration option is used.  If
 -      neither the command line option nor 'sendemail.from' are set, then the
 +      neither the command-line option nor 'sendemail.from' are set, then the
        user will be prompted for the value.  The default for the prompt will be
        the value of GIT_AUTHOR_IDENT, or GIT_COMMITTER_IDENT if that is not
        set, as returned by "git var -l".
@@@ -248,6 -248,18 +248,18 @@@ Automatin
        cc list. Default is the value of 'sendemail.signedoffbycc' configuration
        value; if that is unspecified, default to --signed-off-by-cc.
  
+ --[no-]cc-cover::
+       If this is set, emails found in Cc: headers in the first patch of
+       the series (typically the cover letter) are added to the cc list
+       for each email set. Default is the value of 'sendemail.cccover'
+       configuration value; if that is unspecified, default to --no-cc-cover.
+ --[no-]to-cover::
+       If this is set, emails found in To: headers in the first patch of
+       the series (typically the cover letter) are added to the to list
+       for each email set. Default is the value of 'sendemail.tocover'
+       configuration value; if that is unspecified, default to --no-to-cover.
  --suppress-cc=<category>::
        Specify an additional category of recipients to suppress the
        auto-cc of:
diff --combined git-send-email.perl
index abd62b484cdaef8e6ab5ba366551c03959c08beb,d884b4821d64792258568b59e0983721378ca32a..9949db01e11959c81fae75fa018551601e6d5c3b
@@@ -80,6 -80,8 +80,8 @@@ git send-email [options] <file | direct
      --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.
+     --[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.
      --[no-]suppress-from           * Send to self. Default off.
      --[no-]chain-reply-to          * Chain In-Reply-To: fields. Default off.
@@@ -195,6 -197,7 +197,7 @@@ sub do_edit 
  
  # Variables with corresponding config settings
  my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc);
+ 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);
@@@ -211,6 -214,8 +214,8 @@@ my %config_bool_settings = 
      "chainreplyto" => [\$chain_reply_to, 0],
      "suppressfrom" => [\$suppress_from, undef],
      "signedoffbycc" => [\$signed_off_by_cc, undef],
+     "cccover" => [\$cover_cc, undef],
+     "tocover" => [\$cover_to, undef],
      "signedoffcc" => [\$signed_off_by_cc, undef],      # Deprecated
      "validate" => [\$validate, 1],
      "multiedit" => [\$multiedit, undef],
@@@ -302,6 -307,8 +307,8 @@@ my $rc = GetOptions("h" => \$help
                    "suppress-from!" => \$suppress_from,
                    "suppress-cc=s" => \@suppress_cc,
                    "signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
+                   "cc-cover|cc-cover!" => \$cover_cc,
+                   "to-cover|to-cover!" => \$cover_to,
                    "confirm=s" => \$confirm,
                    "dry-run" => \$dry_run,
                    "envelope-sender=s" => \$envelope_sender,
@@@ -1113,18 -1120,6 +1120,18 @@@ sub ssl_verify_params 
        }
  }
  
 +sub file_name_is_absolute {
 +      my ($path) = @_;
 +
 +      # msys does not grok DOS drive-prefixes
 +      if ($^O eq 'msys') {
 +              return ($path =~ m#^/# || $path =~ m#^[a-zA-Z]\:#)
 +      }
 +
 +      require File::Spec::Functions;
 +      return File::Spec::Functions::file_name_is_absolute($path);
 +}
 +
  # Returns 1 if the message was sent, and 0 otherwise.
  # In actuality, the whole program dies when there
  # is an error sending a message.
@@@ -1209,7 -1204,7 +1216,7 @@@ X-Mailer: git-send-email $gitversio
  
        if ($dry_run) {
                # We don't want to send the email.
 -      } elsif ($smtp_server =~ m#^/#) {
 +      } elsif (file_name_is_absolute($smtp_server)) {
                my $pid = open my $sm, '|-';
                defined $pid or die $!;
                if (!$pid) {
                printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
        } else {
                print (($dry_run ? "Dry-" : "")."OK. Log says:\n");
 -              if ($smtp_server !~ m#^/#) {
 +              if (!file_name_is_absolute($smtp_server)) {
                        print "Server: $smtp_server\n";
                        print "MAIL FROM:<$raw_from>\n";
                        foreach my $entry (@recipients) {
@@@ -1481,6 -1476,15 +1488,15 @@@ foreach my $t (@files) 
        @to = (@initial_to, @to);
        @cc = (@initial_cc, @cc);
  
+       if ($message_num == 1) {
+               if (defined $cover_cc and $cover_cc) {
+                       @initial_cc = @cc;
+               }
+               if (defined $cover_to and $cover_to) {
+                       @initial_to = @to;
+               }
+       }
        my $message_was_sent = send_message();
  
        # set up for the next message