Code

Merge branch 'fc/send-email-envelope'
authorJunio C Hamano <gitster@pobox.com>
Mon, 30 Nov 2009 22:42:50 +0000 (14:42 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Nov 2009 22:42:50 +0000 (14:42 -0800)
1  2 
Documentation/git-send-email.txt
git-send-email.perl
t/t9001-send-email.sh

index c85d7f4385b91ce296c0247e3c9b93059abff19d,118c902e7a802ad0cc43f6ae2120a447bc55d70b..8c482f40b98f81460da7230a8656a9a4a97d77df
@@@ -60,8 -60,8 +60,8 @@@ The --bcc option must be repeated for e
  The --cc option must be repeated for each user you want on the cc list.
  
  --compose::
 -      Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an
 -      introductory message for the patch series.
 +      Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
 +      to edit an introductory message for the patch series.
  +
  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
@@@ -108,9 -108,10 +108,10 @@@ Sendin
  --envelope-sender=<address>::
        Specify the envelope sender used to send the emails.
        This is useful if your default address is not the address that is
-       subscribed to a list. If you use the sendmail binary, you must have
-       suitable privileges for the -f parameter. Default is the value of
-       the 'sendemail.envelopesender' configuration variable; if that is
+       subscribed to a list. In order to use the 'From' address, set the
+       value to "auto". If you use the sendmail binary, you must have
+       suitable privileges for the -f parameter.  Default is the value of the
+       'sendemail.envelopesender' configuration variable; if that is
        unspecified, choosing the envelope sender is left to your MTA.
  
  --smtp-encryption=<encryption>::
diff --combined git-send-email.perl
index 6bd4bbc81a33b7402b5152342e4daac3ce89c0a4,9f44e2964a52b84ac3d03b2bbafab8ae3d6a6d2a..319b5356713b02a48508ee9af2d14781d8760e94
@@@ -162,8 -162,7 +162,8 @@@ my $compose_filename
  
  # Handle interactive edition of files.
  my $multiedit;
 -my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
 +my $editor = Git::command_oneline('var', 'GIT_EDITOR');
 +
  sub do_edit {
        if (defined($multiedit) && !$multiedit) {
                map {
@@@ -187,11 -186,9 +187,11 @@@ my ($identity, $aliasfiletype, @alias_f
  my ($validate, $confirm);
  my (@suppress_cc);
  
 +my $not_set_by_user = "true but not set by the user";
 +
  my %config_bool_settings = (
      "thread" => [\$thread, 1],
 -    "chainreplyto" => [\$chain_reply_to, 1],
 +    "chainreplyto" => [\$chain_reply_to, $not_set_by_user],
      "suppressfrom" => [\$suppress_from, undef],
      "signedoffbycc" => [\$signed_off_by_cc, undef],
      "signedoffcc" => [\$signed_off_by_cc, undef],      # Deprecated
@@@ -216,19 -213,6 +216,19 @@@ my %config_settings = 
      "from" => \$sender,
  );
  
 +# Help users prepare for 1.7.0
 +sub chain_reply_to {
 +      if (defined $chain_reply_to &&
 +          $chain_reply_to eq $not_set_by_user) {
 +              print STDERR
 +                  "In git 1.7.0, the default will be changed to --no-chain-reply-to\n" .
 +                  "Set sendemail.chainreplyto configuration variable to true if\n" .
 +                  "you want to keep --chain-reply-to as your default.\n";
 +              $chain_reply_to = 1;
 +      }
 +      return $chain_reply_to;
 +}
 +
  # Handle Uncouth Termination
  sub signal_handler {
  
@@@ -851,7 -835,7 +851,7 @@@ sub send_messag
            $gitversion = Git::version();
        }
  
 -      my $cc = join(", ", unique_email_list(@cc));
 +      my $cc = join(",\n\t", unique_email_list(@cc));
        my $ccline = "";
        if ($cc ne '') {
                $ccline = "\nCc: $cc";
@@@ -877,7 -861,9 +877,9 @@@ X-Mailer: git-send-email $gitversio
  
        my @sendmail_parameters = ('-i', @recipients);
        my $raw_from = $sanitized_sender;
-       $raw_from = $envelope_sender if (defined $envelope_sender);
+       if (defined $envelope_sender && $envelope_sender ne "auto") {
+               $raw_from = $envelope_sender;
+       }
        $raw_from = extract_valid_address($raw_from);
        unshift (@sendmail_parameters,
                        '-f', $raw_from) if(defined $envelope_sender);
                if ($smtp_server !~ m#^/#) {
                        print "Server: $smtp_server\n";
                        print "MAIL FROM:<$raw_from>\n";
 -                      print "RCPT TO:".join(',',(map { "<$_>" } @recipients))."\n";
 +                      foreach my $entry (@recipients) {
 +                          print "RCPT TO:<$entry>\n";
 +                      }
                } else {
                        print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n";
                }
@@@ -1172,7 -1156,7 +1174,7 @@@ foreach my $t (@files) 
  
        # set up for the next message
        if ($thread && $message_was_sent &&
 -              ($chain_reply_to || !defined $reply_to || length($reply_to) == 0)) {
 +              (chain_reply_to() || !defined $reply_to || length($reply_to) == 0)) {
                $reply_to = $message_id;
                if (length $references > 0) {
                        $references .= "\n $message_id";
diff --combined t/t9001-send-email.sh
index 798291240a2c34ddfff50ad7758f7ce8881e8263,c23ea0f3c55013fab6cc42a58d613a1be2b61168..fb51ab3dbea92be5f345517e35c2fcc432c59f45
@@@ -95,6 -95,40 +95,40 @@@ test_expect_success 
      'Verify commandline' \
      'test_cmp expected commandline1'
  
+ test_expect_success 'Send patches with --envelope-sender' '
+     clean_fake_sendmail &&
+      git send-email --envelope-sender="Patch Contributer <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
+ '
+ cat >expected <<\EOF
+ !patch@example.com!
+ !-i!
+ !nobody@example.com!
+ !author@example.com!
+ !one@example.com!
+ !two@example.com!
+ EOF
+ test_expect_success \
+     'Verify commandline' \
+     'test_cmp expected commandline1'
+ test_expect_success 'Send patches with --envelope-sender=auto' '
+     clean_fake_sendmail &&
+      git send-email --envelope-sender=auto --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
+ '
+ cat >expected <<\EOF
+ !nobody@example.com!
+ !-i!
+ !nobody@example.com!
+ !author@example.com!
+ !one@example.com!
+ !two@example.com!
+ EOF
+ test_expect_success \
+     'Verify commandline' \
+     'test_cmp expected commandline1'
  cat >expected-show-all-headers <<\EOF
  0001-Second.patch
  (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
  Dry-OK. Log says:
  Server: relay.example.com
  MAIL FROM:<from@example.com>
 -RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com>
 +RCPT TO:<to@example.com>
 +RCPT TO:<cc@example.com>
 +RCPT TO:<author@example.com>
 +RCPT TO:<one@example.com>
 +RCPT TO:<two@example.com>
 +RCPT TO:<bcc@example.com>
  From: Example <from@example.com>
  To: to@example.com
 -Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
 +Cc: cc@example.com,
 +      A <author@example.com>,
 +      One <one@example.com>,
 +      two@example.com
  Subject: [PATCH 1/1] Second.
  Date: DATE-STRING
  Message-Id: MESSAGE-ID-STRING
@@@ -172,7 -198,7 +206,7 @@@ test_expect_success 'cccmd works' 
                --smtp-server="$(pwd)/fake.sendmail" \
                cccmd.patch \
                &&
 -      grep ^Cc:.*cccmd@example.com msgtxt1
 +      grep "^ cccmd@example.com" msgtxt1
  '
  
  z8=zzzzzzzz
@@@ -286,17 -312,10 +320,17 @@@ cat >expected-suppress-sob <<\EO
  Dry-OK. Log says:
  Server: relay.example.com
  MAIL FROM:<from@example.com>
 -RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
 +RCPT TO:<to@example.com>
 +RCPT TO:<cc@example.com>
 +RCPT TO:<author@example.com>
 +RCPT TO:<one@example.com>
 +RCPT TO:<two@example.com>
  From: Example <from@example.com>
  To: to@example.com
 -Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
 +Cc: cc@example.com,
 +      A <author@example.com>,
 +      One <one@example.com>,
 +      two@example.com
  Subject: [PATCH 1/1] Second.
  Date: DATE-STRING
  Message-Id: MESSAGE-ID-STRING
@@@ -333,15 -352,10 +367,15 @@@ cat >expected-suppress-sob <<\EO
  Dry-OK. Log says:
  Server: relay.example.com
  MAIL FROM:<from@example.com>
 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
 +RCPT TO:<to@example.com>
 +RCPT TO:<author@example.com>
 +RCPT TO:<one@example.com>
 +RCPT TO:<two@example.com>
  From: Example <from@example.com>
  To: to@example.com
 -Cc: A <author@example.com>, One <one@example.com>, two@example.com
 +Cc: A <author@example.com>,
 +      One <one@example.com>,
 +      two@example.com
  Subject: [PATCH 1/1] Second.
  Date: DATE-STRING
  Message-Id: MESSAGE-ID-STRING
@@@ -364,17 -378,10 +398,17 @@@ cat >expected-suppress-cccmd <<\EO
  Dry-OK. Log says:
  Server: relay.example.com
  MAIL FROM:<from@example.com>
 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
 +RCPT TO:<to@example.com>
 +RCPT TO:<author@example.com>
 +RCPT TO:<one@example.com>
 +RCPT TO:<two@example.com>
 +RCPT TO:<committer@example.com>
  From: Example <from@example.com>
  To: to@example.com
 -Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
 +Cc: A <author@example.com>,
 +      One <one@example.com>,
 +      two@example.com,
 +      C O Mitter <committer@example.com>
  Subject: [PATCH 1/1] Second.
  Date: DATE-STRING
  Message-Id: MESSAGE-ID-STRING
@@@ -419,17 -426,10 +453,17 @@@ cat >expected-suppress-body <<\EO
  Dry-OK. Log says:
  Server: relay.example.com
  MAIL FROM:<from@example.com>
 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com>
 +RCPT TO:<to@example.com>
 +RCPT TO:<author@example.com>
 +RCPT TO:<one@example.com>
 +RCPT TO:<two@example.com>
 +RCPT TO:<cc-cmd@example.com>
  From: Example <from@example.com>
  To: to@example.com
 -Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com
 +Cc: A <author@example.com>,
 +      One <one@example.com>,
 +      two@example.com,
 +      cc-cmd@example.com
  Subject: [PATCH 1/1] Second.
  Date: DATE-STRING
  Message-Id: MESSAGE-ID-STRING
@@@ -450,15 -450,10 +484,15 @@@ cat >expected-suppress-body-cccmd <<\EO
  Dry-OK. Log says:
  Server: relay.example.com
  MAIL FROM:<from@example.com>
 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
 +RCPT TO:<to@example.com>
 +RCPT TO:<author@example.com>
 +RCPT TO:<one@example.com>
 +RCPT TO:<two@example.com>
  From: Example <from@example.com>
  To: to@example.com
 -Cc: A <author@example.com>, One <one@example.com>, two@example.com
 +Cc: A <author@example.com>,
 +      One <one@example.com>,
 +      two@example.com
  Subject: [PATCH 1/1] Second.
  Date: DATE-STRING
  Message-Id: MESSAGE-ID-STRING
@@@ -479,15 -474,10 +513,15 @@@ cat >expected-suppress-sob <<\EO
  Dry-OK. Log says:
  Server: relay.example.com
  MAIL FROM:<from@example.com>
 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
 +RCPT TO:<to@example.com>
 +RCPT TO:<author@example.com>
 +RCPT TO:<one@example.com>
 +RCPT TO:<two@example.com>
  From: Example <from@example.com>
  To: to@example.com
 -Cc: A <author@example.com>, One <one@example.com>, two@example.com
 +Cc: A <author@example.com>,
 +      One <one@example.com>,
 +      two@example.com
  Subject: [PATCH 1/1] Second.
  Date: DATE-STRING
  Message-Id: MESSAGE-ID-STRING
@@@ -510,17 -500,10 +544,17 @@@ cat >expected-suppress-bodycc <<\EO
  Dry-OK. Log says:
  Server: relay.example.com
  MAIL FROM:<from@example.com>
 -RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
 +RCPT TO:<to@example.com>
 +RCPT TO:<author@example.com>
 +RCPT TO:<one@example.com>
 +RCPT TO:<two@example.com>
 +RCPT TO:<committer@example.com>
  From: Example <from@example.com>
  To: to@example.com
 -Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
 +Cc: A <author@example.com>,
 +      One <one@example.com>,
 +      two@example.com,
 +      C O Mitter <committer@example.com>
  Subject: [PATCH 1/1] Second.
  Date: DATE-STRING
  Message-Id: MESSAGE-ID-STRING
@@@ -540,13 -523,10 +574,13 @@@ cat >expected-suppress-cc <<\EO
  Dry-OK. Log says:
  Server: relay.example.com
  MAIL FROM:<from@example.com>
 -RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com>
 +RCPT TO:<to@example.com>
 +RCPT TO:<author@example.com>
 +RCPT TO:<committer@example.com>
  From: Example <from@example.com>
  To: to@example.com
 -Cc: A <author@example.com>, C O Mitter <committer@example.com>
 +Cc: A <author@example.com>,
 +      C O Mitter <committer@example.com>
  Subject: [PATCH 1/1] Second.
  Date: DATE-STRING
  Message-Id: MESSAGE-ID-STRING
@@@ -659,7 -639,7 +693,7 @@@ test_expect_success 'utf8 Cc is rfc204
        --to=nobody@example.com \
        --smtp-server="$(pwd)/fake.sendmail" \
        outdir/*.patch &&
 -      grep "^Cc:" msgtxt1 |
 +      grep "^ " msgtxt1 |
        grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
  '
  
@@@ -769,53 -749,4 +803,53 @@@ test_expect_success 'threading but no c
        grep "In-Reply-To: " stdout
  '
  
 +test_expect_success 'warning with an implicit --chain-reply-to' '
 +      git send-email \
 +      --dry-run \
 +      --from="Example <nobody@example.com>" \
 +      --to=nobody@example.com \
 +      outdir/000?-*.patch 2>errors >out &&
 +      grep "no-chain-reply-to" errors
 +'
 +
 +test_expect_success 'no warning with an explicit --chain-reply-to' '
 +      git send-email \
 +      --dry-run \
 +      --from="Example <nobody@example.com>" \
 +      --to=nobody@example.com \
 +      --chain-reply-to \
 +      outdir/000?-*.patch 2>errors >out &&
 +      ! grep "no-chain-reply-to" errors
 +'
 +
 +test_expect_success 'no warning with an explicit --no-chain-reply-to' '
 +      git send-email \
 +      --dry-run \
 +      --from="Example <nobody@example.com>" \
 +      --to=nobody@example.com \
 +      --no-chain-reply-to \
 +      outdir/000?-*.patch 2>errors >out &&
 +      ! grep "no-chain-reply-to" errors
 +'
 +
 +test_expect_success 'no warning with sendemail.chainreplyto = false' '
 +      git config sendemail.chainreplyto false &&
 +      git send-email \
 +      --dry-run \
 +      --from="Example <nobody@example.com>" \
 +      --to=nobody@example.com \
 +      outdir/000?-*.patch 2>errors >out &&
 +      ! grep "no-chain-reply-to" errors
 +'
 +
 +test_expect_success 'no warning with sendemail.chainreplyto = true' '
 +      git config sendemail.chainreplyto true &&
 +      git send-email \
 +      --dry-run \
 +      --from="Example <nobody@example.com>" \
 +      --to=nobody@example.com \
 +      outdir/000?-*.patch 2>errors >out &&
 +      ! grep "no-chain-reply-to" errors
 +'
 +
  test_done