t / t9001-send-email.shon commit gitweb: Incremental blame (using JavaScript) (4af819d)
   1#!/bin/sh
   2
   3test_description='git send-email'
   4. ./test-lib.sh
   5
   6if ! test_have_prereq PERL; then
   7        say 'skipping git send-email tests, perl not available'
   8        test_done
   9fi
  10
  11PROG='git send-email'
  12test_expect_success \
  13    'prepare reference tree' \
  14    'echo "1A quick brown fox jumps over the" >file &&
  15     echo "lazy dog" >>file &&
  16     git add file &&
  17     GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
  18
  19test_expect_success \
  20    'Setup helper tool' \
  21    '(echo "#!$SHELL_PATH"
  22      echo shift
  23      echo output=1
  24      echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
  25      echo for a
  26      echo do
  27      echo "  echo \"!\$a!\""
  28      echo "done >commandline\$output"
  29      echo "cat > msgtxt\$output"
  30      ) >fake.sendmail &&
  31     chmod +x ./fake.sendmail &&
  32     git add fake.sendmail &&
  33     GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
  34
  35clean_fake_sendmail() {
  36        rm -f commandline* msgtxt*
  37}
  38
  39test_expect_success 'Extract patches' '
  40    patches=`git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
  41'
  42
  43# Test no confirm early to ensure remaining tests will not hang
  44test_no_confirm () {
  45        rm -f no_confirm_okay
  46        echo n | \
  47                GIT_SEND_EMAIL_NOTTY=1 \
  48                git send-email \
  49                --from="Example <from@example.com>" \
  50                --to=nobody@example.com \
  51                --smtp-server="$(pwd)/fake.sendmail" \
  52                $@ \
  53                $patches > stdout &&
  54                test_must_fail grep "Send this email" stdout &&
  55                > no_confirm_okay
  56}
  57
  58# Exit immediately to prevent hang if a no-confirm test fails
  59check_no_confirm () {
  60        test -f no_confirm_okay || {
  61                say 'No confirm test failed; skipping remaining tests to prevent hanging'
  62                test_done
  63        }
  64}
  65
  66test_expect_success 'No confirm with --suppress-cc' '
  67        test_no_confirm --suppress-cc=sob
  68'
  69check_no_confirm
  70
  71test_expect_success 'No confirm with --confirm=never' '
  72        test_no_confirm --confirm=never
  73'
  74check_no_confirm
  75
  76# leave sendemail.confirm set to never after this so that none of the
  77# remaining tests prompt unintentionally.
  78test_expect_success 'No confirm with sendemail.confirm=never' '
  79        git config sendemail.confirm never &&
  80        test_no_confirm --compose --subject=foo
  81'
  82check_no_confirm
  83
  84test_expect_success 'Send patches' '
  85     git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
  86'
  87
  88cat >expected <<\EOF
  89!nobody@example.com!
  90!author@example.com!
  91!one@example.com!
  92!two@example.com!
  93EOF
  94test_expect_success \
  95    'Verify commandline' \
  96    'test_cmp expected commandline1'
  97
  98cat >expected-show-all-headers <<\EOF
  990001-Second.patch
 100(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
 101(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
 102(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
 103Dry-OK. Log says:
 104Server: relay.example.com
 105MAIL FROM:<from@example.com>
 106RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com>
 107From: Example <from@example.com>
 108To: to@example.com
 109Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
 110Subject: [PATCH 1/1] Second.
 111Date: DATE-STRING
 112Message-Id: MESSAGE-ID-STRING
 113X-Mailer: X-MAILER-STRING
 114In-Reply-To: <unique-message-id@example.com>
 115References: <unique-message-id@example.com>
 116
 117Result: OK
 118EOF
 119
 120test_expect_success 'Show all headers' '
 121        git send-email \
 122                --dry-run \
 123                --suppress-cc=sob \
 124                --from="Example <from@example.com>" \
 125                --to=to@example.com \
 126                --cc=cc@example.com \
 127                --bcc=bcc@example.com \
 128                --in-reply-to="<unique-message-id@example.com>" \
 129                --smtp-server relay.example.com \
 130                $patches |
 131        sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
 132                -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
 133                -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
 134                >actual-show-all-headers &&
 135        test_cmp expected-show-all-headers actual-show-all-headers
 136'
 137
 138test_expect_success 'Prompting works' '
 139        clean_fake_sendmail &&
 140        (echo "Example <from@example.com>"
 141         echo "to@example.com"
 142         echo ""
 143        ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
 144                --smtp-server="$(pwd)/fake.sendmail" \
 145                $patches \
 146                2>errors &&
 147                grep "^From: Example <from@example.com>$" msgtxt1 &&
 148                grep "^To: to@example.com$" msgtxt1
 149'
 150
 151test_expect_success 'cccmd works' '
 152        clean_fake_sendmail &&
 153        cp $patches cccmd.patch &&
 154        echo cccmd--cccmd@example.com >>cccmd.patch &&
 155        {
 156          echo "#!$SHELL_PATH"
 157          echo sed -n -e s/^cccmd--//p \"\$1\"
 158        } > cccmd-sed &&
 159        chmod +x cccmd-sed &&
 160        git send-email \
 161                --from="Example <nobody@example.com>" \
 162                --to=nobody@example.com \
 163                --cc-cmd=./cccmd-sed \
 164                --smtp-server="$(pwd)/fake.sendmail" \
 165                cccmd.patch \
 166                &&
 167        grep ^Cc:.*cccmd@example.com msgtxt1
 168'
 169
 170z8=zzzzzzzz
 171z64=$z8$z8$z8$z8$z8$z8$z8$z8
 172z512=$z64$z64$z64$z64$z64$z64$z64$z64
 173test_expect_success 'reject long lines' '
 174        clean_fake_sendmail &&
 175        cp $patches longline.patch &&
 176        echo $z512$z512 >>longline.patch &&
 177        test_must_fail git send-email \
 178                --from="Example <nobody@example.com>" \
 179                --to=nobody@example.com \
 180                --smtp-server="$(pwd)/fake.sendmail" \
 181                $patches longline.patch \
 182                2>errors &&
 183        grep longline.patch errors
 184'
 185
 186test_expect_success 'no patch was sent' '
 187        ! test -e commandline1
 188'
 189
 190test_expect_success 'Author From: in message body' '
 191        clean_fake_sendmail &&
 192        git send-email \
 193                --from="Example <nobody@example.com>" \
 194                --to=nobody@example.com \
 195                --smtp-server="$(pwd)/fake.sendmail" \
 196                $patches &&
 197        sed "1,/^$/d" < msgtxt1 > msgbody1
 198        grep "From: A <author@example.com>" msgbody1
 199'
 200
 201test_expect_success 'Author From: not in message body' '
 202        clean_fake_sendmail &&
 203        git send-email \
 204                --from="A <author@example.com>" \
 205                --to=nobody@example.com \
 206                --smtp-server="$(pwd)/fake.sendmail" \
 207                $patches &&
 208        sed "1,/^$/d" < msgtxt1 > msgbody1
 209        ! grep "From: A <author@example.com>" msgbody1
 210'
 211
 212test_expect_success 'allow long lines with --no-validate' '
 213        git send-email \
 214                --from="Example <nobody@example.com>" \
 215                --to=nobody@example.com \
 216                --smtp-server="$(pwd)/fake.sendmail" \
 217                --novalidate \
 218                $patches longline.patch \
 219                2>errors
 220'
 221
 222test_expect_success 'Invalid In-Reply-To' '
 223        clean_fake_sendmail &&
 224        git send-email \
 225                --from="Example <nobody@example.com>" \
 226                --to=nobody@example.com \
 227                --in-reply-to=" " \
 228                --smtp-server="$(pwd)/fake.sendmail" \
 229                $patches
 230                2>errors
 231        ! grep "^In-Reply-To: < *>" msgtxt1
 232'
 233
 234test_expect_success 'Valid In-Reply-To when prompting' '
 235        clean_fake_sendmail &&
 236        (echo "From Example <from@example.com>"
 237         echo "To Example <to@example.com>"
 238         echo ""
 239        ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
 240                --smtp-server="$(pwd)/fake.sendmail" \
 241                $patches 2>errors &&
 242        ! grep "^In-Reply-To: < *>" msgtxt1
 243'
 244
 245test_expect_success 'setup fake editor' '
 246        (echo "#!$SHELL_PATH" &&
 247         echo "echo fake edit >>\"\$1\""
 248        ) >fake-editor &&
 249        chmod +x fake-editor
 250'
 251
 252test_set_editor "$(pwd)/fake-editor"
 253
 254test_expect_success '--compose works' '
 255        clean_fake_sendmail &&
 256        git send-email \
 257        --compose --subject foo \
 258        --from="Example <nobody@example.com>" \
 259        --to=nobody@example.com \
 260        --smtp-server="$(pwd)/fake.sendmail" \
 261        $patches \
 262        2>errors
 263'
 264
 265test_expect_success 'first message is compose text' '
 266        grep "^fake edit" msgtxt1
 267'
 268
 269test_expect_success 'second message is patch' '
 270        grep "Subject:.*Second" msgtxt2
 271'
 272
 273cat >expected-suppress-sob <<\EOF
 2740001-Second.patch
 275(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
 276(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
 277(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
 278Dry-OK. Log says:
 279Server: relay.example.com
 280MAIL FROM:<from@example.com>
 281RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
 282From: Example <from@example.com>
 283To: to@example.com
 284Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com
 285Subject: [PATCH 1/1] Second.
 286Date: DATE-STRING
 287Message-Id: MESSAGE-ID-STRING
 288X-Mailer: X-MAILER-STRING
 289
 290Result: OK
 291EOF
 292
 293test_suppression () {
 294        git send-email \
 295                --dry-run \
 296                --suppress-cc=$1 ${2+"--suppress-cc=$2"} \
 297                --from="Example <from@example.com>" \
 298                --to=to@example.com \
 299                --smtp-server relay.example.com \
 300                $patches |
 301        sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
 302                -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
 303                -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
 304                >actual-suppress-$1${2+"-$2"} &&
 305        test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
 306}
 307
 308test_expect_success 'sendemail.cc set' '
 309        git config sendemail.cc cc@example.com &&
 310        test_suppression sob
 311'
 312
 313cat >expected-suppress-sob <<\EOF
 3140001-Second.patch
 315(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
 316(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
 317(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
 318Dry-OK. Log says:
 319Server: relay.example.com
 320MAIL FROM:<from@example.com>
 321RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
 322From: Example <from@example.com>
 323To: to@example.com
 324Cc: A <author@example.com>, One <one@example.com>, two@example.com
 325Subject: [PATCH 1/1] Second.
 326Date: DATE-STRING
 327Message-Id: MESSAGE-ID-STRING
 328X-Mailer: X-MAILER-STRING
 329
 330Result: OK
 331EOF
 332
 333test_expect_success 'sendemail.cc unset' '
 334        git config --unset sendemail.cc &&
 335        test_suppression sob
 336'
 337
 338cat >expected-suppress-cccmd <<\EOF
 3390001-Second.patch
 340(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
 341(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
 342(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
 343(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
 344Dry-OK. Log says:
 345Server: relay.example.com
 346MAIL FROM:<from@example.com>
 347RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
 348From: Example <from@example.com>
 349To: to@example.com
 350Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
 351Subject: [PATCH 1/1] Second.
 352Date: DATE-STRING
 353Message-Id: MESSAGE-ID-STRING
 354X-Mailer: X-MAILER-STRING
 355
 356Result: OK
 357EOF
 358
 359test_expect_success 'sendemail.cccmd' '
 360        echo echo cc-cmd@example.com > cccmd &&
 361        chmod +x cccmd &&
 362        git config sendemail.cccmd ./cccmd &&
 363        test_suppression cccmd
 364'
 365
 366cat >expected-suppress-all <<\EOF
 3670001-Second.patch
 368Dry-OK. Log says:
 369Server: relay.example.com
 370MAIL FROM:<from@example.com>
 371RCPT TO:<to@example.com>
 372From: Example <from@example.com>
 373To: to@example.com
 374Subject: [PATCH 1/1] Second.
 375Date: DATE-STRING
 376Message-Id: MESSAGE-ID-STRING
 377X-Mailer: X-MAILER-STRING
 378
 379Result: OK
 380EOF
 381
 382test_expect_success '--suppress-cc=all' '
 383        test_suppression all
 384'
 385
 386cat >expected-suppress-body <<\EOF
 3870001-Second.patch
 388(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
 389(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
 390(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
 391(cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
 392Dry-OK. Log says:
 393Server: relay.example.com
 394MAIL FROM:<from@example.com>
 395RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com>
 396From: Example <from@example.com>
 397To: to@example.com
 398Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com
 399Subject: [PATCH 1/1] Second.
 400Date: DATE-STRING
 401Message-Id: MESSAGE-ID-STRING
 402X-Mailer: X-MAILER-STRING
 403
 404Result: OK
 405EOF
 406
 407test_expect_success '--suppress-cc=body' '
 408        test_suppression body
 409'
 410
 411cat >expected-suppress-body-cccmd <<\EOF
 4120001-Second.patch
 413(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
 414(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
 415(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
 416Dry-OK. Log says:
 417Server: relay.example.com
 418MAIL FROM:<from@example.com>
 419RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
 420From: Example <from@example.com>
 421To: to@example.com
 422Cc: A <author@example.com>, One <one@example.com>, two@example.com
 423Subject: [PATCH 1/1] Second.
 424Date: DATE-STRING
 425Message-Id: MESSAGE-ID-STRING
 426X-Mailer: X-MAILER-STRING
 427
 428Result: OK
 429EOF
 430
 431test_expect_success '--suppress-cc=body --suppress-cc=cccmd' '
 432        test_suppression body cccmd
 433'
 434
 435cat >expected-suppress-sob <<\EOF
 4360001-Second.patch
 437(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
 438(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
 439(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
 440Dry-OK. Log says:
 441Server: relay.example.com
 442MAIL FROM:<from@example.com>
 443RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
 444From: Example <from@example.com>
 445To: to@example.com
 446Cc: A <author@example.com>, One <one@example.com>, two@example.com
 447Subject: [PATCH 1/1] Second.
 448Date: DATE-STRING
 449Message-Id: MESSAGE-ID-STRING
 450X-Mailer: X-MAILER-STRING
 451
 452Result: OK
 453EOF
 454
 455test_expect_success '--suppress-cc=sob' '
 456        git config --unset sendemail.cccmd
 457        test_suppression sob
 458'
 459
 460cat >expected-suppress-bodycc <<\EOF
 4610001-Second.patch
 462(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
 463(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
 464(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
 465(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
 466Dry-OK. Log says:
 467Server: relay.example.com
 468MAIL FROM:<from@example.com>
 469RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
 470From: Example <from@example.com>
 471To: to@example.com
 472Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
 473Subject: [PATCH 1/1] Second.
 474Date: DATE-STRING
 475Message-Id: MESSAGE-ID-STRING
 476X-Mailer: X-MAILER-STRING
 477
 478Result: OK
 479EOF
 480
 481test_expect_success '--suppress-cc=bodycc' '
 482        test_suppression bodycc
 483'
 484
 485cat >expected-suppress-cc <<\EOF
 4860001-Second.patch
 487(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
 488(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
 489Dry-OK. Log says:
 490Server: relay.example.com
 491MAIL FROM:<from@example.com>
 492RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com>
 493From: Example <from@example.com>
 494To: to@example.com
 495Cc: A <author@example.com>, C O Mitter <committer@example.com>
 496Subject: [PATCH 1/1] Second.
 497Date: DATE-STRING
 498Message-Id: MESSAGE-ID-STRING
 499X-Mailer: X-MAILER-STRING
 500
 501Result: OK
 502EOF
 503
 504test_expect_success '--suppress-cc=cc' '
 505        test_suppression cc
 506'
 507
 508test_confirm () {
 509        echo y | \
 510                GIT_SEND_EMAIL_NOTTY=1 \
 511                git send-email \
 512                --from="Example <nobody@example.com>" \
 513                --to=nobody@example.com \
 514                --smtp-server="$(pwd)/fake.sendmail" \
 515                $@ $patches > stdout &&
 516        grep "Send this email" stdout
 517}
 518
 519test_expect_success '--confirm=always' '
 520        test_confirm --confirm=always --suppress-cc=all
 521'
 522
 523test_expect_success '--confirm=auto' '
 524        test_confirm --confirm=auto
 525'
 526
 527test_expect_success '--confirm=cc' '
 528        test_confirm --confirm=cc
 529'
 530
 531test_expect_success '--confirm=compose' '
 532        test_confirm --confirm=compose --compose
 533'
 534
 535test_expect_success 'confirm by default (due to cc)' '
 536        CONFIRM=$(git config --get sendemail.confirm) &&
 537        git config --unset sendemail.confirm &&
 538        test_confirm
 539        ret="$?"
 540        git config sendemail.confirm ${CONFIRM:-never}
 541        test $ret = "0"
 542'
 543
 544test_expect_success 'confirm by default (due to --compose)' '
 545        CONFIRM=$(git config --get sendemail.confirm) &&
 546        git config --unset sendemail.confirm &&
 547        test_confirm --suppress-cc=all --compose
 548        ret="$?"
 549        git config sendemail.confirm ${CONFIRM:-never}
 550        test $ret = "0"
 551'
 552
 553test_expect_success 'confirm detects EOF (inform assumes y)' '
 554        CONFIRM=$(git config --get sendemail.confirm) &&
 555        git config --unset sendemail.confirm &&
 556        rm -fr outdir &&
 557        git format-patch -2 -o outdir &&
 558        GIT_SEND_EMAIL_NOTTY=1 \
 559                git send-email \
 560                        --from="Example <nobody@example.com>" \
 561                        --to=nobody@example.com \
 562                        --smtp-server="$(pwd)/fake.sendmail" \
 563                        outdir/*.patch < /dev/null
 564        ret="$?"
 565        git config sendemail.confirm ${CONFIRM:-never}
 566        test $ret = "0"
 567'
 568
 569test_expect_success 'confirm detects EOF (auto causes failure)' '
 570        CONFIRM=$(git config --get sendemail.confirm) &&
 571        git config sendemail.confirm auto &&
 572        GIT_SEND_EMAIL_NOTTY=1 &&
 573        export GIT_SEND_EMAIL_NOTTY &&
 574                test_must_fail git send-email \
 575                        --from="Example <nobody@example.com>" \
 576                        --to=nobody@example.com \
 577                        --smtp-server="$(pwd)/fake.sendmail" \
 578                        $patches < /dev/null
 579        ret="$?"
 580        git config sendemail.confirm ${CONFIRM:-never}
 581        test $ret = "0"
 582'
 583
 584test_expect_success 'confirm doesnt loop forever' '
 585        CONFIRM=$(git config --get sendemail.confirm) &&
 586        git config sendemail.confirm auto &&
 587        GIT_SEND_EMAIL_NOTTY=1 &&
 588        export GIT_SEND_EMAIL_NOTTY &&
 589                yes "bogus" | test_must_fail git send-email \
 590                        --from="Example <nobody@example.com>" \
 591                        --to=nobody@example.com \
 592                        --smtp-server="$(pwd)/fake.sendmail" \
 593                        $patches
 594        ret="$?"
 595        git config sendemail.confirm ${CONFIRM:-never}
 596        test $ret = "0"
 597'
 598
 599test_expect_success 'utf8 Cc is rfc2047 encoded' '
 600        clean_fake_sendmail &&
 601        rm -fr outdir &&
 602        git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
 603        git send-email \
 604        --from="Example <nobody@example.com>" \
 605        --to=nobody@example.com \
 606        --smtp-server="$(pwd)/fake.sendmail" \
 607        outdir/*.patch &&
 608        grep "^Cc:" msgtxt1 |
 609        grep "=?UTF-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
 610'
 611
 612test_expect_success '--compose adds MIME for utf8 body' '
 613        clean_fake_sendmail &&
 614        (echo "#!$SHELL_PATH" &&
 615         echo "echo utf8 body: àéìöú >>\"\$1\""
 616        ) >fake-editor-utf8 &&
 617        chmod +x fake-editor-utf8 &&
 618          GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
 619          git send-email \
 620          --compose --subject foo \
 621          --from="Example <nobody@example.com>" \
 622          --to=nobody@example.com \
 623          --smtp-server="$(pwd)/fake.sendmail" \
 624          $patches &&
 625        grep "^utf8 body" msgtxt1 &&
 626        grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
 627'
 628
 629test_expect_success '--compose respects user mime type' '
 630        clean_fake_sendmail &&
 631        (echo "#!$SHELL_PATH" &&
 632         echo "(echo MIME-Version: 1.0"
 633         echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
 634         echo " echo Content-Transfer-Encoding: 8bit"
 635         echo " echo Subject: foo"
 636         echo " echo "
 637         echo " echo utf8 body: àéìöú) >\"\$1\""
 638        ) >fake-editor-utf8-mime &&
 639        chmod +x fake-editor-utf8-mime &&
 640          GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
 641          git send-email \
 642          --compose --subject foo \
 643          --from="Example <nobody@example.com>" \
 644          --to=nobody@example.com \
 645          --smtp-server="$(pwd)/fake.sendmail" \
 646          $patches &&
 647        grep "^utf8 body" msgtxt1 &&
 648        grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
 649        ! grep "^Content-Type: text/plain; charset=UTF-8" msgtxt1
 650'
 651
 652test_expect_success '--compose adds MIME for utf8 subject' '
 653        clean_fake_sendmail &&
 654          GIT_EDITOR="\"$(pwd)/fake-editor\"" \
 655          git send-email \
 656          --compose --subject utf8-sübjëct \
 657          --from="Example <nobody@example.com>" \
 658          --to=nobody@example.com \
 659          --smtp-server="$(pwd)/fake.sendmail" \
 660          $patches &&
 661        grep "^fake edit" msgtxt1 &&
 662        grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
 663'
 664
 665test_expect_success 'detects ambiguous reference/file conflict' '
 666        echo master > master &&
 667        git add master &&
 668        git commit -m"add master" &&
 669        test_must_fail git send-email --dry-run master 2>errors &&
 670        grep disambiguate errors
 671'
 672
 673test_expect_success 'feed two files' '
 674        rm -fr outdir &&
 675        git format-patch -2 -o outdir &&
 676        git send-email \
 677        --dry-run \
 678        --from="Example <nobody@example.com>" \
 679        --to=nobody@example.com \
 680        outdir/000?-*.patch 2>errors >out &&
 681        grep "^Subject: " out >subjects &&
 682        test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
 683        test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
 684'
 685
 686test_expect_success 'in-reply-to but no threading' '
 687        git send-email \
 688                --dry-run \
 689                --from="Example <nobody@example.com>" \
 690                --to=nobody@example.com \
 691                --in-reply-to="<in-reply-id@example.com>" \
 692                --nothread \
 693                $patches |
 694        grep "In-Reply-To: <in-reply-id@example.com>"
 695'
 696
 697test_expect_success 'no in-reply-to and no threading' '
 698        git send-email \
 699                --dry-run \
 700                --from="Example <nobody@example.com>" \
 701                --to=nobody@example.com \
 702                --nothread \
 703                $patches $patches >stdout &&
 704        ! grep "In-Reply-To: " stdout
 705'
 706
 707test_expect_success 'threading but no chain-reply-to' '
 708        git send-email \
 709                --dry-run \
 710                --from="Example <nobody@example.com>" \
 711                --to=nobody@example.com \
 712                --thread \
 713                --nochain-reply-to \
 714                $patches $patches >stdout &&
 715        grep "In-Reply-To: " stdout
 716'
 717
 718test_done