Merge branch 'mv/format-cc'
authorJunio C Hamano <gitster@pobox.com>
Wed, 14 May 2008 20:34:34 +0000 (13:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 May 2008 20:34:34 +0000 (13:34 -0700)
* mv/format-cc:
Add tests for sendemail.cc configuration variable
git-send-email: add a new sendemail.cc configuration variable
git-format-patch: add a new format.cc configuration variable

Documentation/git-format-patch.txt
builtin-log.c
git-send-email.perl
t/t9001-send-email.sh
index 7548a21d352f0625a114f48c3063612f2a063436..c60ce123ec745e1903da0b5ab50e4efabeeb5dc3 100644 (file)
@@ -174,6 +174,7 @@ and file suffix, and number patches when outputting more than one.
         subjectprefix = CHANGE
         suffix = .txt
         numbered = auto
+       cc = <email>
 ------------
 
 
index 80a01f8d44a40608e989b1cc1973a28c0b9040a5..9d046b2e035bfa6ae63d6d004e5a92072a202d70 100644 (file)
@@ -485,6 +485,13 @@ static int git_format_config(const char *var, const char *value)
                fmt_patch_suffix = xstrdup(value);
                return 0;
        }
+       if (!strcmp(var, "format.cc")) {
+               if (!value)
+                       return config_error_nonbool(var);
+               ALLOC_GROW(extra_cc, extra_cc_nr + 1, extra_cc_alloc);
+               extra_cc[extra_cc_nr++] = xstrdup(value);
+               return 0;
+       }
        if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
                return 0;
        }
index 9e568bf9c012b610fd8db7e4444cb7ff8c6e0a0f..cb05cf5b9ebc41c6d95067037605154c5a83e9b1 100755 (executable)
@@ -203,6 +203,7 @@ sub format_2822_time {
     "smtpuser" => \$smtp_authuser,
     "smtppass" => \$smtp_authpass,
     "to" => \@to,
+    "cc" => \@initial_cc,
     "cccmd" => \$cc_cmd,
     "aliasfiletype" => \$aliasfiletype,
     "bcc" => \@bcclist,
index c0973b4e6ee2c6a55d1573e2341607c4adfcbb10..af655cf526930734436ad6daee667e661c229a48 100755 (executable)
@@ -166,4 +166,70 @@ test_expect_success 'second message is patch' '
        grep "Subject:.*Second" msgtxt2
 '
 
+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>
+From: Example <from@example.com>
+To: to@example.com
+Cc: cc@example.com, A <author@example.com>
+Subject: [PATCH 1/1] Second.
+Date: DATE-STRING
+Message-Id: MESSAGE-ID-STRING
+X-Mailer: X-MAILER-STRING
+
+Result: OK
+EOF
+
+test_expect_success 'sendemail.cc set' '
+       git config sendemail.cc cc@example.com &&
+       git send-email \
+               --dry-run \
+               --from="Example <from@example.com>" \
+               --to=to@example.com \
+               --smtp-server relay.example.com \
+               $patches |
+       sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
+               -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
+               -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
+               >actual-show-all-headers &&
+       test_cmp expected-show-all-headers actual-show-all-headers
+'
+
+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>,<author@example.com>
+From: Example <from@example.com>
+To: to@example.com
+Cc: A <author@example.com>
+Subject: [PATCH 1/1] Second.
+Date: DATE-STRING
+Message-Id: MESSAGE-ID-STRING
+X-Mailer: X-MAILER-STRING
+
+Result: OK
+EOF
+
+test_expect_success 'sendemail.cc unset' '
+       git config --unset sendemail.cc &&
+       git send-email \
+               --dry-run \
+               --from="Example <from@example.com>" \
+               --to=to@example.com \
+               --smtp-server relay.example.com \
+               $patches |
+       sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
+               -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
+               -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
+               >actual-show-all-headers &&
+       test_cmp expected-show-all-headers actual-show-all-headers
+'
+
 test_done