Ryan Anderson | ce90301 | 2006-05-29 12:30:15 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Nanako Shiraishi | 47a528a | 2008-09-03 17:59:33 +0900 | [diff] [blame] | 3 | test_description='git send-email' |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 6 | |
Jeff King | cfa1209 | 2023-05-18 20:03:25 -0400 | [diff] [blame] | 7 | TEST_PASSES_SANITIZE_LEAK=true |
Ryan Anderson | ce90301 | 2006-05-29 12:30:15 -0700 | [diff] [blame] | 8 | . ./test-lib.sh |
| 9 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 10 | # May be altered later in the test |
| 11 | PREREQ="PERL" |
Jeff King | 1b19ccd | 2009-04-03 15:33:59 -0400 | [diff] [blame] | 12 | |
Christian Ludwig | ec3b4b0 | 2018-01-12 11:37:24 +0100 | [diff] [blame] | 13 | replace_variable_fields () { |
| 14 | sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 15 | -e "s/^\(Message-ID:\).*/\1 MESSAGE-ID-STRING/" \ |
Christian Ludwig | ec3b4b0 | 2018-01-12 11:37:24 +0100 | [diff] [blame] | 16 | -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" |
| 17 | } |
| 18 | |
Junio C Hamano | aca5606 | 2014-11-25 14:11:39 -0800 | [diff] [blame] | 19 | test_expect_success $PREREQ 'prepare reference tree' ' |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 20 | echo "1A quick brown fox jumps over the" >file && |
| 21 | echo "lazy dog" >>file && |
| 22 | git add file && |
| 23 | GIT_AUTHOR_NAME="A" git commit -a -m "Initial." |
Junio C Hamano | aca5606 | 2014-11-25 14:11:39 -0800 | [diff] [blame] | 24 | ' |
Ryan Anderson | ce90301 | 2006-05-29 12:30:15 -0700 | [diff] [blame] | 25 | |
Junio C Hamano | aca5606 | 2014-11-25 14:11:39 -0800 | [diff] [blame] | 26 | test_expect_success $PREREQ 'Setup helper tool' ' |
Junio C Hamano | acd72b5 | 2014-11-25 14:21:07 -0800 | [diff] [blame] | 27 | write_script fake.sendmail <<-\EOF && |
| 28 | shift |
| 29 | output=1 |
| 30 | while test -f commandline$output |
| 31 | do |
| 32 | output=$(($output+1)) |
| 33 | done |
| 34 | for a |
| 35 | do |
| 36 | echo "!$a!" |
| 37 | done >commandline$output |
| 38 | cat >"msgtxt$output" |
| 39 | EOF |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 40 | git add fake.sendmail && |
| 41 | GIT_AUTHOR_NAME="A" git commit -a -m "Second." |
Junio C Hamano | aca5606 | 2014-11-25 14:11:39 -0800 | [diff] [blame] | 42 | ' |
Ryan Anderson | ce90301 | 2006-05-29 12:30:15 -0700 | [diff] [blame] | 43 | |
Junio C Hamano | ee756a8 | 2014-11-25 14:52:42 -0800 | [diff] [blame] | 44 | clean_fake_sendmail () { |
Jeff King | 6d34a2b | 2008-02-24 16:03:52 -0500 | [diff] [blame] | 45 | rm -f commandline* msgtxt* |
| 46 | } |
| 47 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 48 | test_expect_success $PREREQ 'Extract patches' ' |
Rafael Aquini | f9f60d7 | 2020-06-29 10:11:04 -0400 | [diff] [blame] | 49 | patches=$(git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1) && |
Junio C Hamano | 3ece9bf | 2023-05-17 14:10:39 -0700 | [diff] [blame] | 50 | threaded_patches=$(git format-patch -o threaded --thread=shallow -s --in-reply-to="format" HEAD^1) |
Junio C Hamano | 280242d | 2006-07-02 16:03:59 -0700 | [diff] [blame] | 51 | ' |
| 52 | |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 53 | # Test no confirm early to ensure remaining tests will not hang |
| 54 | test_no_confirm () { |
| 55 | rm -f no_confirm_okay |
| 56 | echo n | \ |
| 57 | GIT_SEND_EMAIL_NOTTY=1 \ |
| 58 | git send-email \ |
| 59 | --from="Example <from@example.com>" \ |
| 60 | --to=nobody@example.com \ |
| 61 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 62 | $@ \ |
Junio C Hamano | ee756a8 | 2014-11-25 14:52:42 -0800 | [diff] [blame] | 63 | $patches >stdout && |
Oswald Buddenhagen | b46d806 | 2023-08-13 12:46:49 +0200 | [diff] [blame] | 64 | ! grep "Send this email" stdout && |
| 65 | >no_confirm_okay |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | # Exit immediately to prevent hang if a no-confirm test fails |
| 69 | check_no_confirm () { |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 70 | if ! test -f no_confirm_okay |
| 71 | then |
| 72 | say 'confirm test failed; skipping remaining tests to prevent hanging' |
| 73 | PREREQ="$PREREQ,CHECK_NO_CONFIRM" |
| 74 | fi |
| 75 | return 0 |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 76 | } |
| 77 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 78 | test_expect_success $PREREQ 'No confirm with --suppress-cc' ' |
| 79 | test_no_confirm --suppress-cc=sob && |
| 80 | check_no_confirm |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 81 | ' |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 82 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 83 | |
| 84 | test_expect_success $PREREQ 'No confirm with --confirm=never' ' |
| 85 | test_no_confirm --confirm=never && |
| 86 | check_no_confirm |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 87 | ' |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 88 | |
| 89 | # leave sendemail.confirm set to never after this so that none of the |
| 90 | # remaining tests prompt unintentionally. |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 91 | test_expect_success $PREREQ 'No confirm with sendemail.confirm=never' ' |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 92 | git config sendemail.confirm never && |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 93 | test_no_confirm --compose --subject=foo && |
| 94 | check_no_confirm |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 95 | ' |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 96 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 97 | test_expect_success $PREREQ 'Send patches' ' |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 98 | git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors |
Junio C Hamano | 280242d | 2006-07-02 16:03:59 -0700 | [diff] [blame] | 99 | ' |
Ryan Anderson | ce90301 | 2006-05-29 12:30:15 -0700 | [diff] [blame] | 100 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 101 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 102 | cat >expected <<-\EOF |
| 103 | !nobody@example.com! |
| 104 | !author@example.com! |
| 105 | !one@example.com! |
| 106 | !two@example.com! |
| 107 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 108 | ' |
| 109 | |
Junio C Hamano | aca5606 | 2014-11-25 14:11:39 -0800 | [diff] [blame] | 110 | test_expect_success $PREREQ 'Verify commandline' ' |
| 111 | test_cmp expected commandline1 |
| 112 | ' |
Ryan Anderson | ce90301 | 2006-05-29 12:30:15 -0700 | [diff] [blame] | 113 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 114 | test_expect_success $PREREQ 'Send patches with --envelope-sender' ' |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 115 | clean_fake_sendmail && |
| 116 | git send-email --envelope-sender="Patch Contributor <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors |
Junio C Hamano | 4f333bc | 2009-11-22 09:54:10 -0800 | [diff] [blame] | 117 | ' |
| 118 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 119 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 120 | cat >expected <<-\EOF |
| 121 | !patch@example.com! |
| 122 | !-i! |
| 123 | !nobody@example.com! |
| 124 | !author@example.com! |
| 125 | !one@example.com! |
| 126 | !two@example.com! |
| 127 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 128 | ' |
| 129 | |
Junio C Hamano | aca5606 | 2014-11-25 14:11:39 -0800 | [diff] [blame] | 130 | test_expect_success $PREREQ 'Verify commandline' ' |
| 131 | test_cmp expected commandline1 |
| 132 | ' |
Junio C Hamano | 4f333bc | 2009-11-22 09:54:10 -0800 | [diff] [blame] | 133 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 134 | test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' ' |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 135 | clean_fake_sendmail && |
| 136 | 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 |
Felipe Contreras | c89e324 | 2009-11-26 21:04:29 +0200 | [diff] [blame] | 137 | ' |
| 138 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 139 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 140 | cat >expected <<-\EOF |
| 141 | !nobody@example.com! |
| 142 | !-i! |
| 143 | !nobody@example.com! |
| 144 | !author@example.com! |
| 145 | !one@example.com! |
| 146 | !two@example.com! |
| 147 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 148 | ' |
| 149 | |
Junio C Hamano | aca5606 | 2014-11-25 14:11:39 -0800 | [diff] [blame] | 150 | test_expect_success $PREREQ 'Verify commandline' ' |
| 151 | test_cmp expected commandline1 |
| 152 | ' |
Felipe Contreras | c89e324 | 2009-11-26 21:04:29 +0200 | [diff] [blame] | 153 | |
Matthieu Moy | e3fdbcc | 2016-10-13 07:47:27 +0200 | [diff] [blame] | 154 | test_expect_success $PREREQ 'setup expect for cc trailer' " |
| 155 | cat >expected-cc <<\EOF |
| 156 | !recipient@example.com! |
| 157 | !author@example.com! |
| 158 | !one@example.com! |
| 159 | !two@example.com! |
| 160 | !three@example.com! |
| 161 | !four@example.com! |
Matthieu Moy | cb2922f | 2017-08-23 12:21:01 +0200 | [diff] [blame] | 162 | !five@example.com! |
| 163 | !six@example.com! |
Matthieu Moy | e3fdbcc | 2016-10-13 07:47:27 +0200 | [diff] [blame] | 164 | EOF |
| 165 | " |
| 166 | |
| 167 | test_expect_success $PREREQ 'cc trailer with various syntax' ' |
| 168 | test_commit cc-trailer && |
| 169 | test_when_finished "git reset --hard HEAD^" && |
| 170 | git commit --amend -F - <<-EOF && |
| 171 | Test Cc: trailers. |
| 172 | |
| 173 | Cc: one@example.com |
Johan Hovold | 9d33439 | 2017-02-20 12:44:06 +0100 | [diff] [blame] | 174 | Cc: <two@example.com> # trailing comments are ignored |
| 175 | Cc: <three@example.com>, <not.four@example.com> one address per line |
| 176 | Cc: "Some # Body" <four@example.com> [ <also.a.comment> ] |
Matthieu Moy | cb2922f | 2017-08-23 12:21:01 +0200 | [diff] [blame] | 177 | Cc: five@example.com # not.six@example.com |
| 178 | Cc: six@example.com, not.seven@example.com |
Matthieu Moy | e3fdbcc | 2016-10-13 07:47:27 +0200 | [diff] [blame] | 179 | EOF |
| 180 | clean_fake_sendmail && |
| 181 | git send-email -1 --to=recipient@example.com \ |
| 182 | --smtp-server="$(pwd)/fake.sendmail" && |
| 183 | test_cmp expected-cc commandline1 |
| 184 | ' |
| 185 | |
Alex Bennée | d60be8a | 2018-01-08 11:34:34 +0100 | [diff] [blame] | 186 | test_expect_success $PREREQ 'setup fake get_maintainer.pl script for cc trailer' " |
| 187 | write_script expected-cc-script.sh <<-EOF |
| 188 | echo 'One Person <one@example.com> (supporter:THIS (FOO/bar))' |
| 189 | echo 'Two Person <two@example.com> (maintainer:THIS THING)' |
| 190 | echo 'Third List <three@example.com> (moderated list:THIS THING (FOO/bar))' |
| 191 | echo '<four@example.com> (moderated list:FOR THING)' |
| 192 | echo 'five@example.com (open list:FOR THING (FOO/bar))' |
| 193 | echo 'six@example.com (open list)' |
| 194 | EOF |
| 195 | " |
| 196 | |
| 197 | test_expect_success $PREREQ 'cc trailer with get_maintainer.pl output' ' |
| 198 | clean_fake_sendmail && |
| 199 | git send-email -1 --to=recipient@example.com \ |
| 200 | --cc-cmd=./expected-cc-script.sh \ |
| 201 | --smtp-server="$(pwd)/fake.sendmail" && |
| 202 | test_cmp expected-cc commandline1 |
| 203 | ' |
| 204 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 205 | test_expect_success $PREREQ 'setup expect' " |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 206 | cat >expected-show-all-headers <<\EOF |
| 207 | 0001-Second.patch |
| 208 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' |
Jay Soffian | 5012699 | 2009-02-14 23:32:14 -0500 | [diff] [blame] | 209 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
| 210 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 211 | Dry-OK. Log says: |
| 212 | Server: relay.example.com |
| 213 | MAIL FROM:<from@example.com> |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 214 | RCPT TO:<to@example.com> |
| 215 | RCPT TO:<cc@example.com> |
| 216 | RCPT TO:<author@example.com> |
| 217 | RCPT TO:<one@example.com> |
| 218 | RCPT TO:<two@example.com> |
| 219 | RCPT TO:<bcc@example.com> |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 220 | From: Example <from@example.com> |
| 221 | To: to@example.com |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 222 | Cc: cc@example.com, |
| 223 | A <author@example.com>, |
| 224 | One <one@example.com>, |
| 225 | two@example.com |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 226 | Subject: [PATCH 1/1] Second. |
| 227 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 228 | Message-ID: MESSAGE-ID-STRING |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 229 | X-Mailer: X-MAILER-STRING |
| 230 | In-Reply-To: <unique-message-id@example.com> |
| 231 | References: <unique-message-id@example.com> |
Christian Ludwig | d11c943 | 2018-03-04 00:58:14 +0100 | [diff] [blame] | 232 | Reply-To: Reply <reply@example.com> |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 233 | MIME-Version: 1.0 |
| 234 | Content-Transfer-Encoding: 8bit |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 235 | |
| 236 | Result: OK |
| 237 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 238 | " |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 239 | |
Michael S. Tsirkin | 5adcf2c | 2013-05-30 10:11:13 +0300 | [diff] [blame] | 240 | test_suppress_self () { |
| 241 | test_commit $3 && |
| 242 | test_when_finished "git reset --hard HEAD^" && |
| 243 | |
| 244 | write_script cccmd-sed <<-EOF && |
| 245 | sed -n -e s/^cccmd--//p "\$1" |
| 246 | EOF |
| 247 | |
| 248 | git commit --amend --author="$1 <$2>" -F - && |
| 249 | clean_fake_sendmail && |
| 250 | git format-patch --stdout -1 >"suppress-self-$3.patch" && |
| 251 | |
| 252 | git send-email --from="$1 <$2>" \ |
| 253 | --to=nobody@example.com \ |
| 254 | --cc-cmd=./cccmd-sed \ |
| 255 | --suppress-cc=self \ |
| 256 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 257 | suppress-self-$3.patch && |
| 258 | |
| 259 | mv msgtxt1 msgtxt1-$3 && |
| 260 | sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" && |
Michael S. Tsirkin | 5adcf2c | 2013-05-30 10:11:13 +0300 | [diff] [blame] | 261 | |
| 262 | (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3"; |
Ævar Arnfjörð Bjarmason | d3c6751 | 2018-07-27 17:48:11 +0000 | [diff] [blame] | 263 | test_must_be_empty actual-no-cc-$3) |
Michael S. Tsirkin | 5adcf2c | 2013-05-30 10:11:13 +0300 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | test_suppress_self_unquoted () { |
| 267 | test_suppress_self "$1" "$2" "unquoted-$3" <<-EOF |
| 268 | test suppress-cc.self unquoted-$3 with name $1 email $2 |
| 269 | |
| 270 | unquoted-$3 |
| 271 | |
Michael S. Tsirkin | d6ee445 | 2013-06-05 21:10:57 +0300 | [diff] [blame] | 272 | cccmd--$1 <$2> |
| 273 | |
Michael S. Tsirkin | 5adcf2c | 2013-05-30 10:11:13 +0300 | [diff] [blame] | 274 | Cc: $1 <$2> |
| 275 | Signed-off-by: $1 <$2> |
| 276 | EOF |
| 277 | } |
| 278 | |
Michael S. Tsirkin | dd29f0b | 2013-06-05 21:11:02 +0300 | [diff] [blame] | 279 | test_suppress_self_quoted () { |
| 280 | test_suppress_self "$1" "$2" "quoted-$3" <<-EOF |
| 281 | test suppress-cc.self quoted-$3 with name $1 email $2 |
| 282 | |
| 283 | quoted-$3 |
| 284 | |
| 285 | cccmd--"$1" <$2> |
| 286 | |
| 287 | Cc: $1 <$2> |
| 288 | Cc: "$1" <$2> |
| 289 | Signed-off-by: $1 <$2> |
| 290 | Signed-off-by: "$1" <$2> |
| 291 | EOF |
| 292 | } |
| 293 | |
Michael S. Tsirkin | 5adcf2c | 2013-05-30 10:11:13 +0300 | [diff] [blame] | 294 | test_expect_success $PREREQ 'self name is suppressed' " |
Michael S. Tsirkin | d6ee445 | 2013-06-05 21:10:57 +0300 | [diff] [blame] | 295 | test_suppress_self_unquoted 'A U Thor' 'author@example.com' \ |
Michael S. Tsirkin | 5adcf2c | 2013-05-30 10:11:13 +0300 | [diff] [blame] | 296 | 'self_name_suppressed' |
| 297 | " |
| 298 | |
Michael S. Tsirkin | dd29f0b | 2013-06-05 21:11:02 +0300 | [diff] [blame] | 299 | test_expect_success $PREREQ 'self name with dot is suppressed' " |
| 300 | test_suppress_self_quoted 'A U. Thor' 'author@example.com' \ |
| 301 | 'self_name_dot_suppressed' |
| 302 | " |
| 303 | |
Michael S. Tsirkin | 4b45bcf | 2013-06-05 21:11:04 +0300 | [diff] [blame] | 304 | test_expect_success $PREREQ 'non-ascii self name is suppressed' " |
| 305 | test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \ |
| 306 | 'non_ascii_self_suppressed' |
| 307 | " |
| 308 | |
Роман Донченко | ab47e2a | 2014-12-14 18:59:47 +0300 | [diff] [blame] | 309 | # This name is long enough to force format-patch to split it into multiple |
| 310 | # encoded-words, assuming it uses UTF-8 with the "Q" encoding. |
| 311 | test_expect_success $PREREQ 'long non-ascii self name is suppressed' " |
| 312 | test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \ |
| 313 | 'long_non_ascii_self_suppressed' |
| 314 | " |
| 315 | |
Michael S. Tsirkin | 1495266 | 2013-06-05 21:11:08 +0300 | [diff] [blame] | 316 | test_expect_success $PREREQ 'sanitized self name is suppressed' " |
| 317 | test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \ |
| 318 | 'self_name_sanitized_suppressed' |
| 319 | " |
| 320 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 321 | test_expect_success $PREREQ 'Show all headers' ' |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 322 | git send-email \ |
| 323 | --dry-run \ |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 324 | --suppress-cc=sob \ |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 325 | --from="Example <from@example.com>" \ |
Christian Ludwig | d11c943 | 2018-03-04 00:58:14 +0100 | [diff] [blame] | 326 | --reply-to="Reply <reply@example.com>" \ |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 327 | --to=to@example.com \ |
| 328 | --cc=cc@example.com \ |
| 329 | --bcc=bcc@example.com \ |
| 330 | --in-reply-to="<unique-message-id@example.com>" \ |
| 331 | --smtp-server relay.example.com \ |
Christian Ludwig | ec3b4b0 | 2018-01-12 11:37:24 +0100 | [diff] [blame] | 332 | $patches | replace_variable_fields \ |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 333 | >actual-show-all-headers && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 334 | test_cmp expected-show-all-headers actual-show-all-headers |
David D. Kilzer | b7f30e0 | 2007-11-18 20:14:55 -0800 | [diff] [blame] | 335 | ' |
| 336 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 337 | test_expect_success $PREREQ 'Prompting works' ' |
Jay Soffian | 0da43a6 | 2009-04-04 23:23:21 -0400 | [diff] [blame] | 338 | clean_fake_sendmail && |
Eric Sunshine | cff4243 | 2018-07-01 20:24:04 -0400 | [diff] [blame] | 339 | (echo "to@example.com" && |
Jeff King | c016726 | 2023-08-08 14:15:31 -0400 | [diff] [blame] | 340 | echo "my-message-id@example.com" |
Jay Soffian | 0da43a6 | 2009-04-04 23:23:21 -0400 | [diff] [blame] | 341 | ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ |
| 342 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 343 | $patches \ |
| 344 | 2>errors && |
Felipe Contreras | 8cac13d | 2012-11-24 12:16:19 +0100 | [diff] [blame] | 345 | grep "^From: A U Thor <author@example.com>\$" msgtxt1 && |
Jeff King | c016726 | 2023-08-08 14:15:31 -0400 | [diff] [blame] | 346 | grep "^To: to@example.com\$" msgtxt1 && |
| 347 | grep "^In-Reply-To: <my-message-id@example.com>" msgtxt1 |
Jay Soffian | 0da43a6 | 2009-04-04 23:23:21 -0400 | [diff] [blame] | 348 | ' |
| 349 | |
Jeff King | 59defcc | 2012-11-28 15:06:26 -0500 | [diff] [blame] | 350 | test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' ' |
| 351 | clean_fake_sendmail && |
| 352 | (sane_unset GIT_AUTHOR_NAME && |
| 353 | sane_unset GIT_AUTHOR_EMAIL && |
| 354 | sane_unset GIT_COMMITTER_NAME && |
| 355 | sane_unset GIT_COMMITTER_EMAIL && |
| 356 | GIT_SEND_EMAIL_NOTTY=1 git send-email \ |
| 357 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 358 | --to=to@example.com \ |
| 359 | $patches </dev/null 2>errors |
| 360 | ) |
| 361 | ' |
| 362 | |
| 363 | test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' ' |
| 364 | clean_fake_sendmail && |
| 365 | (sane_unset GIT_AUTHOR_NAME && |
| 366 | sane_unset GIT_AUTHOR_EMAIL && |
| 367 | sane_unset GIT_COMMITTER_NAME && |
| 368 | sane_unset GIT_COMMITTER_EMAIL && |
| 369 | GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY && |
| 370 | test_must_fail git send-email \ |
| 371 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 372 | --to=to@example.com \ |
| 373 | $patches </dev/null 2>errors && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 374 | test_grep "tell me who you are" errors |
Jeff King | 59defcc | 2012-11-28 15:06:26 -0500 | [diff] [blame] | 375 | ) |
| 376 | ' |
| 377 | |
Maxim Cournoyer | ba92106 | 2023-05-01 10:38:47 -0400 | [diff] [blame] | 378 | test_expect_success $PREREQ 'setup cmd scripts' ' |
Remi Lespinet | 62089fb | 2015-06-30 14:16:42 +0200 | [diff] [blame] | 379 | write_script tocmd-sed <<-\EOF && |
| 380 | sed -n -e "s/^tocmd--//p" "$1" |
| 381 | EOF |
Maxim Cournoyer | ba92106 | 2023-05-01 10:38:47 -0400 | [diff] [blame] | 382 | write_script cccmd-sed <<-\EOF && |
Remi Lespinet | 62089fb | 2015-06-30 14:16:42 +0200 | [diff] [blame] | 383 | sed -n -e "s/^cccmd--//p" "$1" |
| 384 | EOF |
Maxim Cournoyer | ba92106 | 2023-05-01 10:38:47 -0400 | [diff] [blame] | 385 | write_script headercmd-sed <<-\EOF |
| 386 | sed -n -e "s/^headercmd--//p" "$1" |
| 387 | EOF |
Remi Lespinet | 62089fb | 2015-06-30 14:16:42 +0200 | [diff] [blame] | 388 | ' |
| 389 | |
Joe Perches | 6e74e07 | 2010-09-24 10:03:00 -0700 | [diff] [blame] | 390 | test_expect_success $PREREQ 'tocmd works' ' |
| 391 | clean_fake_sendmail && |
| 392 | cp $patches tocmd.patch && |
| 393 | echo tocmd--tocmd@example.com >>tocmd.patch && |
Joe Perches | 6e74e07 | 2010-09-24 10:03:00 -0700 | [diff] [blame] | 394 | git send-email \ |
| 395 | --from="Example <nobody@example.com>" \ |
| 396 | --to-cmd=./tocmd-sed \ |
| 397 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 398 | tocmd.patch \ |
| 399 | && |
| 400 | grep "^To: tocmd@example.com" msgtxt1 |
| 401 | ' |
| 402 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 403 | test_expect_success $PREREQ 'cccmd works' ' |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 404 | clean_fake_sendmail && |
| 405 | cp $patches cccmd.patch && |
Ævar Arnfjörð Bjarmason | 41ae8f1 | 2010-09-30 13:43:09 +0000 | [diff] [blame] | 406 | echo "cccmd-- cccmd@example.com" >>cccmd.patch && |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 407 | git send-email \ |
| 408 | --from="Example <nobody@example.com>" \ |
| 409 | --to=nobody@example.com \ |
| 410 | --cc-cmd=./cccmd-sed \ |
| 411 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 412 | cccmd.patch \ |
| 413 | && |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 414 | grep "^ cccmd@example.com" msgtxt1 |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 415 | ' |
| 416 | |
Maxim Cournoyer | ba92106 | 2023-05-01 10:38:47 -0400 | [diff] [blame] | 417 | test_expect_success $PREREQ 'headercmd works' ' |
| 418 | clean_fake_sendmail && |
| 419 | cp $patches headercmd.patch && |
| 420 | echo "headercmd--X-Debbugs-CC: dummy@example.com" >>headercmd.patch && |
| 421 | git send-email \ |
| 422 | --from="Example <nobody@example.com>" \ |
| 423 | --to=nobody@example.com \ |
| 424 | --header-cmd=./headercmd-sed \ |
| 425 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 426 | headercmd.patch \ |
| 427 | && |
| 428 | grep "^X-Debbugs-CC: dummy@example.com" msgtxt1 |
| 429 | ' |
| 430 | |
| 431 | test_expect_success $PREREQ '--no-header-cmd works' ' |
| 432 | clean_fake_sendmail && |
| 433 | cp $patches headercmd.patch && |
| 434 | echo "headercmd--X-Debbugs-CC: dummy@example.com" >>headercmd.patch && |
| 435 | git send-email \ |
| 436 | --from="Example <nobody@example.com>" \ |
| 437 | --to=nobody@example.com \ |
| 438 | --header-cmd=./headercmd-sed \ |
| 439 | --no-header-cmd \ |
| 440 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 441 | headercmd.patch \ |
| 442 | && |
| 443 | ! grep "^X-Debbugs-CC: dummy@example.com" msgtxt1 |
| 444 | ' |
| 445 | |
| 446 | test_expect_success $PREREQ 'multiline fields are correctly unfolded' ' |
| 447 | clean_fake_sendmail && |
| 448 | cp $patches headercmd.patch && |
| 449 | write_script headercmd-multiline <<-\EOF && |
| 450 | echo "X-Debbugs-CC: someone@example.com |
| 451 | FoldedField: This is a tale |
| 452 | best told using |
| 453 | multiple lines." |
| 454 | EOF |
| 455 | git send-email \ |
| 456 | --from="Example <nobody@example.com>" \ |
| 457 | --to=nobody@example.com \ |
| 458 | --header-cmd=./headercmd-multiline \ |
| 459 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 460 | headercmd.patch && |
| 461 | grep "^FoldedField: This is a tale best told using multiple lines.$" msgtxt1 |
| 462 | ' |
| 463 | |
Maxim Cournoyer | 3a7a18a | 2023-05-01 10:38:48 -0400 | [diff] [blame] | 464 | # Blank lines in the middle of the output of a command are invalid. |
| 465 | test_expect_success $PREREQ 'malform output reported on blank lines in command output' ' |
| 466 | clean_fake_sendmail && |
| 467 | cp $patches headercmd.patch && |
| 468 | write_script headercmd-malformed-output <<-\EOF && |
| 469 | echo "X-Debbugs-CC: someone@example.com |
| 470 | |
| 471 | SomeOtherField: someone-else@example.com" |
| 472 | EOF |
| 473 | ! git send-email \ |
| 474 | --from="Example <nobody@example.com>" \ |
| 475 | --to=nobody@example.com \ |
| 476 | --header-cmd=./headercmd-malformed-output \ |
| 477 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 478 | headercmd.patch |
| 479 | ' |
| 480 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 481 | test_expect_success $PREREQ 'reject long lines' ' |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 482 | z8=zzzzzzzz && |
| 483 | z64=$z8$z8$z8$z8$z8$z8$z8$z8 && |
| 484 | z512=$z64$z64$z64$z64$z64$z64$z64$z64 && |
Jeff King | 6d34a2b | 2008-02-24 16:03:52 -0500 | [diff] [blame] | 485 | clean_fake_sendmail && |
Jeff King | 747bbff | 2008-01-18 09:19:48 -0500 | [diff] [blame] | 486 | cp $patches longline.patch && |
Ævar Arnfjörð Bjarmason | ea7811b | 2021-04-06 16:00:37 +0200 | [diff] [blame] | 487 | cat >>longline.patch <<-EOF && |
| 488 | $z512$z512 |
| 489 | not a long line |
| 490 | $z512$z512 |
| 491 | EOF |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 492 | test_must_fail git send-email \ |
Jeff King | 747bbff | 2008-01-18 09:19:48 -0500 | [diff] [blame] | 493 | --from="Example <nobody@example.com>" \ |
| 494 | --to=nobody@example.com \ |
| 495 | --smtp-server="$(pwd)/fake.sendmail" \ |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 496 | --transfer-encoding=8bit \ |
Jeff King | 747bbff | 2008-01-18 09:19:48 -0500 | [diff] [blame] | 497 | $patches longline.patch \ |
Ævar Arnfjörð Bjarmason | e585210 | 2021-04-06 16:00:35 +0200 | [diff] [blame] | 498 | 2>actual && |
| 499 | cat >expect <<-\EOF && |
Ævar Arnfjörð Bjarmason | ea7811b | 2021-04-06 16:00:37 +0200 | [diff] [blame] | 500 | fatal: longline.patch:35 is longer than 998 characters |
Ævar Arnfjörð Bjarmason | e585210 | 2021-04-06 16:00:35 +0200 | [diff] [blame] | 501 | warning: no patches were sent |
| 502 | EOF |
| 503 | test_cmp expect actual |
Jeff King | 747bbff | 2008-01-18 09:19:48 -0500 | [diff] [blame] | 504 | ' |
| 505 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 506 | test_expect_success $PREREQ 'no patch was sent' ' |
Jeff King | 6d34a2b | 2008-02-24 16:03:52 -0500 | [diff] [blame] | 507 | ! test -e commandline1 |
Jeff King | 747bbff | 2008-01-18 09:19:48 -0500 | [diff] [blame] | 508 | ' |
| 509 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 510 | test_expect_success $PREREQ 'Author From: in message body' ' |
Jay Soffian | 5012699 | 2009-02-14 23:32:14 -0500 | [diff] [blame] | 511 | clean_fake_sendmail && |
| 512 | git send-email \ |
| 513 | --from="Example <nobody@example.com>" \ |
| 514 | --to=nobody@example.com \ |
| 515 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 516 | $patches && |
Junio C Hamano | ee756a8 | 2014-11-25 14:52:42 -0800 | [diff] [blame] | 517 | sed "1,/^\$/d" <msgtxt1 >msgbody1 && |
Jay Soffian | 5012699 | 2009-02-14 23:32:14 -0500 | [diff] [blame] | 518 | grep "From: A <author@example.com>" msgbody1 |
| 519 | ' |
| 520 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 521 | test_expect_success $PREREQ 'Author From: not in message body' ' |
Jay Soffian | 5012699 | 2009-02-14 23:32:14 -0500 | [diff] [blame] | 522 | clean_fake_sendmail && |
| 523 | git send-email \ |
| 524 | --from="A <author@example.com>" \ |
| 525 | --to=nobody@example.com \ |
| 526 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 527 | $patches && |
Junio C Hamano | ee756a8 | 2014-11-25 14:52:42 -0800 | [diff] [blame] | 528 | sed "1,/^\$/d" <msgtxt1 >msgbody1 && |
Jay Soffian | 5012699 | 2009-02-14 23:32:14 -0500 | [diff] [blame] | 529 | ! grep "From: A <author@example.com>" msgbody1 |
| 530 | ' |
| 531 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 532 | test_expect_success $PREREQ 'allow long lines with --no-validate' ' |
Jeff King | c764a0c | 2008-01-18 09:20:10 -0500 | [diff] [blame] | 533 | git send-email \ |
| 534 | --from="Example <nobody@example.com>" \ |
| 535 | --to=nobody@example.com \ |
| 536 | --smtp-server="$(pwd)/fake.sendmail" \ |
Kyle J. McKay | f471494 | 2015-01-30 18:40:17 -0800 | [diff] [blame] | 537 | --no-validate \ |
Jeff King | c764a0c | 2008-01-18 09:20:10 -0500 | [diff] [blame] | 538 | $patches longline.patch \ |
| 539 | 2>errors |
| 540 | ' |
| 541 | |
brian m. carlson | 7a36987 | 2018-07-08 22:17:10 +0000 | [diff] [blame] | 542 | test_expect_success $PREREQ 'short lines with auto encoding are 8bit' ' |
| 543 | clean_fake_sendmail && |
| 544 | git send-email \ |
| 545 | --from="A <author@example.com>" \ |
| 546 | --to=nobody@example.com \ |
| 547 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 548 | --transfer-encoding=auto \ |
| 549 | $patches && |
| 550 | grep "Content-Transfer-Encoding: 8bit" msgtxt1 |
| 551 | ' |
| 552 | |
| 553 | test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable' ' |
| 554 | clean_fake_sendmail && |
| 555 | git send-email \ |
| 556 | --from="Example <nobody@example.com>" \ |
| 557 | --to=nobody@example.com \ |
| 558 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 559 | --transfer-encoding=auto \ |
| 560 | --no-validate \ |
| 561 | longline.patch && |
| 562 | grep "Content-Transfer-Encoding: quoted-printable" msgtxt1 |
| 563 | ' |
| 564 | |
brian m. carlson | 74d76a1 | 2019-04-13 22:45:51 +0000 | [diff] [blame] | 565 | test_expect_success $PREREQ 'carriage returns with auto encoding are quoted-printable' ' |
| 566 | clean_fake_sendmail && |
| 567 | cp $patches cr.patch && |
| 568 | printf "this is a line\r\n" >>cr.patch && |
| 569 | git send-email \ |
| 570 | --from="Example <nobody@example.com>" \ |
| 571 | --to=nobody@example.com \ |
| 572 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 573 | --transfer-encoding=auto \ |
| 574 | --no-validate \ |
| 575 | cr.patch && |
| 576 | grep "Content-Transfer-Encoding: quoted-printable" msgtxt1 |
| 577 | ' |
| 578 | |
brian m. carlson | f2d06fb | 2018-07-08 22:17:11 +0000 | [diff] [blame] | 579 | for enc in auto quoted-printable base64 |
| 580 | do |
| 581 | test_expect_success $PREREQ "--validate passes with encoding $enc" ' |
| 582 | git send-email \ |
| 583 | --from="Example <nobody@example.com>" \ |
| 584 | --to=nobody@example.com \ |
| 585 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 586 | --transfer-encoding=$enc \ |
| 587 | --validate \ |
| 588 | $patches longline.patch |
| 589 | ' |
Aaron Lindsay | 3c88e46 | 2018-11-02 05:52:38 -0400 | [diff] [blame] | 590 | |
| 591 | done |
| 592 | |
Robert Foss | c824393 | 2021-03-23 18:33:27 +0100 | [diff] [blame] | 593 | test_expect_success $PREREQ "--validate respects relative core.hooksPath path" ' |
| 594 | clean_fake_sendmail && |
| 595 | mkdir my-hooks && |
| 596 | test_when_finished "rm my-hooks.ran" && |
| 597 | write_script my-hooks/sendemail-validate <<-\EOF && |
| 598 | >my-hooks.ran |
| 599 | exit 1 |
| 600 | EOF |
| 601 | test_config core.hooksPath "my-hooks" && |
| 602 | test_must_fail git send-email \ |
| 603 | --from="Example <nobody@example.com>" \ |
| 604 | --to=nobody@example.com \ |
| 605 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 606 | --validate \ |
Ævar Arnfjörð Bjarmason | e585210 | 2021-04-06 16:00:35 +0200 | [diff] [blame] | 607 | longline.patch 2>actual && |
Robert Foss | c824393 | 2021-03-23 18:33:27 +0100 | [diff] [blame] | 608 | test_path_is_file my-hooks.ran && |
Ævar Arnfjörð Bjarmason | ea7811b | 2021-04-06 16:00:37 +0200 | [diff] [blame] | 609 | cat >expect <<-EOF && |
Ævar Arnfjörð Bjarmason | e585210 | 2021-04-06 16:00:35 +0200 | [diff] [blame] | 610 | fatal: longline.patch: rejected by sendemail-validate hook |
Michael Strawbridge | a8022c5 | 2023-04-19 16:27:03 -0400 | [diff] [blame] | 611 | fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'"'"' died with exit code 1 |
Ævar Arnfjörð Bjarmason | e585210 | 2021-04-06 16:00:35 +0200 | [diff] [blame] | 612 | warning: no patches were sent |
| 613 | EOF |
| 614 | test_cmp expect actual |
Robert Foss | c824393 | 2021-03-23 18:33:27 +0100 | [diff] [blame] | 615 | ' |
| 616 | |
| 617 | test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" ' |
Ævar Arnfjörð Bjarmason | 2815326 | 2021-05-26 13:21:06 +0200 | [diff] [blame] | 618 | hooks_path="$(pwd)/my-hooks" && |
| 619 | test_config core.hooksPath "$hooks_path" && |
Robert Foss | c824393 | 2021-03-23 18:33:27 +0100 | [diff] [blame] | 620 | test_when_finished "rm my-hooks.ran" && |
| 621 | test_must_fail git send-email \ |
| 622 | --from="Example <nobody@example.com>" \ |
| 623 | --to=nobody@example.com \ |
| 624 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 625 | --validate \ |
Ævar Arnfjörð Bjarmason | e585210 | 2021-04-06 16:00:35 +0200 | [diff] [blame] | 626 | longline.patch 2>actual && |
Robert Foss | c824393 | 2021-03-23 18:33:27 +0100 | [diff] [blame] | 627 | test_path_is_file my-hooks.ran && |
Ævar Arnfjörð Bjarmason | ea7811b | 2021-04-06 16:00:37 +0200 | [diff] [blame] | 628 | cat >expect <<-EOF && |
Ævar Arnfjörð Bjarmason | e585210 | 2021-04-06 16:00:35 +0200 | [diff] [blame] | 629 | fatal: longline.patch: rejected by sendemail-validate hook |
Michael Strawbridge | a8022c5 | 2023-04-19 16:27:03 -0400 | [diff] [blame] | 630 | fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'"'"' died with exit code 1 |
Ævar Arnfjörð Bjarmason | e585210 | 2021-04-06 16:00:35 +0200 | [diff] [blame] | 631 | warning: no patches were sent |
| 632 | EOF |
| 633 | test_cmp expect actual |
Robert Foss | c824393 | 2021-03-23 18:33:27 +0100 | [diff] [blame] | 634 | ' |
| 635 | |
Michael Strawbridge | 0d86470 | 2023-10-25 14:51:29 -0400 | [diff] [blame] | 636 | test_expect_success $PREREQ "--validate hook supports multiple addresses in arguments" ' |
| 637 | hooks_path="$(pwd)/my-hooks" && |
| 638 | test_config core.hooksPath "$hooks_path" && |
| 639 | test_when_finished "rm my-hooks.ran" && |
| 640 | test_must_fail git send-email \ |
| 641 | --from="Example <nobody@example.com>" \ |
| 642 | --to=nobody@example.com,abc@example.com \ |
| 643 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 644 | --validate \ |
| 645 | longline.patch 2>actual && |
| 646 | test_path_is_file my-hooks.ran && |
| 647 | cat >expect <<-EOF && |
| 648 | fatal: longline.patch: rejected by sendemail-validate hook |
| 649 | fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'"'"' died with exit code 1 |
| 650 | warning: no patches were sent |
| 651 | EOF |
| 652 | test_cmp expect actual |
| 653 | ' |
| 654 | |
Michael Strawbridge | a8022c5 | 2023-04-19 16:27:03 -0400 | [diff] [blame] | 655 | test_expect_success $PREREQ "--validate hook supports header argument" ' |
| 656 | write_script my-hooks/sendemail-validate <<-\EOF && |
| 657 | if test "$#" -ge 2 |
| 658 | then |
| 659 | grep "X-test-header: v1.0" "$2" |
| 660 | else |
| 661 | echo "No header arg passed" |
| 662 | exit 1 |
| 663 | fi |
| 664 | EOF |
| 665 | test_config core.hooksPath "my-hooks" && |
| 666 | rm -fr outdir && |
| 667 | git format-patch \ |
| 668 | --add-header="X-test-header: v1.0" \ |
| 669 | -n HEAD^1 -o outdir && |
| 670 | git send-email \ |
| 671 | --dry-run \ |
| 672 | --to=nobody@example.com \ |
| 673 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 674 | --validate \ |
| 675 | outdir/000?-*.patch |
| 676 | ' |
| 677 | |
Junio C Hamano | 3ece9bf | 2023-05-17 14:10:39 -0700 | [diff] [blame] | 678 | test_expect_success $PREREQ 'clear message-id before parsing a new message' ' |
| 679 | clean_fake_sendmail && |
| 680 | echo true | write_script my-hooks/sendemail-validate && |
| 681 | test_config core.hooksPath my-hooks && |
Junio C Hamano | 3ece9bf | 2023-05-17 14:10:39 -0700 | [diff] [blame] | 682 | git send-email --validate --to=recipient@example.com \ |
| 683 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 684 | $patches $threaded_patches && |
| 685 | id0=$(grep "^Message-ID: " $threaded_patches) && |
| 686 | id1=$(grep "^Message-ID: " msgtxt1) && |
| 687 | id2=$(grep "^Message-ID: " msgtxt2) && |
| 688 | test "z$id0" = "z$id2" && |
| 689 | test "z$id1" != "z$id2" |
| 690 | ' |
| 691 | |
Aaron Lindsay | 3c88e46 | 2018-11-02 05:52:38 -0400 | [diff] [blame] | 692 | for enc in 7bit 8bit quoted-printable base64 |
| 693 | do |
| 694 | test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" ' |
| 695 | clean_fake_sendmail && |
| 696 | git send-email \ |
| 697 | --from="Example <nobody@example.com>" \ |
| 698 | --to=nobody@example.com \ |
| 699 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 700 | --transfer-encoding=$enc \ |
| 701 | $patches && |
| 702 | grep "Content-Transfer-Encoding: $enc" msgtxt1 |
| 703 | ' |
brian m. carlson | f2d06fb | 2018-07-08 22:17:11 +0000 | [diff] [blame] | 704 | done |
| 705 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 706 | test_expect_success $PREREQ 'Invalid In-Reply-To' ' |
Jeff King | 6d34a2b | 2008-02-24 16:03:52 -0500 | [diff] [blame] | 707 | clean_fake_sendmail && |
Jay Soffian | 0fb7fc7 | 2008-02-21 19:16:04 -0500 | [diff] [blame] | 708 | git send-email \ |
| 709 | --from="Example <nobody@example.com>" \ |
| 710 | --to=nobody@example.com \ |
| 711 | --in-reply-to=" " \ |
| 712 | --smtp-server="$(pwd)/fake.sendmail" \ |
Antonio Ospite | 5b57413 | 2010-10-19 11:50:39 +0200 | [diff] [blame] | 713 | $patches \ |
Antonio Ospite | cc7e816 | 2011-01-04 21:56:58 +0100 | [diff] [blame] | 714 | 2>errors && |
Jeff King | 6d34a2b | 2008-02-24 16:03:52 -0500 | [diff] [blame] | 715 | ! grep "^In-Reply-To: < *>" msgtxt1 |
Jay Soffian | 0fb7fc7 | 2008-02-21 19:16:04 -0500 | [diff] [blame] | 716 | ' |
| 717 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 718 | test_expect_success $PREREQ 'Valid In-Reply-To when prompting' ' |
Jeff King | 6d34a2b | 2008-02-24 16:03:52 -0500 | [diff] [blame] | 719 | clean_fake_sendmail && |
Eric Sunshine | cff4243 | 2018-07-01 20:24:04 -0400 | [diff] [blame] | 720 | (echo "From Example <from@example.com>" && |
| 721 | echo "To Example <to@example.com>" && |
Jay Soffian | 0fb7fc7 | 2008-02-21 19:16:04 -0500 | [diff] [blame] | 722 | echo "" |
Junio C Hamano | 6eca18c | 2014-03-06 15:22:34 -0800 | [diff] [blame] | 723 | ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ |
Jay Soffian | 0fb7fc7 | 2008-02-21 19:16:04 -0500 | [diff] [blame] | 724 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 725 | $patches 2>errors && |
Jeff King | 6d34a2b | 2008-02-24 16:03:52 -0500 | [diff] [blame] | 726 | ! grep "^In-Reply-To: < *>" msgtxt1 |
Jay Soffian | 0fb7fc7 | 2008-02-21 19:16:04 -0500 | [diff] [blame] | 727 | ' |
| 728 | |
Junio C Hamano | 54aae5e | 2010-10-19 11:46:31 -0700 | [diff] [blame] | 729 | test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' ' |
| 730 | clean_fake_sendmail && |
| 731 | echo "<unique-message-id@example.com>" >expect && |
| 732 | git send-email \ |
| 733 | --from="Example <nobody@example.com>" \ |
| 734 | --to=nobody@example.com \ |
Kyle J. McKay | f471494 | 2015-01-30 18:40:17 -0800 | [diff] [blame] | 735 | --no-chain-reply-to \ |
Junio C Hamano | 54aae5e | 2010-10-19 11:46:31 -0700 | [diff] [blame] | 736 | --in-reply-to="$(cat expect)" \ |
| 737 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 738 | $patches $patches $patches \ |
| 739 | 2>errors && |
Antonio Ospite | db54c8e | 2010-11-12 15:55:08 +0100 | [diff] [blame] | 740 | # The first message is a reply to --in-reply-to |
Junio C Hamano | 54aae5e | 2010-10-19 11:46:31 -0700 | [diff] [blame] | 741 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && |
| 742 | test_cmp expect actual && |
Antonio Ospite | db54c8e | 2010-11-12 15:55:08 +0100 | [diff] [blame] | 743 | # Second and subsequent messages are replies to the first one |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 744 | sed -n -e "s/^Message-ID: *\(.*\)/\1/p" msgtxt1 >expect && |
Junio C Hamano | 54aae5e | 2010-10-19 11:46:31 -0700 | [diff] [blame] | 745 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && |
| 746 | test_cmp expect actual && |
| 747 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && |
| 748 | test_cmp expect actual |
| 749 | ' |
| 750 | |
| 751 | test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' ' |
| 752 | clean_fake_sendmail && |
| 753 | echo "<unique-message-id@example.com>" >expect && |
| 754 | git send-email \ |
| 755 | --from="Example <nobody@example.com>" \ |
| 756 | --to=nobody@example.com \ |
| 757 | --chain-reply-to \ |
| 758 | --in-reply-to="$(cat expect)" \ |
| 759 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 760 | $patches $patches $patches \ |
| 761 | 2>errors && |
| 762 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual && |
| 763 | test_cmp expect actual && |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 764 | sed -n -e "s/^Message-ID: *\(.*\)/\1/p" msgtxt1 >expect && |
Junio C Hamano | 54aae5e | 2010-10-19 11:46:31 -0700 | [diff] [blame] | 765 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual && |
| 766 | test_cmp expect actual && |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 767 | sed -n -e "s/^Message-ID: *\(.*\)/\1/p" msgtxt2 >expect && |
Junio C Hamano | 54aae5e | 2010-10-19 11:46:31 -0700 | [diff] [blame] | 768 | sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual && |
| 769 | test_cmp expect actual |
| 770 | ' |
| 771 | |
Ævar Arnfjörð Bjarmason | 5b719b7 | 2021-05-25 01:14:24 +0200 | [diff] [blame] | 772 | test_set_editor "$(pwd)/fake-editor" |
| 773 | |
| 774 | test_expect_success $PREREQ 'setup erroring fake editor' ' |
| 775 | write_script fake-editor <<-\EOF |
| 776 | echo >&2 "I am about to error" |
| 777 | exit 1 |
| 778 | EOF |
| 779 | ' |
| 780 | |
| 781 | test_expect_success $PREREQ 'fake editor dies with error' ' |
| 782 | clean_fake_sendmail && |
| 783 | test_must_fail git send-email \ |
| 784 | --compose --subject foo \ |
| 785 | --from="Example <nobody@example.com>" \ |
| 786 | --to=nobody@example.com \ |
| 787 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 788 | $patches 2>err && |
| 789 | grep "I am about to error" err && |
| 790 | grep "the editor exited uncleanly, aborting everything" err |
| 791 | ' |
| 792 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 793 | test_expect_success $PREREQ 'setup fake editor' ' |
Junio C Hamano | acd72b5 | 2014-11-25 14:21:07 -0800 | [diff] [blame] | 794 | write_script fake-editor <<-\EOF |
| 795 | echo fake edit >>"$1" |
| 796 | EOF |
Jeff King | 8a8bf46 | 2008-02-24 16:04:14 -0500 | [diff] [blame] | 797 | ' |
| 798 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 799 | test_expect_success $PREREQ '--compose works' ' |
Jeff King | 8a8bf46 | 2008-02-24 16:04:14 -0500 | [diff] [blame] | 800 | clean_fake_sendmail && |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 801 | git send-email \ |
| 802 | --compose --subject foo \ |
| 803 | --from="Example <nobody@example.com>" \ |
| 804 | --to=nobody@example.com \ |
| 805 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 806 | $patches \ |
| 807 | 2>errors |
Jeff King | 8a8bf46 | 2008-02-24 16:04:14 -0500 | [diff] [blame] | 808 | ' |
| 809 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 810 | test_expect_success $PREREQ 'first message is compose text' ' |
Jeff King | 8a8bf46 | 2008-02-24 16:04:14 -0500 | [diff] [blame] | 811 | grep "^fake edit" msgtxt1 |
| 812 | ' |
| 813 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 814 | test_expect_success $PREREQ 'second message is patch' ' |
Jeff King | 8a8bf46 | 2008-02-24 16:04:14 -0500 | [diff] [blame] | 815 | grep "Subject:.*Second" msgtxt2 |
| 816 | ' |
| 817 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 818 | test_expect_success $PREREQ 'setup expect' " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 819 | cat >expected-suppress-sob <<\EOF |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 820 | 0001-Second.patch |
| 821 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' |
Jay Soffian | 5012699 | 2009-02-14 23:32:14 -0500 | [diff] [blame] | 822 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
| 823 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 824 | Dry-OK. Log says: |
| 825 | Server: relay.example.com |
| 826 | MAIL FROM:<from@example.com> |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 827 | RCPT TO:<to@example.com> |
| 828 | RCPT TO:<cc@example.com> |
| 829 | RCPT TO:<author@example.com> |
| 830 | RCPT TO:<one@example.com> |
| 831 | RCPT TO:<two@example.com> |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 832 | From: Example <from@example.com> |
| 833 | To: to@example.com |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 834 | Cc: cc@example.com, |
| 835 | A <author@example.com>, |
| 836 | One <one@example.com>, |
| 837 | two@example.com |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 838 | Subject: [PATCH 1/1] Second. |
| 839 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 840 | Message-ID: MESSAGE-ID-STRING |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 841 | X-Mailer: X-MAILER-STRING |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 842 | MIME-Version: 1.0 |
| 843 | Content-Transfer-Encoding: 8bit |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 844 | |
| 845 | Result: OK |
| 846 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 847 | " |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 848 | |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 849 | test_suppression () { |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 850 | git send-email \ |
| 851 | --dry-run \ |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 852 | --suppress-cc=$1 ${2+"--suppress-cc=$2"} \ |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 853 | --from="Example <from@example.com>" \ |
| 854 | --to=to@example.com \ |
| 855 | --smtp-server relay.example.com \ |
Remi Lespinet | d4cf11c | 2015-06-30 14:16:44 +0200 | [diff] [blame] | 856 | $patches | replace_variable_fields \ |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 857 | >actual-suppress-$1${2+"-$2"} && |
| 858 | test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"} |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 859 | } |
| 860 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 861 | test_expect_success $PREREQ 'sendemail.cc set' ' |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 862 | git config sendemail.cc cc@example.com && |
| 863 | test_suppression sob |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 864 | ' |
| 865 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 866 | test_expect_success $PREREQ 'setup expect' " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 867 | cat >expected-suppress-sob <<\EOF |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 868 | 0001-Second.patch |
| 869 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' |
Jay Soffian | 5012699 | 2009-02-14 23:32:14 -0500 | [diff] [blame] | 870 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
| 871 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 872 | Dry-OK. Log says: |
| 873 | Server: relay.example.com |
| 874 | MAIL FROM:<from@example.com> |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 875 | RCPT TO:<to@example.com> |
| 876 | RCPT TO:<author@example.com> |
| 877 | RCPT TO:<one@example.com> |
| 878 | RCPT TO:<two@example.com> |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 879 | From: Example <from@example.com> |
| 880 | To: to@example.com |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 881 | Cc: A <author@example.com>, |
| 882 | One <one@example.com>, |
| 883 | two@example.com |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 884 | Subject: [PATCH 1/1] Second. |
| 885 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 886 | Message-ID: MESSAGE-ID-STRING |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 887 | X-Mailer: X-MAILER-STRING |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 888 | MIME-Version: 1.0 |
| 889 | Content-Transfer-Encoding: 8bit |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 890 | |
| 891 | Result: OK |
| 892 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 893 | " |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 894 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 895 | test_expect_success $PREREQ 'sendemail.cc unset' ' |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 896 | git config --unset sendemail.cc && |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 897 | test_suppression sob |
| 898 | ' |
| 899 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 900 | test_expect_success $PREREQ 'setup expect' " |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 901 | cat >expected-suppress-cccmd <<\EOF |
| 902 | 0001-Second.patch |
| 903 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' |
| 904 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
| 905 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' |
| 906 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' |
| 907 | Dry-OK. Log says: |
| 908 | Server: relay.example.com |
| 909 | MAIL FROM:<from@example.com> |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 910 | RCPT TO:<to@example.com> |
| 911 | RCPT TO:<author@example.com> |
| 912 | RCPT TO:<one@example.com> |
| 913 | RCPT TO:<two@example.com> |
| 914 | RCPT TO:<committer@example.com> |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 915 | From: Example <from@example.com> |
| 916 | To: to@example.com |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 917 | Cc: A <author@example.com>, |
| 918 | One <one@example.com>, |
| 919 | two@example.com, |
| 920 | C O Mitter <committer@example.com> |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 921 | Subject: [PATCH 1/1] Second. |
| 922 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 923 | Message-ID: MESSAGE-ID-STRING |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 924 | X-Mailer: X-MAILER-STRING |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 925 | MIME-Version: 1.0 |
| 926 | Content-Transfer-Encoding: 8bit |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 927 | |
| 928 | Result: OK |
| 929 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 930 | " |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 931 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 932 | test_expect_success $PREREQ 'sendemail.cccmd' ' |
Junio C Hamano | acd72b5 | 2014-11-25 14:21:07 -0800 | [diff] [blame] | 933 | write_script cccmd <<-\EOF && |
| 934 | echo cc-cmd@example.com |
| 935 | EOF |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 936 | git config sendemail.cccmd ./cccmd && |
| 937 | test_suppression cccmd |
| 938 | ' |
| 939 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 940 | test_expect_success $PREREQ 'setup expect' ' |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 941 | cat >expected-suppress-all <<\EOF |
| 942 | 0001-Second.patch |
| 943 | Dry-OK. Log says: |
| 944 | Server: relay.example.com |
| 945 | MAIL FROM:<from@example.com> |
| 946 | RCPT TO:<to@example.com> |
| 947 | From: Example <from@example.com> |
| 948 | To: to@example.com |
| 949 | Subject: [PATCH 1/1] Second. |
| 950 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 951 | Message-ID: MESSAGE-ID-STRING |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 952 | X-Mailer: X-MAILER-STRING |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 953 | MIME-Version: 1.0 |
| 954 | Content-Transfer-Encoding: 8bit |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 955 | |
| 956 | Result: OK |
| 957 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 958 | ' |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 959 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 960 | test_expect_success $PREREQ '--suppress-cc=all' ' |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 961 | test_suppression all |
| 962 | ' |
| 963 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 964 | test_expect_success $PREREQ 'setup expect' " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 965 | cat >expected-suppress-body <<\EOF |
| 966 | 0001-Second.patch |
| 967 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' |
| 968 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
| 969 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 970 | (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd' |
| 971 | Dry-OK. Log says: |
| 972 | Server: relay.example.com |
| 973 | MAIL FROM:<from@example.com> |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 974 | RCPT TO:<to@example.com> |
| 975 | RCPT TO:<author@example.com> |
| 976 | RCPT TO:<one@example.com> |
| 977 | RCPT TO:<two@example.com> |
| 978 | RCPT TO:<cc-cmd@example.com> |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 979 | From: Example <from@example.com> |
| 980 | To: to@example.com |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 981 | Cc: A <author@example.com>, |
| 982 | One <one@example.com>, |
| 983 | two@example.com, |
| 984 | cc-cmd@example.com |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 985 | Subject: [PATCH 1/1] Second. |
| 986 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 987 | Message-ID: MESSAGE-ID-STRING |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 988 | X-Mailer: X-MAILER-STRING |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 989 | MIME-Version: 1.0 |
| 990 | Content-Transfer-Encoding: 8bit |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 991 | |
| 992 | Result: OK |
| 993 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 994 | " |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 995 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 996 | test_expect_success $PREREQ '--suppress-cc=body' ' |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 997 | test_suppression body |
| 998 | ' |
| 999 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1000 | test_expect_success $PREREQ 'setup expect' " |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 1001 | cat >expected-suppress-body-cccmd <<\EOF |
| 1002 | 0001-Second.patch |
| 1003 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' |
| 1004 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
| 1005 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1006 | Dry-OK. Log says: |
| 1007 | Server: relay.example.com |
| 1008 | MAIL FROM:<from@example.com> |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 1009 | RCPT TO:<to@example.com> |
| 1010 | RCPT TO:<author@example.com> |
| 1011 | RCPT TO:<one@example.com> |
| 1012 | RCPT TO:<two@example.com> |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1013 | From: Example <from@example.com> |
| 1014 | To: to@example.com |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 1015 | Cc: A <author@example.com>, |
| 1016 | One <one@example.com>, |
| 1017 | two@example.com |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1018 | Subject: [PATCH 1/1] Second. |
| 1019 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 1020 | Message-ID: MESSAGE-ID-STRING |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1021 | X-Mailer: X-MAILER-STRING |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 1022 | MIME-Version: 1.0 |
| 1023 | Content-Transfer-Encoding: 8bit |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1024 | |
| 1025 | Result: OK |
| 1026 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1027 | " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1028 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1029 | test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' ' |
Paolo Bonzini | cb8a9bd | 2009-06-18 14:31:32 +0200 | [diff] [blame] | 1030 | test_suppression body cccmd |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1031 | ' |
| 1032 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1033 | test_expect_success $PREREQ 'setup expect' " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1034 | cat >expected-suppress-sob <<\EOF |
| 1035 | 0001-Second.patch |
| 1036 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' |
| 1037 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
| 1038 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' |
| 1039 | Dry-OK. Log says: |
| 1040 | Server: relay.example.com |
| 1041 | MAIL FROM:<from@example.com> |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 1042 | RCPT TO:<to@example.com> |
| 1043 | RCPT TO:<author@example.com> |
| 1044 | RCPT TO:<one@example.com> |
| 1045 | RCPT TO:<two@example.com> |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1046 | From: Example <from@example.com> |
| 1047 | To: to@example.com |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 1048 | Cc: A <author@example.com>, |
| 1049 | One <one@example.com>, |
| 1050 | two@example.com |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1051 | Subject: [PATCH 1/1] Second. |
| 1052 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 1053 | Message-ID: MESSAGE-ID-STRING |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1054 | X-Mailer: X-MAILER-STRING |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 1055 | MIME-Version: 1.0 |
| 1056 | Content-Transfer-Encoding: 8bit |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1057 | |
| 1058 | Result: OK |
| 1059 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1060 | " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1061 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1062 | test_expect_success $PREREQ '--suppress-cc=sob' ' |
Antonio Ospite | cc7e816 | 2011-01-04 21:56:58 +0100 | [diff] [blame] | 1063 | test_might_fail git config --unset sendemail.cccmd && |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1064 | test_suppression sob |
| 1065 | ' |
| 1066 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1067 | test_expect_success $PREREQ 'setup expect' " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1068 | cat >expected-suppress-bodycc <<\EOF |
| 1069 | 0001-Second.patch |
| 1070 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' |
| 1071 | (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com' |
| 1072 | (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com' |
| 1073 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' |
| 1074 | Dry-OK. Log says: |
| 1075 | Server: relay.example.com |
| 1076 | MAIL FROM:<from@example.com> |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 1077 | RCPT TO:<to@example.com> |
| 1078 | RCPT TO:<author@example.com> |
| 1079 | RCPT TO:<one@example.com> |
| 1080 | RCPT TO:<two@example.com> |
| 1081 | RCPT TO:<committer@example.com> |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1082 | From: Example <from@example.com> |
| 1083 | To: to@example.com |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 1084 | Cc: A <author@example.com>, |
| 1085 | One <one@example.com>, |
| 1086 | two@example.com, |
| 1087 | C O Mitter <committer@example.com> |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1088 | Subject: [PATCH 1/1] Second. |
| 1089 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 1090 | Message-ID: MESSAGE-ID-STRING |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1091 | X-Mailer: X-MAILER-STRING |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 1092 | MIME-Version: 1.0 |
| 1093 | Content-Transfer-Encoding: 8bit |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1094 | |
| 1095 | Result: OK |
| 1096 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1097 | " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1098 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1099 | test_expect_success $PREREQ '--suppress-cc=bodycc' ' |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1100 | test_suppression bodycc |
| 1101 | ' |
| 1102 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1103 | test_expect_success $PREREQ 'setup expect' " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1104 | cat >expected-suppress-cc <<\EOF |
| 1105 | 0001-Second.patch |
| 1106 | (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' |
| 1107 | (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>' |
| 1108 | Dry-OK. Log says: |
| 1109 | Server: relay.example.com |
| 1110 | MAIL FROM:<from@example.com> |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 1111 | RCPT TO:<to@example.com> |
| 1112 | RCPT TO:<author@example.com> |
| 1113 | RCPT TO:<committer@example.com> |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1114 | From: Example <from@example.com> |
| 1115 | To: to@example.com |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 1116 | Cc: A <author@example.com>, |
| 1117 | C O Mitter <committer@example.com> |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1118 | Subject: [PATCH 1/1] Second. |
| 1119 | Date: DATE-STRING |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 1120 | Message-ID: MESSAGE-ID-STRING |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1121 | X-Mailer: X-MAILER-STRING |
brian m. carlson | e67a228 | 2018-07-08 22:17:12 +0000 | [diff] [blame] | 1122 | MIME-Version: 1.0 |
| 1123 | Content-Transfer-Encoding: 8bit |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1124 | |
| 1125 | Result: OK |
| 1126 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1127 | " |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1128 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1129 | test_expect_success $PREREQ '--suppress-cc=cc' ' |
Jay Soffian | 3531e27 | 2009-02-14 23:32:15 -0500 | [diff] [blame] | 1130 | test_suppression cc |
Miklos Vajna | 33c592d | 2008-04-29 12:56:47 +0200 | [diff] [blame] | 1131 | ' |
| 1132 | |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1133 | test_confirm () { |
| 1134 | echo y | \ |
| 1135 | GIT_SEND_EMAIL_NOTTY=1 \ |
| 1136 | git send-email \ |
| 1137 | --from="Example <nobody@example.com>" \ |
| 1138 | --to=nobody@example.com \ |
| 1139 | --smtp-server="$(pwd)/fake.sendmail" \ |
Junio C Hamano | ee756a8 | 2014-11-25 14:52:42 -0800 | [diff] [blame] | 1140 | $@ $patches >stdout && |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1141 | grep "Send this email" stdout |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1142 | } |
| 1143 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1144 | test_expect_success $PREREQ '--confirm=always' ' |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1145 | test_confirm --confirm=always --suppress-cc=all |
| 1146 | ' |
| 1147 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1148 | test_expect_success $PREREQ '--confirm=auto' ' |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1149 | test_confirm --confirm=auto |
| 1150 | ' |
| 1151 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1152 | test_expect_success $PREREQ '--confirm=cc' ' |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1153 | test_confirm --confirm=cc |
| 1154 | ' |
| 1155 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1156 | test_expect_success $PREREQ '--confirm=compose' ' |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1157 | test_confirm --confirm=compose --compose |
| 1158 | ' |
| 1159 | |
Jeff King | 545871b | 2015-03-20 06:13:22 -0400 | [diff] [blame] | 1160 | test_expect_success $PREREQ 'confirm by default (due to cc)' ' |
Jeff King | fc99da1 | 2015-03-25 01:32:20 -0400 | [diff] [blame] | 1161 | test_when_finished git config sendemail.confirm never && |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1162 | git config --unset sendemail.confirm && |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1163 | test_confirm |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1164 | ' |
| 1165 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1166 | test_expect_success $PREREQ 'confirm by default (due to --compose)' ' |
Jeff King | fc99da1 | 2015-03-25 01:32:20 -0400 | [diff] [blame] | 1167 | test_when_finished git config sendemail.confirm never && |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1168 | git config --unset sendemail.confirm && |
| 1169 | test_confirm --suppress-cc=all --compose |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1170 | ' |
| 1171 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1172 | test_expect_success $PREREQ 'confirm detects EOF (inform assumes y)' ' |
Jeff King | fc99da1 | 2015-03-25 01:32:20 -0400 | [diff] [blame] | 1173 | test_when_finished git config sendemail.confirm never && |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1174 | git config --unset sendemail.confirm && |
Jay Soffian | dc1460a | 2009-03-31 12:22:12 -0400 | [diff] [blame] | 1175 | rm -fr outdir && |
| 1176 | git format-patch -2 -o outdir && |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1177 | GIT_SEND_EMAIL_NOTTY=1 \ |
| 1178 | git send-email \ |
| 1179 | --from="Example <nobody@example.com>" \ |
| 1180 | --to=nobody@example.com \ |
| 1181 | --smtp-server="$(pwd)/fake.sendmail" \ |
Junio C Hamano | ee756a8 | 2014-11-25 14:52:42 -0800 | [diff] [blame] | 1182 | outdir/*.patch </dev/null |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1183 | ' |
| 1184 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1185 | test_expect_success $PREREQ 'confirm detects EOF (auto causes failure)' ' |
Jeff King | fc99da1 | 2015-03-25 01:32:20 -0400 | [diff] [blame] | 1186 | test_when_finished git config sendemail.confirm never && |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1187 | git config sendemail.confirm auto && |
Jay Soffian | 3b3637c | 2009-03-31 12:22:13 -0400 | [diff] [blame] | 1188 | GIT_SEND_EMAIL_NOTTY=1 && |
| 1189 | export GIT_SEND_EMAIL_NOTTY && |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1190 | test_must_fail git send-email \ |
| 1191 | --from="Example <nobody@example.com>" \ |
| 1192 | --to=nobody@example.com \ |
| 1193 | --smtp-server="$(pwd)/fake.sendmail" \ |
Junio C Hamano | ee756a8 | 2014-11-25 14:52:42 -0800 | [diff] [blame] | 1194 | $patches </dev/null |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1195 | ' |
| 1196 | |
Stefano Lattarini | 41ccfdd | 2013-04-12 00:36:10 +0200 | [diff] [blame] | 1197 | test_expect_success $PREREQ 'confirm does not loop forever' ' |
Jeff King | fc99da1 | 2015-03-25 01:32:20 -0400 | [diff] [blame] | 1198 | test_when_finished git config sendemail.confirm never && |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1199 | git config sendemail.confirm auto && |
Jay Soffian | 3b3637c | 2009-03-31 12:22:13 -0400 | [diff] [blame] | 1200 | GIT_SEND_EMAIL_NOTTY=1 && |
| 1201 | export GIT_SEND_EMAIL_NOTTY && |
| 1202 | yes "bogus" | test_must_fail git send-email \ |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1203 | --from="Example <nobody@example.com>" \ |
| 1204 | --to=nobody@example.com \ |
| 1205 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1206 | $patches |
Jay Soffian | c18f75a | 2009-03-28 21:39:11 -0400 | [diff] [blame] | 1207 | ' |
| 1208 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1209 | test_expect_success $PREREQ 'utf8 Cc is rfc2047 encoded' ' |
Jay Soffian | a61c0ff | 2009-03-31 12:22:14 -0400 | [diff] [blame] | 1210 | clean_fake_sendmail && |
| 1211 | rm -fr outdir && |
| 1212 | git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" && |
| 1213 | git send-email \ |
| 1214 | --from="Example <nobody@example.com>" \ |
| 1215 | --to=nobody@example.com \ |
| 1216 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1217 | outdir/*.patch && |
Joe Perches | 02461e0 | 2009-10-08 10:03:26 -0700 | [diff] [blame] | 1218 | grep "^ " msgtxt1 | |
Brandon Casey | d1fff6f | 2009-06-06 20:12:31 -0500 | [diff] [blame] | 1219 | grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>" |
Jay Soffian | a61c0ff | 2009-03-31 12:22:14 -0400 | [diff] [blame] | 1220 | ' |
| 1221 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1222 | test_expect_success $PREREQ '--compose adds MIME for utf8 body' ' |
Jeff King | 0706bd1 | 2008-03-28 17:28:33 -0400 | [diff] [blame] | 1223 | clean_fake_sendmail && |
Junio C Hamano | acd72b5 | 2014-11-25 14:21:07 -0800 | [diff] [blame] | 1224 | write_script fake-editor-utf8 <<-\EOF && |
| 1225 | echo "utf8 body: àéìöú" >>"$1" |
| 1226 | EOF |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1227 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
| 1228 | git send-email \ |
| 1229 | --compose --subject foo \ |
| 1230 | --from="Example <nobody@example.com>" \ |
| 1231 | --to=nobody@example.com \ |
| 1232 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1233 | $patches && |
Jeff King | 0706bd1 | 2008-03-28 17:28:33 -0400 | [diff] [blame] | 1234 | grep "^utf8 body" msgtxt1 && |
Brandon Casey | d1fff6f | 2009-06-06 20:12:31 -0500 | [diff] [blame] | 1235 | grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
Jeff King | 0706bd1 | 2008-03-28 17:28:33 -0400 | [diff] [blame] | 1236 | ' |
| 1237 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1238 | test_expect_success $PREREQ '--compose respects user mime type' ' |
Jeff King | 0706bd1 | 2008-03-28 17:28:33 -0400 | [diff] [blame] | 1239 | clean_fake_sendmail && |
Junio C Hamano | acd72b5 | 2014-11-25 14:21:07 -0800 | [diff] [blame] | 1240 | write_script fake-editor-utf8-mime <<-\EOF && |
| 1241 | cat >"$1" <<-\EOM |
| 1242 | MIME-Version: 1.0 |
| 1243 | Content-Type: text/plain; charset=iso-8859-1 |
| 1244 | Content-Transfer-Encoding: 8bit |
| 1245 | Subject: foo |
| 1246 | |
| 1247 | utf8 body: àéìöú |
| 1248 | EOM |
| 1249 | EOF |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1250 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \ |
| 1251 | git send-email \ |
| 1252 | --compose --subject foo \ |
| 1253 | --from="Example <nobody@example.com>" \ |
| 1254 | --to=nobody@example.com \ |
| 1255 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1256 | $patches && |
Jeff King | 0706bd1 | 2008-03-28 17:28:33 -0400 | [diff] [blame] | 1257 | grep "^utf8 body" msgtxt1 && |
| 1258 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 && |
Brandon Casey | d1fff6f | 2009-06-06 20:12:31 -0500 | [diff] [blame] | 1259 | ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1 |
Jeff King | 0706bd1 | 2008-03-28 17:28:33 -0400 | [diff] [blame] | 1260 | ' |
| 1261 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1262 | test_expect_success $PREREQ '--compose adds MIME for utf8 subject' ' |
Jeff King | d54eaaa | 2008-03-28 17:29:01 -0400 | [diff] [blame] | 1263 | clean_fake_sendmail && |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1264 | GIT_EDITOR="\"$(pwd)/fake-editor\"" \ |
| 1265 | git send-email \ |
| 1266 | --compose --subject utf8-sübjëct \ |
| 1267 | --from="Example <nobody@example.com>" \ |
| 1268 | --to=nobody@example.com \ |
| 1269 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1270 | $patches && |
Jeff King | d54eaaa | 2008-03-28 17:29:01 -0400 | [diff] [blame] | 1271 | grep "^fake edit" msgtxt1 && |
Brandon Casey | d1fff6f | 2009-06-06 20:12:31 -0500 | [diff] [blame] | 1272 | grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 |
Jeff King | d54eaaa | 2008-03-28 17:29:01 -0400 | [diff] [blame] | 1273 | ' |
| 1274 | |
Thomas Rast | b622d4d | 2012-07-30 21:25:40 +0200 | [diff] [blame] | 1275 | test_expect_success $PREREQ 'utf8 author is correctly passed on' ' |
| 1276 | clean_fake_sendmail && |
| 1277 | test_commit weird_author && |
| 1278 | test_when_finished "git reset --hard HEAD^" && |
| 1279 | git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" && |
| 1280 | git format-patch --stdout -1 >funny_name.patch && |
| 1281 | git send-email --from="Example <nobody@example.com>" \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1282 | --to=nobody@example.com \ |
| 1283 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1284 | funny_name.patch && |
Thomas Rast | b622d4d | 2012-07-30 21:25:40 +0200 | [diff] [blame] | 1285 | grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1 |
| 1286 | ' |
| 1287 | |
Michael S. Tsirkin | 4cb46bd | 2013-06-18 15:49:26 +0300 | [diff] [blame] | 1288 | test_expect_success $PREREQ 'utf8 sender is not duplicated' ' |
Michael S. Tsirkin | f07075c | 2013-06-18 15:49:29 +0300 | [diff] [blame] | 1289 | clean_fake_sendmail && |
| 1290 | test_commit weird_sender && |
| 1291 | test_when_finished "git reset --hard HEAD^" && |
| 1292 | git commit --amend --author "Füñný Nâmé <odd_?=mail@example.com>" && |
| 1293 | git format-patch --stdout -1 >funny_name.patch && |
| 1294 | git send-email --from="Füñný Nâmé <odd_?=mail@example.com>" \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1295 | --to=nobody@example.com \ |
| 1296 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1297 | funny_name.patch && |
Michael S. Tsirkin | f07075c | 2013-06-18 15:49:29 +0300 | [diff] [blame] | 1298 | grep "^From: " msgtxt1 >msgfrom && |
| 1299 | test_line_count = 1 msgfrom |
| 1300 | ' |
| 1301 | |
Krzysztof Mazur | 62e0069 | 2012-10-10 01:02:56 +0200 | [diff] [blame] | 1302 | test_expect_success $PREREQ 'sendemail.composeencoding works' ' |
| 1303 | clean_fake_sendmail && |
| 1304 | git config sendemail.composeencoding iso-8859-1 && |
Junio C Hamano | acd72b5 | 2014-11-25 14:21:07 -0800 | [diff] [blame] | 1305 | write_script fake-editor-utf8 <<-\EOF && |
| 1306 | echo "utf8 body: àéìöú" >>"$1" |
| 1307 | EOF |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1308 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
| 1309 | git send-email \ |
| 1310 | --compose --subject foo \ |
| 1311 | --from="Example <nobody@example.com>" \ |
| 1312 | --to=nobody@example.com \ |
| 1313 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1314 | $patches && |
Krzysztof Mazur | 62e0069 | 2012-10-10 01:02:56 +0200 | [diff] [blame] | 1315 | grep "^utf8 body" msgtxt1 && |
| 1316 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 |
| 1317 | ' |
| 1318 | |
| 1319 | test_expect_success $PREREQ '--compose-encoding works' ' |
| 1320 | clean_fake_sendmail && |
Junio C Hamano | acd72b5 | 2014-11-25 14:21:07 -0800 | [diff] [blame] | 1321 | write_script fake-editor-utf8 <<-\EOF && |
| 1322 | echo "utf8 body: àéìöú" >>"$1" |
| 1323 | EOF |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1324 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
| 1325 | git send-email \ |
| 1326 | --compose-encoding iso-8859-1 \ |
| 1327 | --compose --subject foo \ |
| 1328 | --from="Example <nobody@example.com>" \ |
| 1329 | --to=nobody@example.com \ |
| 1330 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1331 | $patches && |
Krzysztof Mazur | 62e0069 | 2012-10-10 01:02:56 +0200 | [diff] [blame] | 1332 | grep "^utf8 body" msgtxt1 && |
| 1333 | grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 |
| 1334 | ' |
| 1335 | |
| 1336 | test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencoding' ' |
| 1337 | clean_fake_sendmail && |
| 1338 | git config sendemail.composeencoding iso-8859-1 && |
Junio C Hamano | acd72b5 | 2014-11-25 14:21:07 -0800 | [diff] [blame] | 1339 | write_script fake-editor-utf8 <<-\EOF && |
| 1340 | echo "utf8 body: àéìöú" >>"$1" |
| 1341 | EOF |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1342 | GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \ |
| 1343 | git send-email \ |
| 1344 | --compose-encoding iso-8859-2 \ |
| 1345 | --compose --subject foo \ |
| 1346 | --from="Example <nobody@example.com>" \ |
| 1347 | --to=nobody@example.com \ |
| 1348 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1349 | $patches && |
Krzysztof Mazur | 62e0069 | 2012-10-10 01:02:56 +0200 | [diff] [blame] | 1350 | grep "^utf8 body" msgtxt1 && |
| 1351 | grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1 |
| 1352 | ' |
| 1353 | |
Krzysztof Mazur | 4a47a4d | 2012-10-22 14:41:48 +0200 | [diff] [blame] | 1354 | test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' ' |
| 1355 | clean_fake_sendmail && |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1356 | GIT_EDITOR="\"$(pwd)/fake-editor\"" \ |
| 1357 | git send-email \ |
| 1358 | --compose-encoding iso-8859-2 \ |
| 1359 | --compose --subject utf8-sübjëct \ |
| 1360 | --from="Example <nobody@example.com>" \ |
| 1361 | --to=nobody@example.com \ |
| 1362 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1363 | $patches && |
Krzysztof Mazur | 4a47a4d | 2012-10-22 14:41:48 +0200 | [diff] [blame] | 1364 | grep "^fake edit" msgtxt1 && |
| 1365 | grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1 |
| 1366 | ' |
| 1367 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1368 | test_expect_success $PREREQ 'detects ambiguous reference/file conflict' ' |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 1369 | echo main >main && |
| 1370 | git add main && |
| 1371 | git commit -m"add main" && |
| 1372 | test_must_fail git send-email --dry-run main 2>errors && |
Pierre Habouzit | 5df9fcf | 2008-11-11 00:54:00 +0100 | [diff] [blame] | 1373 | grep disambiguate errors |
| 1374 | ' |
| 1375 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1376 | test_expect_success $PREREQ 'feed two files' ' |
Junio C Hamano | 69f4ce5 | 2008-11-30 22:38:20 -0800 | [diff] [blame] | 1377 | rm -fr outdir && |
| 1378 | git format-patch -2 -o outdir && |
Jay Soffian | c1f2aa4 | 2009-03-02 23:52:18 -0500 | [diff] [blame] | 1379 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1380 | --dry-run \ |
| 1381 | --from="Example <nobody@example.com>" \ |
| 1382 | --to=nobody@example.com \ |
| 1383 | outdir/000?-*.patch 2>errors >out && |
Junio C Hamano | 69f4ce5 | 2008-11-30 22:38:20 -0800 | [diff] [blame] | 1384 | grep "^Subject: " out >subjects && |
| 1385 | test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 1386 | test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add main" |
Junio C Hamano | 69f4ce5 | 2008-11-30 22:38:20 -0800 | [diff] [blame] | 1387 | ' |
| 1388 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1389 | test_expect_success $PREREQ 'in-reply-to but no threading' ' |
Thomas Rast | aaab4b9 | 2009-03-11 23:40:13 +0100 | [diff] [blame] | 1390 | git send-email \ |
| 1391 | --dry-run \ |
| 1392 | --from="Example <nobody@example.com>" \ |
| 1393 | --to=nobody@example.com \ |
| 1394 | --in-reply-to="<in-reply-id@example.com>" \ |
Kyle J. McKay | f471494 | 2015-01-30 18:40:17 -0800 | [diff] [blame] | 1395 | --no-thread \ |
Johannes Schindelin | de26f02 | 2020-02-14 13:53:21 +0000 | [diff] [blame] | 1396 | $patches >out && |
| 1397 | grep "In-Reply-To: <in-reply-id@example.com>" out |
Thomas Rast | aaab4b9 | 2009-03-11 23:40:13 +0100 | [diff] [blame] | 1398 | ' |
| 1399 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1400 | test_expect_success $PREREQ 'no in-reply-to and no threading' ' |
Markus Heidelberg | 32ae831 | 2009-06-12 12:51:37 +0200 | [diff] [blame] | 1401 | git send-email \ |
| 1402 | --dry-run \ |
| 1403 | --from="Example <nobody@example.com>" \ |
| 1404 | --to=nobody@example.com \ |
Kyle J. McKay | f471494 | 2015-01-30 18:40:17 -0800 | [diff] [blame] | 1405 | --no-thread \ |
Ævar Arnfjörð Bjarmason | 2554dd1 | 2019-05-17 21:55:41 +0200 | [diff] [blame] | 1406 | $patches >stdout && |
Markus Heidelberg | 32ae831 | 2009-06-12 12:51:37 +0200 | [diff] [blame] | 1407 | ! grep "In-Reply-To: " stdout |
| 1408 | ' |
| 1409 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1410 | test_expect_success $PREREQ 'threading but no chain-reply-to' ' |
Markus Heidelberg | d67114a | 2009-06-12 12:51:40 +0200 | [diff] [blame] | 1411 | git send-email \ |
| 1412 | --dry-run \ |
| 1413 | --from="Example <nobody@example.com>" \ |
| 1414 | --to=nobody@example.com \ |
| 1415 | --thread \ |
Kyle J. McKay | f471494 | 2015-01-30 18:40:17 -0800 | [diff] [blame] | 1416 | --no-chain-reply-to \ |
Markus Heidelberg | d67114a | 2009-06-12 12:51:40 +0200 | [diff] [blame] | 1417 | $patches $patches >stdout && |
| 1418 | grep "In-Reply-To: " stdout |
| 1419 | ' |
| 1420 | |
Rafael Aquini | f9f60d7 | 2020-06-29 10:11:04 -0400 | [diff] [blame] | 1421 | test_expect_success $PREREQ 'override in-reply-to if no threading' ' |
| 1422 | git send-email \ |
| 1423 | --dry-run \ |
| 1424 | --from="Example <nobody@example.com>" \ |
| 1425 | --to=nobody@example.com \ |
| 1426 | --no-thread \ |
| 1427 | --in-reply-to="override" \ |
| 1428 | $threaded_patches >stdout && |
| 1429 | grep "In-Reply-To: <override>" stdout |
| 1430 | ' |
| 1431 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1432 | test_expect_success $PREREQ 'sendemail.to works' ' |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1433 | git config --replace-all sendemail.to "Somebody <somebody@ex.com>" && |
| 1434 | git send-email \ |
| 1435 | --dry-run \ |
| 1436 | --from="Example <nobody@example.com>" \ |
Ævar Arnfjörð Bjarmason | 2554dd1 | 2019-05-17 21:55:41 +0200 | [diff] [blame] | 1437 | $patches >stdout && |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1438 | grep "To: Somebody <somebody@ex.com>" stdout |
| 1439 | ' |
| 1440 | |
Ævar Arnfjörð Bjarmason | 3ff1504 | 2019-05-17 21:55:44 +0200 | [diff] [blame] | 1441 | test_expect_success $PREREQ 'setup sendemail.identity' ' |
| 1442 | git config --replace-all sendemail.to "default@example.com" && |
| 1443 | git config --replace-all sendemail.isp.to "isp@example.com" && |
| 1444 | git config --replace-all sendemail.cloud.to "cloud@example.com" |
| 1445 | ' |
| 1446 | |
| 1447 | test_expect_success $PREREQ 'sendemail.identity: reads the correct identity config' ' |
| 1448 | git -c sendemail.identity=cloud send-email \ |
| 1449 | --dry-run \ |
| 1450 | --from="nobody@example.com" \ |
| 1451 | $patches >stdout && |
| 1452 | grep "To: cloud@example.com" stdout |
| 1453 | ' |
| 1454 | |
| 1455 | test_expect_success $PREREQ 'sendemail.identity: identity overrides sendemail.identity' ' |
| 1456 | git -c sendemail.identity=cloud send-email \ |
| 1457 | --identity=isp \ |
| 1458 | --dry-run \ |
| 1459 | --from="nobody@example.com" \ |
| 1460 | $patches >stdout && |
| 1461 | grep "To: isp@example.com" stdout |
| 1462 | ' |
| 1463 | |
| 1464 | test_expect_success $PREREQ 'sendemail.identity: --no-identity clears previous identity' ' |
| 1465 | git -c sendemail.identity=cloud send-email \ |
| 1466 | --no-identity \ |
| 1467 | --dry-run \ |
| 1468 | --from="nobody@example.com" \ |
| 1469 | $patches >stdout && |
| 1470 | grep "To: default@example.com" stdout |
| 1471 | ' |
| 1472 | |
Elijah Newren | 4dc8b1c | 2019-11-05 17:07:25 +0000 | [diff] [blame] | 1473 | test_expect_success $PREREQ 'sendemail.identity: bool identity variable existence overrides' ' |
Ævar Arnfjörð Bjarmason | 3ff1504 | 2019-05-17 21:55:44 +0200 | [diff] [blame] | 1474 | git -c sendemail.identity=cloud \ |
| 1475 | -c sendemail.xmailer=true \ |
| 1476 | -c sendemail.cloud.xmailer=false \ |
| 1477 | send-email \ |
| 1478 | --dry-run \ |
| 1479 | --from="nobody@example.com" \ |
| 1480 | $patches >stdout && |
| 1481 | grep "To: cloud@example.com" stdout && |
| 1482 | ! grep "X-Mailer" stdout |
| 1483 | ' |
| 1484 | |
| 1485 | test_expect_success $PREREQ 'sendemail.identity: bool variable fallback' ' |
| 1486 | git -c sendemail.identity=cloud \ |
| 1487 | -c sendemail.xmailer=false \ |
| 1488 | send-email \ |
| 1489 | --dry-run \ |
| 1490 | --from="nobody@example.com" \ |
| 1491 | $patches >stdout && |
| 1492 | grep "To: cloud@example.com" stdout && |
| 1493 | ! grep "X-Mailer" stdout |
| 1494 | ' |
| 1495 | |
Ævar Arnfjörð Bjarmason | 879be43 | 2021-05-28 11:23:41 +0200 | [diff] [blame] | 1496 | test_expect_success $PREREQ 'sendemail.identity: bool variable without a value' ' |
| 1497 | git -c sendemail.xmailer \ |
| 1498 | send-email \ |
| 1499 | --dry-run \ |
| 1500 | --from="nobody@example.com" \ |
| 1501 | $patches >stdout && |
| 1502 | grep "To: default@example.com" stdout && |
| 1503 | grep "X-Mailer" stdout |
| 1504 | ' |
| 1505 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1506 | test_expect_success $PREREQ '--no-to overrides sendemail.to' ' |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1507 | git send-email \ |
| 1508 | --dry-run \ |
| 1509 | --from="Example <nobody@example.com>" \ |
| 1510 | --no-to \ |
| 1511 | --to=nobody@example.com \ |
Ævar Arnfjörð Bjarmason | 2554dd1 | 2019-05-17 21:55:41 +0200 | [diff] [blame] | 1512 | $patches >stdout && |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1513 | grep "To: nobody@example.com" stdout && |
| 1514 | ! grep "To: Somebody <somebody@ex.com>" stdout |
| 1515 | ' |
| 1516 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1517 | test_expect_success $PREREQ 'sendemail.cc works' ' |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1518 | git config --replace-all sendemail.cc "Somebody <somebody@ex.com>" && |
| 1519 | git send-email \ |
| 1520 | --dry-run \ |
| 1521 | --from="Example <nobody@example.com>" \ |
| 1522 | --to=nobody@example.com \ |
Ævar Arnfjörð Bjarmason | 2554dd1 | 2019-05-17 21:55:41 +0200 | [diff] [blame] | 1523 | $patches >stdout && |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1524 | grep "Cc: Somebody <somebody@ex.com>" stdout |
| 1525 | ' |
| 1526 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1527 | test_expect_success $PREREQ '--no-cc overrides sendemail.cc' ' |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1528 | git send-email \ |
| 1529 | --dry-run \ |
| 1530 | --from="Example <nobody@example.com>" \ |
| 1531 | --no-cc \ |
| 1532 | --cc=bodies@example.com \ |
| 1533 | --to=nobody@example.com \ |
Ævar Arnfjörð Bjarmason | 2554dd1 | 2019-05-17 21:55:41 +0200 | [diff] [blame] | 1534 | $patches >stdout && |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1535 | grep "Cc: bodies@example.com" stdout && |
| 1536 | ! grep "Cc: Somebody <somebody@ex.com>" stdout |
| 1537 | ' |
| 1538 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1539 | test_expect_success $PREREQ 'sendemail.bcc works' ' |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1540 | git config --replace-all sendemail.bcc "Other <other@ex.com>" && |
| 1541 | git send-email \ |
| 1542 | --dry-run \ |
| 1543 | --from="Example <nobody@example.com>" \ |
| 1544 | --to=nobody@example.com \ |
| 1545 | --smtp-server relay.example.com \ |
Ævar Arnfjörð Bjarmason | 2554dd1 | 2019-05-17 21:55:41 +0200 | [diff] [blame] | 1546 | $patches >stdout && |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1547 | grep "RCPT TO:<other@ex.com>" stdout |
| 1548 | ' |
| 1549 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1550 | test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' ' |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1551 | git send-email \ |
| 1552 | --dry-run \ |
| 1553 | --from="Example <nobody@example.com>" \ |
| 1554 | --no-bcc \ |
| 1555 | --bcc=bodies@example.com \ |
| 1556 | --to=nobody@example.com \ |
| 1557 | --smtp-server relay.example.com \ |
Ævar Arnfjörð Bjarmason | 2554dd1 | 2019-05-17 21:55:41 +0200 | [diff] [blame] | 1558 | $patches >stdout && |
Stephen Boyd | f434c08 | 2010-03-07 14:46:48 -0800 | [diff] [blame] | 1559 | grep "RCPT TO:<bodies@example.com>" stdout && |
| 1560 | ! grep "RCPT TO:<other@ex.com>" stdout |
| 1561 | ' |
| 1562 | |
Stephen Boyd | 21802cd | 2010-09-29 00:26:44 -0700 | [diff] [blame] | 1563 | test_expect_success $PREREQ 'patches To headers are used by default' ' |
Elia Pinto | bdf20f5 | 2016-01-11 14:34:09 +0100 | [diff] [blame] | 1564 | patch=$(git format-patch -1 --to="bodies@example.com") && |
Stephen Boyd | 21802cd | 2010-09-29 00:26:44 -0700 | [diff] [blame] | 1565 | test_when_finished "rm $patch" && |
| 1566 | git send-email \ |
| 1567 | --dry-run \ |
| 1568 | --from="Example <nobody@example.com>" \ |
| 1569 | --smtp-server relay.example.com \ |
| 1570 | $patch >stdout && |
| 1571 | grep "RCPT TO:<bodies@example.com>" stdout |
| 1572 | ' |
| 1573 | |
| 1574 | test_expect_success $PREREQ 'patches To headers are appended to' ' |
Elia Pinto | bdf20f5 | 2016-01-11 14:34:09 +0100 | [diff] [blame] | 1575 | patch=$(git format-patch -1 --to="bodies@example.com") && |
Stephen Boyd | 21802cd | 2010-09-29 00:26:44 -0700 | [diff] [blame] | 1576 | test_when_finished "rm $patch" && |
| 1577 | git send-email \ |
| 1578 | --dry-run \ |
| 1579 | --from="Example <nobody@example.com>" \ |
| 1580 | --to=nobody@example.com \ |
| 1581 | --smtp-server relay.example.com \ |
| 1582 | $patch >stdout && |
| 1583 | grep "RCPT TO:<bodies@example.com>" stdout && |
| 1584 | grep "RCPT TO:<nobody@example.com>" stdout |
| 1585 | ' |
| 1586 | |
Stephen Boyd | 3c3bb51 | 2010-10-04 00:05:24 -0700 | [diff] [blame] | 1587 | test_expect_success $PREREQ 'To headers from files reset each patch' ' |
Elia Pinto | bdf20f5 | 2016-01-11 14:34:09 +0100 | [diff] [blame] | 1588 | patch1=$(git format-patch -1 --to="bodies@example.com") && |
| 1589 | patch2=$(git format-patch -1 --to="other@example.com" HEAD~) && |
Stephen Boyd | 3c3bb51 | 2010-10-04 00:05:24 -0700 | [diff] [blame] | 1590 | test_when_finished "rm $patch1 && rm $patch2" && |
| 1591 | git send-email \ |
| 1592 | --dry-run \ |
| 1593 | --from="Example <nobody@example.com>" \ |
| 1594 | --to="nobody@example.com" \ |
| 1595 | --smtp-server relay.example.com \ |
| 1596 | $patch1 $patch2 >stdout && |
| 1597 | test $(grep -c "RCPT TO:<bodies@example.com>" stdout) = 1 && |
| 1598 | test $(grep -c "RCPT TO:<nobody@example.com>" stdout) = 2 && |
| 1599 | test $(grep -c "RCPT TO:<other@example.com>" stdout) = 1 |
| 1600 | ' |
| 1601 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1602 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1603 | cat >email-using-8bit <<\EOF |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1604 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 1605 | Message-ID: <bogus-message-id@example.com> |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1606 | From: author@example.com |
| 1607 | Date: Sat, 12 Jun 2010 15:53:58 +0200 |
| 1608 | Subject: subject goes here |
| 1609 | |
| 1610 | Dieser deutsche Text enthält einen Umlaut! |
| 1611 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1612 | ' |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1613 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1614 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1615 | echo "Subject: subject goes here" >expected |
Krzysztof Mazur | 5637d85 | 2012-10-24 10:03:35 +0200 | [diff] [blame] | 1616 | ' |
| 1617 | |
| 1618 | test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' ' |
| 1619 | clean_fake_sendmail && |
| 1620 | echo bogus | |
| 1621 | git send-email --from=author@example.com --to=nobody@example.com \ |
| 1622 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1623 | --8bit-encoding=UTF-8 \ |
| 1624 | email-using-8bit >stdout && |
| 1625 | grep "Subject" msgtxt1 >actual && |
| 1626 | test_cmp expected actual |
| 1627 | ' |
| 1628 | |
| 1629 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1630 | cat >content-type-decl <<-\EOF |
| 1631 | MIME-Version: 1.0 |
| 1632 | Content-Type: text/plain; charset=UTF-8 |
| 1633 | Content-Transfer-Encoding: 8bit |
| 1634 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1635 | ' |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1636 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1637 | test_expect_success $PREREQ 'asks about and fixes 8bit encodings' ' |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1638 | clean_fake_sendmail && |
| 1639 | echo | |
| 1640 | git send-email --from=author@example.com --to=nobody@example.com \ |
| 1641 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1642 | email-using-8bit >stdout && |
| 1643 | grep "do not declare a Content-Transfer-Encoding" stdout && |
| 1644 | grep email-using-8bit stdout && |
| 1645 | grep "Which 8bit encoding" stdout && |
Đoàn Trần Công Danh | 81580fa | 2022-09-21 20:02:31 +0700 | [diff] [blame] | 1646 | grep -E "Content|MIME" msgtxt1 >actual && |
Stefan Beller | 9c5b2fa | 2017-10-06 12:00:06 -0700 | [diff] [blame] | 1647 | test_cmp content-type-decl actual |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1648 | ' |
| 1649 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1650 | test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1651 | clean_fake_sendmail && |
| 1652 | git config sendemail.assume8bitEncoding UTF-8 && |
| 1653 | echo bogus | |
| 1654 | git send-email --from=author@example.com --to=nobody@example.com \ |
| 1655 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1656 | email-using-8bit >stdout && |
Đoàn Trần Công Danh | 81580fa | 2022-09-21 20:02:31 +0700 | [diff] [blame] | 1657 | grep -E "Content|MIME" msgtxt1 >actual && |
Stefan Beller | 9c5b2fa | 2017-10-06 12:00:06 -0700 | [diff] [blame] | 1658 | test_cmp content-type-decl actual |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1659 | ' |
| 1660 | |
Ævar Arnfjörð Bjarmason | b996f84 | 2021-09-06 09:33:29 +0200 | [diff] [blame] | 1661 | test_expect_success $PREREQ 'sendemail.8bitEncoding in .git/config overrides --global .gitconfig' ' |
| 1662 | clean_fake_sendmail && |
| 1663 | git config sendemail.assume8bitEncoding UTF-8 && |
| 1664 | test_when_finished "rm -rf home" && |
| 1665 | mkdir home && |
| 1666 | git config -f home/.gitconfig sendemail.assume8bitEncoding "bogus too" && |
| 1667 | echo bogus | |
| 1668 | env HOME="$(pwd)/home" DEBUG=1 \ |
| 1669 | git send-email --from=author@example.com --to=nobody@example.com \ |
| 1670 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1671 | email-using-8bit >stdout && |
Đoàn Trần Công Danh | 81580fa | 2022-09-21 20:02:31 +0700 | [diff] [blame] | 1672 | grep -E "Content|MIME" msgtxt1 >actual && |
Ævar Arnfjörð Bjarmason | b996f84 | 2021-09-06 09:33:29 +0200 | [diff] [blame] | 1673 | test_cmp content-type-decl actual |
| 1674 | ' |
| 1675 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1676 | test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1677 | clean_fake_sendmail && |
| 1678 | git config sendemail.assume8bitEncoding "bogus too" && |
| 1679 | echo bogus | |
| 1680 | git send-email --from=author@example.com --to=nobody@example.com \ |
| 1681 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1682 | --8bit-encoding=UTF-8 \ |
| 1683 | email-using-8bit >stdout && |
Đoàn Trần Công Danh | 81580fa | 2022-09-21 20:02:31 +0700 | [diff] [blame] | 1684 | grep -E "Content|MIME" msgtxt1 >actual && |
Stefan Beller | 9c5b2fa | 2017-10-06 12:00:06 -0700 | [diff] [blame] | 1685 | test_cmp content-type-decl actual |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1686 | ' |
| 1687 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1688 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1689 | cat >email-using-8bit <<-\EOF |
| 1690 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 1691 | Message-ID: <bogus-message-id@example.com> |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1692 | From: author@example.com |
| 1693 | Date: Sat, 12 Jun 2010 15:53:58 +0200 |
| 1694 | Subject: Dieser Betreff enthält auch einen Umlaut! |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1695 | |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1696 | Nothing to see here. |
| 1697 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1698 | ' |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1699 | |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1700 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1701 | cat >expected <<-\EOF |
| 1702 | Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?= |
| 1703 | EOF |
Ævar Arnfjörð Bjarmason | f944414 | 2010-08-13 20:40:10 +0000 | [diff] [blame] | 1704 | ' |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1705 | |
Ævar Arnfjörð Bjarmason | 57cd35e | 2010-08-13 20:40:09 +0000 | [diff] [blame] | 1706 | test_expect_success $PREREQ '--8bit-encoding also treats subject' ' |
Thomas Rast | 3cae7e5 | 2010-06-17 22:10:39 +0200 | [diff] [blame] | 1707 | clean_fake_sendmail && |
| 1708 | echo bogus | |
| 1709 | git send-email --from=author@example.com --to=nobody@example.com \ |
| 1710 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1711 | --8bit-encoding=UTF-8 \ |
| 1712 | email-using-8bit >stdout && |
| 1713 | grep "Subject" msgtxt1 >actual && |
| 1714 | test_cmp expected actual |
| 1715 | ' |
| 1716 | |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1717 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1718 | cat >email-using-8bit <<-\EOF |
| 1719 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 1720 | Message-ID: <bogus-message-id@example.com> |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1721 | From: A U Thor <author@example.com> |
| 1722 | Date: Sat, 12 Jun 2010 15:53:58 +0200 |
| 1723 | Content-Type: text/plain; charset=UTF-8 |
| 1724 | Subject: Nothing to see here. |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1725 | |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1726 | Dieser Betreff enthält auch einen Umlaut! |
| 1727 | EOF |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1728 | ' |
| 1729 | |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1730 | test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' ' |
| 1731 | clean_fake_sendmail && |
Ævar Arnfjörð Bjarmason | a8aea5d | 2019-05-17 21:55:42 +0200 | [diff] [blame] | 1732 | test_must_fail git -c sendemail.transferEncoding=8bit \ |
| 1733 | send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1734 | --transfer-encoding=7bit \ |
| 1735 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1736 | email-using-8bit \ |
| 1737 | 2>errors >out && |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1738 | grep "cannot send message as 7bit" errors && |
| 1739 | test -z "$(ls msgtxt*)" |
| 1740 | ' |
| 1741 | |
Ævar Arnfjörð Bjarmason | a8aea5d | 2019-05-17 21:55:42 +0200 | [diff] [blame] | 1742 | test_expect_success $PREREQ 'sendemail.transferEncoding via config' ' |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1743 | clean_fake_sendmail && |
Ævar Arnfjörð Bjarmason | a8aea5d | 2019-05-17 21:55:42 +0200 | [diff] [blame] | 1744 | test_must_fail git -c sendemail.transferEncoding=7bit \ |
| 1745 | send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1746 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1747 | email-using-8bit \ |
| 1748 | 2>errors >out && |
Ævar Arnfjörð Bjarmason | a8aea5d | 2019-05-17 21:55:42 +0200 | [diff] [blame] | 1749 | grep "cannot send message as 7bit" errors && |
| 1750 | test -z "$(ls msgtxt*)" |
Ævar Arnfjörð Bjarmason | 3494dfd | 2019-05-09 13:48:30 +0200 | [diff] [blame] | 1751 | ' |
| 1752 | |
Ævar Arnfjörð Bjarmason | a8aea5d | 2019-05-17 21:55:42 +0200 | [diff] [blame] | 1753 | test_expect_success $PREREQ 'sendemail.transferEncoding via cli' ' |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1754 | clean_fake_sendmail && |
Ævar Arnfjörð Bjarmason | a8aea5d | 2019-05-17 21:55:42 +0200 | [diff] [blame] | 1755 | test_must_fail git send-email \ |
| 1756 | --transfer-encoding=7bit \ |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1757 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1758 | email-using-8bit \ |
| 1759 | 2>errors >out && |
Ævar Arnfjörð Bjarmason | a8aea5d | 2019-05-17 21:55:42 +0200 | [diff] [blame] | 1760 | grep "cannot send message as 7bit" errors && |
| 1761 | test -z "$(ls msgtxt*)" |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1762 | ' |
| 1763 | |
| 1764 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1765 | cat >expected <<-\EOF |
| 1766 | Dieser Betreff enth=C3=A4lt auch einen Umlaut! |
| 1767 | EOF |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1768 | ' |
| 1769 | |
| 1770 | test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' ' |
| 1771 | clean_fake_sendmail && |
| 1772 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1773 | --transfer-encoding=quoted-printable \ |
| 1774 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1775 | email-using-8bit \ |
| 1776 | 2>errors >out && |
Martin Ågren | c76b84a | 2020-08-06 22:08:53 +0200 | [diff] [blame] | 1777 | sed "1,/^$/d" msgtxt1 >actual && |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1778 | test_cmp expected actual |
| 1779 | ' |
| 1780 | |
| 1781 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1782 | cat >expected <<-\EOF |
| 1783 | RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg== |
| 1784 | EOF |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1785 | ' |
| 1786 | |
| 1787 | test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' ' |
| 1788 | clean_fake_sendmail && |
| 1789 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1790 | --transfer-encoding=base64 \ |
| 1791 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1792 | email-using-8bit \ |
| 1793 | 2>errors >out && |
Martin Ågren | c76b84a | 2020-08-06 22:08:53 +0200 | [diff] [blame] | 1794 | sed "1,/^$/d" msgtxt1 >actual && |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1795 | test_cmp expected actual |
| 1796 | ' |
| 1797 | |
| 1798 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1799 | cat >email-using-qp <<-\EOF |
| 1800 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 1801 | Message-ID: <bogus-message-id@example.com> |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1802 | From: A U Thor <author@example.com> |
| 1803 | Date: Sat, 12 Jun 2010 15:53:58 +0200 |
| 1804 | MIME-Version: 1.0 |
| 1805 | Content-Transfer-Encoding: quoted-printable |
| 1806 | Content-Type: text/plain; charset=UTF-8 |
| 1807 | Subject: Nothing to see here. |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1808 | |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1809 | Dieser Betreff enth=C3=A4lt auch einen Umlaut! |
| 1810 | EOF |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1811 | ' |
| 1812 | |
| 1813 | test_expect_success $PREREQ 'convert from quoted-printable to base64' ' |
| 1814 | clean_fake_sendmail && |
| 1815 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1816 | --transfer-encoding=base64 \ |
| 1817 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1818 | email-using-qp \ |
| 1819 | 2>errors >out && |
Martin Ågren | c76b84a | 2020-08-06 22:08:53 +0200 | [diff] [blame] | 1820 | sed "1,/^$/d" msgtxt1 >actual && |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1821 | test_cmp expected actual |
| 1822 | ' |
| 1823 | |
| 1824 | test_expect_success $PREREQ 'setup expect' " |
Junio C Hamano | ee756a8 | 2014-11-25 14:52:42 -0800 | [diff] [blame] | 1825 | tr -d '\\015' | tr '%' '\\015' >email-using-crlf <<EOF |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1826 | From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001 |
Junio C Hamano | ba4324c | 2022-12-16 10:47:19 +0900 | [diff] [blame] | 1827 | Message-ID: <bogus-message-id@example.com> |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1828 | From: A U Thor <author@example.com> |
| 1829 | Date: Sat, 12 Jun 2010 15:53:58 +0200 |
| 1830 | Content-Type: text/plain; charset=UTF-8 |
| 1831 | Subject: Nothing to see here. |
| 1832 | |
| 1833 | Look, I have a CRLF and an = sign!% |
| 1834 | EOF |
| 1835 | " |
| 1836 | |
| 1837 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1838 | cat >expected <<-\EOF |
| 1839 | Look, I have a CRLF and an =3D sign!=0D |
| 1840 | EOF |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1841 | ' |
| 1842 | |
| 1843 | test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' ' |
| 1844 | clean_fake_sendmail && |
| 1845 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1846 | --transfer-encoding=quoted-printable \ |
| 1847 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1848 | email-using-crlf \ |
| 1849 | 2>errors >out && |
Martin Ågren | c76b84a | 2020-08-06 22:08:53 +0200 | [diff] [blame] | 1850 | sed "1,/^$/d" msgtxt1 >actual && |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1851 | test_cmp expected actual |
| 1852 | ' |
| 1853 | |
| 1854 | test_expect_success $PREREQ 'setup expect' ' |
Junio C Hamano | 0720a51 | 2014-11-25 15:03:45 -0800 | [diff] [blame] | 1855 | cat >expected <<-\EOF |
| 1856 | TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K |
| 1857 | EOF |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1858 | ' |
| 1859 | |
| 1860 | test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' ' |
| 1861 | clean_fake_sendmail && |
| 1862 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1863 | --transfer-encoding=base64 \ |
| 1864 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1865 | email-using-crlf \ |
| 1866 | 2>errors >out && |
Martin Ågren | c76b84a | 2020-08-06 22:08:53 +0200 | [diff] [blame] | 1867 | sed "1,/^$/d" msgtxt1 >actual && |
Paolo Bonzini | 8d81408 | 2014-11-25 15:00:27 +0100 | [diff] [blame] | 1868 | test_cmp expected actual |
| 1869 | ' |
| 1870 | |
| 1871 | |
Thomas Rast | a03bc5b | 2009-06-08 23:34:12 +0200 | [diff] [blame] | 1872 | # Note that the patches in this test are deliberately out of order; we |
| 1873 | # want to make sure it works even if the cover-letter is not in the |
| 1874 | # first mail. |
Robin H. Johnson | 57da204 | 2010-12-29 21:02:31 +0000 | [diff] [blame] | 1875 | test_expect_success $PREREQ 'refusing to send cover letter template' ' |
Thomas Rast | a03bc5b | 2009-06-08 23:34:12 +0200 | [diff] [blame] | 1876 | clean_fake_sendmail && |
| 1877 | rm -fr outdir && |
| 1878 | git format-patch --cover-letter -2 -o outdir && |
| 1879 | test_must_fail git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1880 | --from="Example <nobody@example.com>" \ |
| 1881 | --to=nobody@example.com \ |
| 1882 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1883 | outdir/0002-*.patch \ |
| 1884 | outdir/0000-*.patch \ |
| 1885 | outdir/0001-*.patch \ |
| 1886 | 2>errors >out && |
Thomas Rast | a03bc5b | 2009-06-08 23:34:12 +0200 | [diff] [blame] | 1887 | grep "SUBJECT HERE" errors && |
| 1888 | test -z "$(ls msgtxt*)" |
| 1889 | ' |
| 1890 | |
Robin H. Johnson | 57da204 | 2010-12-29 21:02:31 +0000 | [diff] [blame] | 1891 | test_expect_success $PREREQ '--force sends cover letter template anyway' ' |
Thomas Rast | a03bc5b | 2009-06-08 23:34:12 +0200 | [diff] [blame] | 1892 | clean_fake_sendmail && |
| 1893 | rm -fr outdir && |
| 1894 | git format-patch --cover-letter -2 -o outdir && |
| 1895 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1896 | --force \ |
| 1897 | --from="Example <nobody@example.com>" \ |
| 1898 | --to=nobody@example.com \ |
| 1899 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1900 | outdir/0002-*.patch \ |
| 1901 | outdir/0000-*.patch \ |
| 1902 | outdir/0001-*.patch \ |
| 1903 | 2>errors >out && |
Thomas Rast | a03bc5b | 2009-06-08 23:34:12 +0200 | [diff] [blame] | 1904 | ! grep "SUBJECT HERE" errors && |
| 1905 | test -n "$(ls msgtxt*)" |
| 1906 | ' |
| 1907 | |
Michael S. Tsirkin | 8ccc4e4 | 2014-04-29 08:41:18 +0300 | [diff] [blame] | 1908 | test_cover_addresses () { |
| 1909 | header="$1" |
| 1910 | shift |
| 1911 | clean_fake_sendmail && |
| 1912 | rm -fr outdir && |
| 1913 | git format-patch --cover-letter -2 -o outdir && |
Elia Pinto | bdf20f5 | 2016-01-11 14:34:09 +0100 | [diff] [blame] | 1914 | cover=$(echo outdir/0000-*.patch) && |
Michael S. Tsirkin | 8ccc4e4 | 2014-04-29 08:41:18 +0300 | [diff] [blame] | 1915 | mv $cover cover-to-edit.patch && |
Torsten Bögershausen | 35ec002 | 2014-06-10 06:07:59 +0200 | [diff] [blame] | 1916 | perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" && |
Michael S. Tsirkin | 8ccc4e4 | 2014-04-29 08:41:18 +0300 | [diff] [blame] | 1917 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1918 | --force \ |
| 1919 | --from="Example <nobody@example.com>" \ |
| 1920 | --no-to --no-cc \ |
| 1921 | "$@" \ |
| 1922 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1923 | outdir/0000-*.patch \ |
| 1924 | outdir/0001-*.patch \ |
| 1925 | outdir/0002-*.patch \ |
| 1926 | 2>errors >out && |
Michael S. Tsirkin | 8ccc4e4 | 2014-04-29 08:41:18 +0300 | [diff] [blame] | 1927 | grep "^$header: extra@address.com" msgtxt1 >to1 && |
| 1928 | grep "^$header: extra@address.com" msgtxt2 >to2 && |
| 1929 | grep "^$header: extra@address.com" msgtxt3 >to3 && |
| 1930 | test_line_count = 1 to1 && |
| 1931 | test_line_count = 1 to2 && |
| 1932 | test_line_count = 1 to3 |
| 1933 | } |
| 1934 | |
| 1935 | test_expect_success $PREREQ 'to-cover adds To to all mail' ' |
| 1936 | test_cover_addresses "To" --to-cover |
| 1937 | ' |
| 1938 | |
| 1939 | test_expect_success $PREREQ 'cc-cover adds Cc to all mail' ' |
| 1940 | test_cover_addresses "Cc" --cc-cover |
| 1941 | ' |
| 1942 | |
| 1943 | test_expect_success $PREREQ 'tocover adds To to all mail' ' |
| 1944 | test_config sendemail.tocover true && |
| 1945 | test_cover_addresses "To" |
| 1946 | ' |
| 1947 | |
| 1948 | test_expect_success $PREREQ 'cccover adds Cc to all mail' ' |
| 1949 | test_config sendemail.cccover true && |
| 1950 | test_cover_addresses "Cc" |
| 1951 | ' |
| 1952 | |
Eric Wong | 2c510f2 | 2016-01-04 20:53:30 +0000 | [diff] [blame] | 1953 | test_expect_success $PREREQ 'escaped quotes in sendemail.aliasfiletype=mutt' ' |
| 1954 | clean_fake_sendmail && |
| 1955 | echo "alias sbd \\\"Dot U. Sir\\\" <somebody@example.org>" >.mutt && |
| 1956 | git config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" && |
| 1957 | git config sendemail.aliasfiletype mutt && |
| 1958 | git send-email \ |
| 1959 | --from="Example <nobody@example.com>" \ |
| 1960 | --to=sbd \ |
| 1961 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1962 | outdir/0001-*.patch \ |
| 1963 | 2>errors >out && |
| 1964 | grep "^!somebody@example\.org!$" commandline1 && |
| 1965 | grep -F "To: \"Dot U. Sir\" <somebody@example.org>" out |
| 1966 | ' |
| 1967 | |
Cord Seele | 463b0ea | 2011-10-14 22:53:31 +0200 | [diff] [blame] | 1968 | test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' ' |
| 1969 | clean_fake_sendmail && |
| 1970 | echo "alias sbd somebody@example.org" >.mailrc && |
| 1971 | git config --replace-all sendemail.aliasesfile "$(pwd)/.mailrc" && |
| 1972 | git config sendemail.aliasfiletype mailrc && |
| 1973 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1974 | --from="Example <nobody@example.com>" \ |
| 1975 | --to=sbd \ |
| 1976 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1977 | outdir/0001-*.patch \ |
| 1978 | 2>errors >out && |
Cord Seele | 463b0ea | 2011-10-14 22:53:31 +0200 | [diff] [blame] | 1979 | grep "^!somebody@example\.org!$" commandline1 |
| 1980 | ' |
| 1981 | |
Andrei Rybak | 6fc5369 | 2021-06-25 21:38:50 +0200 | [diff] [blame] | 1982 | test_expect_success $PREREQ 'sendemail.aliasesfile=~/.mailrc' ' |
Cord Seele | 463b0ea | 2011-10-14 22:53:31 +0200 | [diff] [blame] | 1983 | clean_fake_sendmail && |
Junio C Hamano | 587089c | 2015-05-23 11:07:50 -0700 | [diff] [blame] | 1984 | echo "alias sbd someone@example.org" >"$HOME/.mailrc" && |
Cord Seele | 463b0ea | 2011-10-14 22:53:31 +0200 | [diff] [blame] | 1985 | git config --replace-all sendemail.aliasesfile "~/.mailrc" && |
| 1986 | git config sendemail.aliasfiletype mailrc && |
| 1987 | git send-email \ |
Junio C Hamano | 03335f2 | 2014-11-25 14:14:41 -0800 | [diff] [blame] | 1988 | --from="Example <nobody@example.com>" \ |
| 1989 | --to=sbd \ |
| 1990 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 1991 | outdir/0001-*.patch \ |
| 1992 | 2>errors >out && |
Cord Seele | 463b0ea | 2011-10-14 22:53:31 +0200 | [diff] [blame] | 1993 | grep "^!someone@example\.org!$" commandline1 |
| 1994 | ' |
| 1995 | |
Jacob Keller | 17b7a83 | 2015-11-19 14:52:11 -0800 | [diff] [blame] | 1996 | test_dump_aliases () { |
| 1997 | msg="$1" && shift && |
| 1998 | filetype="$1" && shift && |
| 1999 | printf '%s\n' "$@" >expect && |
| 2000 | cat >.tmp-email-aliases && |
| 2001 | |
| 2002 | test_expect_success $PREREQ "$msg" ' |
| 2003 | clean_fake_sendmail && rm -fr outdir && |
| 2004 | git config --replace-all sendemail.aliasesfile \ |
| 2005 | "$(pwd)/.tmp-email-aliases" && |
| 2006 | git config sendemail.aliasfiletype "$filetype" && |
| 2007 | git send-email --dump-aliases 2>errors >actual && |
| 2008 | test_cmp expect actual |
| 2009 | ' |
| 2010 | } |
| 2011 | |
| 2012 | test_dump_aliases '--dump-aliases sendmail format' \ |
| 2013 | 'sendmail' \ |
| 2014 | 'abgroup' \ |
| 2015 | 'alice' \ |
| 2016 | 'bcgrp' \ |
| 2017 | 'bob' \ |
| 2018 | 'chloe' <<-\EOF |
| 2019 | alice: Alice W Land <awol@example.com> |
| 2020 | bob: Robert Bobbyton <bob@example.com> |
| 2021 | chloe: chloe@example.com |
| 2022 | abgroup: alice, bob |
| 2023 | bcgrp: bob, chloe, Other <o@example.com> |
| 2024 | EOF |
| 2025 | |
| 2026 | test_dump_aliases '--dump-aliases mutt format' \ |
| 2027 | 'mutt' \ |
| 2028 | 'alice' \ |
| 2029 | 'bob' \ |
| 2030 | 'chloe' \ |
| 2031 | 'donald' <<-\EOF |
| 2032 | alias alice Alice W Land <awol@example.com> |
| 2033 | alias donald Donald C Carlton <donc@example.com> |
| 2034 | alias bob Robert Bobbyton <bob@example.com> |
| 2035 | alias chloe chloe@example.com |
| 2036 | EOF |
| 2037 | |
| 2038 | test_dump_aliases '--dump-aliases mailrc format' \ |
| 2039 | 'mailrc' \ |
| 2040 | 'alice' \ |
| 2041 | 'bob' \ |
| 2042 | 'chloe' \ |
| 2043 | 'eve' <<-\EOF |
| 2044 | alias alice Alice W Land <awol@example.com> |
| 2045 | alias eve Eve <eve@example.com> |
| 2046 | alias bob Robert Bobbyton <bob@example.com> |
| 2047 | alias chloe chloe@example.com |
| 2048 | EOF |
| 2049 | |
| 2050 | test_dump_aliases '--dump-aliases pine format' \ |
| 2051 | 'pine' \ |
| 2052 | 'alice' \ |
| 2053 | 'bob' \ |
| 2054 | 'chloe' \ |
| 2055 | 'eve' <<-\EOF |
| 2056 | alice Alice W Land <awol@example.com> |
| 2057 | eve Eve <eve@example.com> |
| 2058 | bob Robert Bobbyton <bob@example.com> |
| 2059 | chloe chloe@example.com |
| 2060 | EOF |
| 2061 | |
| 2062 | test_dump_aliases '--dump-aliases gnus format' \ |
| 2063 | 'gnus' \ |
| 2064 | 'alice' \ |
| 2065 | 'bob' \ |
| 2066 | 'chloe' \ |
| 2067 | 'eve' <<-\EOF |
| 2068 | (define-mail-alias "alice" "awol@example.com") |
| 2069 | (define-mail-alias "eve" "eve@example.com") |
| 2070 | (define-mail-alias "bob" "bob@example.com") |
| 2071 | (define-mail-alias "chloe" "chloe@example.com") |
| 2072 | EOF |
| 2073 | |
| 2074 | test_expect_success '--dump-aliases must be used alone' ' |
| 2075 | test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting |
| 2076 | ' |
| 2077 | |
Ævar Arnfjörð Bjarmason | 3ff1504 | 2019-05-17 21:55:44 +0200 | [diff] [blame] | 2078 | test_expect_success $PREREQ 'aliases and sendemail.identity' ' |
| 2079 | test_must_fail git \ |
| 2080 | -c sendemail.identity=cloud \ |
| 2081 | -c sendemail.aliasesfile=default-aliases \ |
| 2082 | -c sendemail.cloud.aliasesfile=cloud-aliases \ |
| 2083 | send-email -1 2>stderr && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 2084 | test_grep "cloud-aliases" stderr |
Ævar Arnfjörð Bjarmason | 3ff1504 | 2019-05-17 21:55:44 +0200 | [diff] [blame] | 2085 | ' |
| 2086 | |
Eric Sunshine | 514554c | 2015-05-31 18:29:30 -0400 | [diff] [blame] | 2087 | test_sendmail_aliases () { |
| 2088 | msg="$1" && shift && |
| 2089 | expect="$@" && |
| 2090 | cat >.tmp-email-aliases && |
| 2091 | |
| 2092 | test_expect_success $PREREQ "$msg" ' |
| 2093 | clean_fake_sendmail && rm -fr outdir && |
| 2094 | git format-patch -1 -o outdir && |
| 2095 | git config --replace-all sendemail.aliasesfile \ |
| 2096 | "$(pwd)/.tmp-email-aliases" && |
| 2097 | git config sendemail.aliasfiletype sendmail && |
| 2098 | git send-email \ |
| 2099 | --from="Example <nobody@example.com>" \ |
| 2100 | --to=alice --to=bcgrp \ |
| 2101 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2102 | outdir/0001-*.patch \ |
| 2103 | 2>errors >out && |
| 2104 | for i in $expect |
| 2105 | do |
| 2106 | grep "^!$i!$" commandline1 || return 1 |
| 2107 | done |
| 2108 | ' |
| 2109 | } |
| 2110 | |
| 2111 | test_sendmail_aliases 'sendemail.aliasfiletype=sendmail' \ |
| 2112 | 'awol@example\.com' \ |
| 2113 | 'bob@example\.com' \ |
| 2114 | 'chloe@example\.com' \ |
| 2115 | 'o@example\.com' <<-\EOF |
Allen Hubbe | 3169e06 | 2015-05-26 17:32:03 -0400 | [diff] [blame] | 2116 | alice: Alice W Land <awol@example.com> |
| 2117 | bob: Robert Bobbyton <bob@example.com> |
| 2118 | # this is a comment |
| 2119 | # this is also a comment |
| 2120 | chloe: chloe@example.com |
| 2121 | abgroup: alice, bob |
| 2122 | bcgrp: bob, chloe, Other <o@example.com> |
| 2123 | EOF |
Allen Hubbe | 3169e06 | 2015-05-26 17:32:03 -0400 | [diff] [blame] | 2124 | |
Eric Sunshine | 6be0264 | 2015-05-31 18:29:31 -0400 | [diff] [blame] | 2125 | test_sendmail_aliases 'sendmail aliases line folding' \ |
| 2126 | alice1 \ |
| 2127 | bob1 bob2 \ |
| 2128 | chuck1 chuck2 \ |
| 2129 | darla1 darla2 darla3 \ |
| 2130 | elton1 elton2 elton3 \ |
| 2131 | fred1 fred2 \ |
| 2132 | greg1 <<-\EOF |
| 2133 | alice: alice1 |
| 2134 | bob: bob1,\ |
| 2135 | bob2 |
| 2136 | chuck: chuck1, |
| 2137 | chuck2 |
| 2138 | darla: darla1,\ |
| 2139 | darla2, |
| 2140 | darla3 |
| 2141 | elton: elton1, |
| 2142 | elton2,\ |
| 2143 | elton3 |
| 2144 | fred: fred1,\ |
| 2145 | fred2 |
| 2146 | greg: greg1 |
| 2147 | bcgrp: bob, chuck, darla, elton, fred, greg |
| 2148 | EOF |
| 2149 | |
| 2150 | test_sendmail_aliases 'sendmail aliases tolerate bogus line folding' \ |
| 2151 | alice1 bob1 <<-\EOF |
| 2152 | alice: alice1 |
| 2153 | bcgrp: bob1\ |
| 2154 | EOF |
| 2155 | |
| 2156 | test_sendmail_aliases 'sendmail aliases empty' alice bcgrp <<-\EOF |
| 2157 | EOF |
| 2158 | |
Remi Lespinet | f6f79e5 | 2015-06-30 14:16:43 +0200 | [diff] [blame] | 2159 | test_expect_success $PREREQ 'alias support in To header' ' |
| 2160 | clean_fake_sendmail && |
| 2161 | echo "alias sbd someone@example.org" >.mailrc && |
| 2162 | test_config sendemail.aliasesfile ".mailrc" && |
| 2163 | test_config sendemail.aliasfiletype mailrc && |
| 2164 | git format-patch --stdout -1 --to=sbd >aliased.patch && |
| 2165 | git send-email \ |
| 2166 | --from="Example <nobody@example.com>" \ |
| 2167 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2168 | aliased.patch \ |
| 2169 | 2>errors >out && |
| 2170 | grep "^!someone@example\.org!$" commandline1 |
| 2171 | ' |
| 2172 | |
| 2173 | test_expect_success $PREREQ 'alias support in Cc header' ' |
| 2174 | clean_fake_sendmail && |
| 2175 | echo "alias sbd someone@example.org" >.mailrc && |
| 2176 | test_config sendemail.aliasesfile ".mailrc" && |
| 2177 | test_config sendemail.aliasfiletype mailrc && |
| 2178 | git format-patch --stdout -1 --cc=sbd >aliased.patch && |
| 2179 | git send-email \ |
| 2180 | --from="Example <nobody@example.com>" \ |
| 2181 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2182 | aliased.patch \ |
| 2183 | 2>errors >out && |
| 2184 | grep "^!someone@example\.org!$" commandline1 |
| 2185 | ' |
| 2186 | |
| 2187 | test_expect_success $PREREQ 'tocmd works with aliases' ' |
| 2188 | clean_fake_sendmail && |
| 2189 | echo "alias sbd someone@example.org" >.mailrc && |
| 2190 | test_config sendemail.aliasesfile ".mailrc" && |
| 2191 | test_config sendemail.aliasfiletype mailrc && |
| 2192 | git format-patch --stdout -1 >tocmd.patch && |
| 2193 | echo tocmd--sbd >>tocmd.patch && |
| 2194 | git send-email \ |
| 2195 | --from="Example <nobody@example.com>" \ |
| 2196 | --to-cmd=./tocmd-sed \ |
| 2197 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2198 | tocmd.patch \ |
| 2199 | 2>errors >out && |
| 2200 | grep "^!someone@example\.org!$" commandline1 |
| 2201 | ' |
| 2202 | |
| 2203 | test_expect_success $PREREQ 'cccmd works with aliases' ' |
| 2204 | clean_fake_sendmail && |
| 2205 | echo "alias sbd someone@example.org" >.mailrc && |
| 2206 | test_config sendemail.aliasesfile ".mailrc" && |
| 2207 | test_config sendemail.aliasfiletype mailrc && |
| 2208 | git format-patch --stdout -1 >cccmd.patch && |
| 2209 | echo cccmd--sbd >>cccmd.patch && |
| 2210 | git send-email \ |
| 2211 | --from="Example <nobody@example.com>" \ |
| 2212 | --cc-cmd=./cccmd-sed \ |
| 2213 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2214 | cccmd.patch \ |
| 2215 | 2>errors >out && |
| 2216 | grep "^!someone@example\.org!$" commandline1 |
| 2217 | ' |
| 2218 | |
Luis Henriques | 2cf770f | 2014-12-04 19:11:30 +0000 | [diff] [blame] | 2219 | do_xmailer_test () { |
| 2220 | expected=$1 params=$2 && |
| 2221 | git format-patch -1 && |
| 2222 | git send-email \ |
| 2223 | --from="Example <nobody@example.com>" \ |
| 2224 | --to=someone@example.com \ |
| 2225 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2226 | $params \ |
| 2227 | 0001-*.patch \ |
| 2228 | 2>errors >out && |
| 2229 | { grep '^X-Mailer:' out || :; } >mailer && |
| 2230 | test_line_count = $expected mailer |
| 2231 | } |
| 2232 | |
| 2233 | test_expect_success $PREREQ '--[no-]xmailer without any configuration' ' |
| 2234 | do_xmailer_test 1 "--xmailer" && |
| 2235 | do_xmailer_test 0 "--no-xmailer" |
| 2236 | ' |
| 2237 | |
| 2238 | test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=true' ' |
| 2239 | test_config sendemail.xmailer true && |
| 2240 | do_xmailer_test 1 "" && |
| 2241 | do_xmailer_test 0 "--no-xmailer" && |
| 2242 | do_xmailer_test 1 "--xmailer" |
| 2243 | ' |
| 2244 | |
Ævar Arnfjörð Bjarmason | 879be43 | 2021-05-28 11:23:41 +0200 | [diff] [blame] | 2245 | test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer' ' |
| 2246 | test_when_finished "test_unconfig sendemail.xmailer" && |
| 2247 | cat >>.git/config <<-\EOF && |
| 2248 | [sendemail] |
| 2249 | xmailer |
| 2250 | EOF |
| 2251 | test_config sendemail.xmailer true && |
| 2252 | do_xmailer_test 1 "" && |
| 2253 | do_xmailer_test 0 "--no-xmailer" && |
| 2254 | do_xmailer_test 1 "--xmailer" |
| 2255 | ' |
| 2256 | |
Luis Henriques | 2cf770f | 2014-12-04 19:11:30 +0000 | [diff] [blame] | 2257 | test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' ' |
| 2258 | test_config sendemail.xmailer false && |
| 2259 | do_xmailer_test 0 "" && |
| 2260 | do_xmailer_test 0 "--no-xmailer" && |
| 2261 | do_xmailer_test 1 "--xmailer" |
| 2262 | ' |
| 2263 | |
Ævar Arnfjörð Bjarmason | 879be43 | 2021-05-28 11:23:41 +0200 | [diff] [blame] | 2264 | test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=' ' |
| 2265 | test_config sendemail.xmailer "" && |
| 2266 | do_xmailer_test 0 "" && |
| 2267 | do_xmailer_test 0 "--no-xmailer" && |
| 2268 | do_xmailer_test 1 "--xmailer" |
| 2269 | ' |
| 2270 | |
Remi Lespinet | b1c8a11 | 2015-06-30 14:16:50 +0200 | [diff] [blame] | 2271 | test_expect_success $PREREQ 'setup expected-list' ' |
| 2272 | git send-email \ |
| 2273 | --dry-run \ |
| 2274 | --from="Example <from@example.com>" \ |
| 2275 | --to="To 1 <to1@example.com>" \ |
| 2276 | --to="to2@example.com" \ |
| 2277 | --to="to3@example.com" \ |
| 2278 | --cc="Cc 1 <cc1@example.com>" \ |
| 2279 | --cc="Cc2 <cc2@example.com>" \ |
| 2280 | --bcc="bcc1@example.com" \ |
| 2281 | --bcc="bcc2@example.com" \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 2282 | 0001-add-main.patch | replace_variable_fields \ |
Remi Lespinet | b1c8a11 | 2015-06-30 14:16:50 +0200 | [diff] [blame] | 2283 | >expected-list |
| 2284 | ' |
| 2285 | |
| 2286 | test_expect_success $PREREQ 'use email list in --cc --to and --bcc' ' |
| 2287 | git send-email \ |
| 2288 | --dry-run \ |
| 2289 | --from="Example <from@example.com>" \ |
| 2290 | --to="To 1 <to1@example.com>, to2@example.com" \ |
| 2291 | --to="to3@example.com" \ |
| 2292 | --cc="Cc 1 <cc1@example.com>, Cc2 <cc2@example.com>" \ |
| 2293 | --bcc="bcc1@example.com, bcc2@example.com" \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 2294 | 0001-add-main.patch | replace_variable_fields \ |
Remi Lespinet | b1c8a11 | 2015-06-30 14:16:50 +0200 | [diff] [blame] | 2295 | >actual-list && |
| 2296 | test_cmp expected-list actual-list |
| 2297 | ' |
| 2298 | |
| 2299 | test_expect_success $PREREQ 'aliases work with email list' ' |
| 2300 | echo "alias to2 to2@example.com" >.mutt && |
| 2301 | echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt && |
| 2302 | test_config sendemail.aliasesfile ".mutt" && |
| 2303 | test_config sendemail.aliasfiletype mutt && |
| 2304 | git send-email \ |
| 2305 | --dry-run \ |
| 2306 | --from="Example <from@example.com>" \ |
| 2307 | --to="To 1 <to1@example.com>, to2, to3@example.com" \ |
| 2308 | --cc="cc1, Cc2 <cc2@example.com>" \ |
| 2309 | --bcc="bcc1@example.com, bcc2@example.com" \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 2310 | 0001-add-main.patch | replace_variable_fields \ |
Remi Lespinet | b1c8a11 | 2015-06-30 14:16:50 +0200 | [diff] [blame] | 2311 | >actual-list && |
| 2312 | test_cmp expected-list actual-list |
| 2313 | ' |
| 2314 | |
Remi Lespinet | fa5b1aa | 2015-06-30 14:16:51 +0200 | [diff] [blame] | 2315 | test_expect_success $PREREQ 'leading and trailing whitespaces are removed' ' |
| 2316 | echo "alias to2 to2@example.com" >.mutt && |
| 2317 | echo "alias cc1 Cc 1 <cc1@example.com>" >>.mutt && |
| 2318 | test_config sendemail.aliasesfile ".mutt" && |
| 2319 | test_config sendemail.aliasfiletype mutt && |
| 2320 | TO1=$(echo "QTo 1 <to1@example.com>" | q_to_tab) && |
| 2321 | TO2=$(echo "QZto2" | qz_to_tab_space) && |
| 2322 | CC1=$(echo "cc1" | append_cr) && |
brian m. carlson | c64368e | 2019-11-27 19:01:42 +0000 | [diff] [blame] | 2323 | BCC1=$(echo " bcc1@example.com Q" | q_to_nul) && |
Remi Lespinet | fa5b1aa | 2015-06-30 14:16:51 +0200 | [diff] [blame] | 2324 | git send-email \ |
| 2325 | --dry-run \ |
| 2326 | --from=" Example <from@example.com>" \ |
| 2327 | --to="$TO1" \ |
| 2328 | --to="$TO2" \ |
| 2329 | --to=" to3@example.com " \ |
| 2330 | --cc="$CC1" \ |
| 2331 | --cc="Cc2 <cc2@example.com>" \ |
| 2332 | --bcc="$BCC1" \ |
| 2333 | --bcc="bcc2@example.com" \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 2334 | 0001-add-main.patch | replace_variable_fields \ |
Remi Lespinet | fa5b1aa | 2015-06-30 14:16:51 +0200 | [diff] [blame] | 2335 | >actual-list && |
| 2336 | test_cmp expected-list actual-list |
| 2337 | ' |
| 2338 | |
Gregory Anders | cd5b33f | 2021-05-14 09:15:53 -0600 | [diff] [blame] | 2339 | test_expect_success $PREREQ 'test using command name with --sendmail-cmd' ' |
| 2340 | clean_fake_sendmail && |
Johannes Sixt | f6a5af0 | 2021-08-24 20:01:29 +0200 | [diff] [blame] | 2341 | PATH="$PWD:$PATH" \ |
Gregory Anders | cd5b33f | 2021-05-14 09:15:53 -0600 | [diff] [blame] | 2342 | git send-email \ |
| 2343 | --from="Example <nobody@example.com>" \ |
| 2344 | --to=nobody@example.com \ |
| 2345 | --sendmail-cmd="fake.sendmail" \ |
| 2346 | HEAD^ && |
| 2347 | test_path_is_file commandline1 |
| 2348 | ' |
| 2349 | |
| 2350 | test_expect_success $PREREQ 'test using arguments with --sendmail-cmd' ' |
| 2351 | clean_fake_sendmail && |
| 2352 | git send-email \ |
| 2353 | --from="Example <nobody@example.com>" \ |
| 2354 | --to=nobody@example.com \ |
| 2355 | --sendmail-cmd='\''"$(pwd)/fake.sendmail" -f nobody@example.com'\'' \ |
| 2356 | HEAD^ && |
| 2357 | test_path_is_file commandline1 |
| 2358 | ' |
| 2359 | |
| 2360 | test_expect_success $PREREQ 'test shell expression with --sendmail-cmd' ' |
| 2361 | clean_fake_sendmail && |
| 2362 | git send-email \ |
| 2363 | --from="Example <nobody@example.com>" \ |
| 2364 | --to=nobody@example.com \ |
| 2365 | --sendmail-cmd='\''f() { "$(pwd)/fake.sendmail" "$@"; };f'\'' \ |
| 2366 | HEAD^ && |
| 2367 | test_path_is_file commandline1 |
| 2368 | ' |
| 2369 | |
Marvin Häuser | e082113 | 2021-08-30 15:30:01 +0000 | [diff] [blame] | 2370 | test_expect_success $PREREQ 'set up in-reply-to/references patches' ' |
| 2371 | cat >has-reply.patch <<-\EOF && |
| 2372 | From: A U Thor <author@example.com> |
| 2373 | Subject: patch with in-reply-to |
| 2374 | Message-ID: <patch.with.in.reply.to@example.com> |
| 2375 | In-Reply-To: <replied.to@example.com> |
| 2376 | References: <replied.to@example.com> |
| 2377 | |
| 2378 | This is the body. |
| 2379 | EOF |
| 2380 | cat >no-reply.patch <<-\EOF |
| 2381 | From: A U Thor <author@example.com> |
| 2382 | Subject: patch without in-reply-to |
| 2383 | Message-ID: <patch.without.in.reply.to@example.com> |
| 2384 | |
| 2385 | This is the body. |
| 2386 | EOF |
| 2387 | ' |
| 2388 | |
| 2389 | test_expect_success $PREREQ 'patch reply headers correct with --no-thread' ' |
| 2390 | clean_fake_sendmail && |
| 2391 | git send-email \ |
| 2392 | --no-thread \ |
| 2393 | --to=nobody@example.com \ |
| 2394 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2395 | has-reply.patch no-reply.patch && |
| 2396 | grep "In-Reply-To: <replied.to@example.com>" msgtxt1 && |
| 2397 | grep "References: <replied.to@example.com>" msgtxt1 && |
| 2398 | ! grep replied.to@example.com msgtxt2 |
| 2399 | ' |
| 2400 | |
| 2401 | test_expect_success $PREREQ 'cmdline in-reply-to used with --no-thread' ' |
| 2402 | clean_fake_sendmail && |
| 2403 | git send-email \ |
| 2404 | --no-thread \ |
| 2405 | --in-reply-to="<cmdline.reply@example.com>" \ |
| 2406 | --to=nobody@example.com \ |
| 2407 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2408 | has-reply.patch no-reply.patch && |
| 2409 | grep "In-Reply-To: <cmdline.reply@example.com>" msgtxt1 && |
| 2410 | grep "References: <cmdline.reply@example.com>" msgtxt1 && |
| 2411 | grep "In-Reply-To: <cmdline.reply@example.com>" msgtxt2 && |
| 2412 | grep "References: <cmdline.reply@example.com>" msgtxt2 |
| 2413 | ' |
| 2414 | |
Jonathan Tan | 6489660 | 2017-05-12 15:38:26 -0700 | [diff] [blame] | 2415 | test_expect_success $PREREQ 'invoke hook' ' |
Ævar Arnfjörð Bjarmason | bef805b | 2022-03-17 11:13:14 +0100 | [diff] [blame] | 2416 | test_hook sendemail-validate <<-\EOF && |
Jonathan Tan | 6489660 | 2017-05-12 15:38:26 -0700 | [diff] [blame] | 2417 | # test that we have the correct environment variable, pwd, and |
| 2418 | # argument |
| 2419 | case "$GIT_DIR" in |
| 2420 | *.git) |
| 2421 | true |
| 2422 | ;; |
| 2423 | *) |
| 2424 | false |
| 2425 | ;; |
| 2426 | esac && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 2427 | test -f 0001-add-main.patch && |
| 2428 | grep "add main" "$1" |
Jonathan Tan | 6489660 | 2017-05-12 15:38:26 -0700 | [diff] [blame] | 2429 | EOF |
| 2430 | |
| 2431 | mkdir subdir && |
| 2432 | ( |
| 2433 | # Test that it works even if we are not at the root of the |
| 2434 | # working tree |
| 2435 | cd subdir && |
| 2436 | git send-email \ |
| 2437 | --from="Example <nobody@example.com>" \ |
| 2438 | --to=nobody@example.com \ |
| 2439 | --smtp-server="$(pwd)/../fake.sendmail" \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 2440 | ../0001-add-main.patch && |
Jonathan Tan | 6489660 | 2017-05-12 15:38:26 -0700 | [diff] [blame] | 2441 | |
| 2442 | # Verify error message when a patch is rejected by the hook |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 2443 | sed -e "s/add main/x/" ../0001-add-main.patch >../another.patch && |
Eric Sunshine | be8c48d | 2018-07-01 20:23:53 -0400 | [diff] [blame] | 2444 | test_must_fail git send-email \ |
Jonathan Tan | 6489660 | 2017-05-12 15:38:26 -0700 | [diff] [blame] | 2445 | --from="Example <nobody@example.com>" \ |
| 2446 | --to=nobody@example.com \ |
| 2447 | --smtp-server="$(pwd)/../fake.sendmail" \ |
Eric Sunshine | be8c48d | 2018-07-01 20:23:53 -0400 | [diff] [blame] | 2448 | ../another.patch 2>err && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 2449 | test_grep "rejected by sendemail-validate hook" err |
Jonathan Tan | 6489660 | 2017-05-12 15:38:26 -0700 | [diff] [blame] | 2450 | ) |
| 2451 | ' |
| 2452 | |
Robin Jarry | 3c8d3ad | 2023-04-14 17:52:49 +0200 | [diff] [blame] | 2453 | expected_file_counter_output () { |
| 2454 | total=$1 |
| 2455 | count=0 |
| 2456 | while test $count -ne $total |
| 2457 | do |
| 2458 | count=$((count + 1)) && |
| 2459 | echo "$count/$total" || return |
| 2460 | done |
| 2461 | } |
| 2462 | |
| 2463 | test_expect_success $PREREQ '--validate hook allows counting of messages' ' |
| 2464 | test_when_finished "rm -rf my-hooks.log" && |
| 2465 | test_config core.hooksPath "my-hooks" && |
| 2466 | mkdir -p my-hooks && |
| 2467 | |
| 2468 | write_script my-hooks/sendemail-validate <<-\EOF && |
| 2469 | num=$GIT_SENDEMAIL_FILE_COUNTER && |
| 2470 | tot=$GIT_SENDEMAIL_FILE_TOTAL && |
| 2471 | echo "$num/$tot" >>my-hooks.log || exit 1 |
| 2472 | EOF |
| 2473 | |
| 2474 | >my-hooks.log && |
| 2475 | expected_file_counter_output 4 >expect && |
| 2476 | git send-email \ |
| 2477 | --from="Example <from@example.com>" \ |
| 2478 | --to=nobody@example.com \ |
| 2479 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2480 | --validate -3 --cover-letter --force && |
| 2481 | test_cmp expect my-hooks.log |
| 2482 | ' |
| 2483 | |
Jonathan Tan | 177409e | 2017-06-01 16:50:55 -0700 | [diff] [blame] | 2484 | test_expect_success $PREREQ 'test that send-email works outside a repo' ' |
| 2485 | nongit git send-email \ |
| 2486 | --from="Example <nobody@example.com>" \ |
| 2487 | --to=nobody@example.com \ |
| 2488 | --smtp-server="$(pwd)/fake.sendmail" \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 2489 | "$(pwd)/0001-add-main.patch" |
Jonathan Tan | 177409e | 2017-06-01 16:50:55 -0700 | [diff] [blame] | 2490 | ' |
| 2491 | |
Kyle Meyer | 8774aa5 | 2022-11-26 15:21:23 -0500 | [diff] [blame] | 2492 | test_expect_success $PREREQ 'send-email relays -v 3 to format-patch' ' |
| 2493 | test_when_finished "rm -f out" && |
| 2494 | git send-email --dry-run -v 3 -1 >out && |
| 2495 | grep "PATCH v3" out |
| 2496 | ' |
| 2497 | |
Drew DeVault | dd84e52 | 2020-07-23 20:44:32 -0400 | [diff] [blame] | 2498 | test_expect_success $PREREQ 'test that sendmail config is rejected' ' |
| 2499 | test_config sendmail.program sendmail && |
| 2500 | test_must_fail git send-email \ |
| 2501 | --from="Example <nobody@example.com>" \ |
| 2502 | --to=nobody@example.com \ |
| 2503 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2504 | HEAD^ 2>err && |
Junio C Hamano | 6789275 | 2023-10-31 14:23:30 +0900 | [diff] [blame] | 2505 | test_grep "found configuration options for '"'"sendmail"'"'" err |
Drew DeVault | dd84e52 | 2020-07-23 20:44:32 -0400 | [diff] [blame] | 2506 | ' |
| 2507 | |
| 2508 | test_expect_success $PREREQ 'test that sendmail config rejection is specific' ' |
| 2509 | test_config resendmail.program sendmail && |
| 2510 | git send-email \ |
| 2511 | --from="Example <nobody@example.com>" \ |
| 2512 | --to=nobody@example.com \ |
| 2513 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2514 | HEAD^ |
| 2515 | ' |
| 2516 | |
| 2517 | test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' ' |
| 2518 | test_config sendmail.program sendmail && |
| 2519 | test_config sendemail.forbidSendmailVariables false && |
| 2520 | git send-email \ |
| 2521 | --from="Example <nobody@example.com>" \ |
| 2522 | --to=nobody@example.com \ |
| 2523 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2524 | HEAD^ |
| 2525 | ' |
| 2526 | |
Jeff King | 637e894 | 2023-10-20 06:13:10 -0400 | [diff] [blame] | 2527 | test_expect_success $PREREQ '--compose handles lowercase headers' ' |
| 2528 | write_script fake-editor <<-\EOF && |
| 2529 | sed "s/^From:.*/from: edited-from@example.com/i" "$1" >"$1.tmp" && |
| 2530 | mv "$1.tmp" "$1" |
| 2531 | EOF |
| 2532 | clean_fake_sendmail && |
| 2533 | git send-email \ |
| 2534 | --compose \ |
| 2535 | --from="Example <from@example.com>" \ |
| 2536 | --to=nobody@example.com \ |
| 2537 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2538 | HEAD^ && |
| 2539 | grep "From: edited-from@example.com" msgtxt1 |
| 2540 | ' |
| 2541 | |
| 2542 | test_expect_success $PREREQ '--compose handles to headers' ' |
| 2543 | write_script fake-editor <<-\EOF && |
Jeff King | 3ec6167 | 2023-10-20 06:15:24 -0400 | [diff] [blame] | 2544 | sed "s/^To: .*/&, edited-to@example.com/" <"$1" >"$1.tmp" && |
Jeff King | 637e894 | 2023-10-20 06:13:10 -0400 | [diff] [blame] | 2545 | echo this is the body >>"$1.tmp" && |
| 2546 | mv "$1.tmp" "$1" |
| 2547 | EOF |
| 2548 | clean_fake_sendmail && |
| 2549 | GIT_SEND_EMAIL_NOTTY=1 \ |
| 2550 | git send-email \ |
| 2551 | --compose \ |
| 2552 | --from="Example <from@example.com>" \ |
| 2553 | --to=nobody@example.com \ |
| 2554 | --smtp-server="$(pwd)/fake.sendmail" \ |
| 2555 | HEAD^ && |
Jeff King | 3ec6167 | 2023-10-20 06:15:24 -0400 | [diff] [blame] | 2556 | # Check both that the cover letter used our modified "to" line, |
| 2557 | # but also that it was picked up for the patch. |
| 2558 | q_to_tab >expect <<-\EOF && |
| 2559 | To: nobody@example.com, |
| 2560 | Qedited-to@example.com |
| 2561 | EOF |
| 2562 | grep -A1 "^To:" msgtxt1 >msgtxt1.to && |
| 2563 | test_cmp expect msgtxt1.to && |
| 2564 | grep -A1 "^To:" msgtxt2 >msgtxt2.to && |
| 2565 | test_cmp expect msgtxt2.to |
Jeff King | 637e894 | 2023-10-20 06:13:10 -0400 | [diff] [blame] | 2566 | ' |
| 2567 | |
Ryan Anderson | ce90301 | 2006-05-29 12:30:15 -0700 | [diff] [blame] | 2568 | test_done |