Ignore .gitattributes in bare repositories
[gitweb.git] / t / t9001-send-email.sh
index a4bcd282b609bb522d8f541a857c274996aa6842..3e4eb63f1c4d63d6ff38c79ff1f7a47fa3aa1597 100755 (executable)
@@ -139,15 +139,16 @@ test_expect_success 'Valid In-Reply-To when prompting' '
 
 test_expect_success 'setup fake editor' '
        (echo "#!/bin/sh" &&
-        echo "echo fake edit >>\$1"
+        echo "echo fake edit >>\"\$1\""
        ) >fake-editor &&
        chmod +x fake-editor
 '
 
+test_set_editor "$(pwd)/fake-editor"
+
 test_expect_success '--compose works' '
        clean_fake_sendmail &&
        echo y | \
-               GIT_EDITOR=$(pwd)/fake-editor \
                GIT_SEND_EMAIL_NOTTY=1 \
                git send-email \
                --compose --subject foo \
@@ -166,14 +167,80 @@ 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_expect_success '--compose adds MIME for utf8 body' '
        clean_fake_sendmail &&
        (echo "#!/bin/sh" &&
-        echo "echo utf8 body: àéìöú >>\$1"
+        echo "echo utf8 body: àéìöú >>\"\$1\""
        ) >fake-editor-utf8 &&
        chmod +x fake-editor-utf8 &&
        echo y | \
-         GIT_EDITOR=$(pwd)/fake-editor-utf8 \
+         GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
          GIT_SEND_EMAIL_NOTTY=1 \
          git send-email \
          --compose --subject foo \
@@ -193,11 +260,11 @@ test_expect_success '--compose respects user mime type' '
         echo " echo Content-Transfer-Encoding: 8bit"
         echo " echo Subject: foo"
         echo " echo "
-        echo " echo utf8 body: àéìöú) >\$1"
+        echo " echo utf8 body: àéìöú) >\"\$1\""
        ) >fake-editor-utf8-mime &&
        chmod +x fake-editor-utf8-mime &&
        echo y | \
-         GIT_EDITOR=$(pwd)/fake-editor-utf8-mime \
+         GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
          GIT_SEND_EMAIL_NOTTY=1 \
          git send-email \
          --compose --subject foo \
@@ -213,7 +280,7 @@ test_expect_success '--compose respects user mime type' '
 test_expect_success '--compose adds MIME for utf8 subject' '
        clean_fake_sendmail &&
        echo y | \
-         GIT_EDITOR=$(pwd)/fake-editor \
+         GIT_EDITOR="\"$(pwd)/fake-editor\"" \
          GIT_SEND_EMAIL_NOTTY=1 \
          git send-email \
          --compose --subject utf8-sübjëct \