t / t4150-am.shon commit t4150: am with applypatch-msg hook (f26bdf2)
   1#!/bin/sh
   2
   3test_description='git am running'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup: messages' '
   8        cat >msg <<-\EOF &&
   9        second
  10
  11        Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy
  12        eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
  13        voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
  14        kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
  15        ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
  16        tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
  17        vero eos et accusam et justo duo dolores et ea rebum.
  18
  19        EOF
  20        qz_to_tab_space <<-\EOF >>msg &&
  21        QDuis autem vel eum iriure dolor in hendrerit in vulputate velit
  22        Qesse molestie consequat, vel illum dolore eu feugiat nulla facilisis
  23        Qat vero eros et accumsan et iusto odio dignissim qui blandit
  24        Qpraesent luptatum zzril delenit augue duis dolore te feugait nulla
  25        Qfacilisi.
  26        EOF
  27        cat >>msg <<-\EOF &&
  28
  29        Lorem ipsum dolor sit amet,
  30        consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
  31        laoreet dolore magna aliquam erat volutpat.
  32
  33          git
  34          ---
  35          +++
  36
  37        Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
  38        lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure
  39        dolor in hendrerit in vulputate velit esse molestie consequat, vel illum
  40        dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
  41        dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te
  42        feugait nulla facilisi.
  43        EOF
  44
  45        cat >failmail <<-\EOF &&
  46        From foo@example.com Fri May 23 10:43:49 2008
  47        From:   foo@example.com
  48        To:     bar@example.com
  49        Subject: Re: [RFC/PATCH] git-foo.sh
  50        Date:   Fri, 23 May 2008 05:23:42 +0200
  51
  52        Sometimes we have to find out that there'\''s nothing left.
  53
  54        EOF
  55
  56        cat >pine <<-\EOF &&
  57        From MAILER-DAEMON Fri May 23 10:43:49 2008
  58        Date: 23 May 2008 05:23:42 +0200
  59        From: Mail System Internal Data <MAILER-DAEMON@example.com>
  60        Subject: DON'\''T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA
  61        Message-ID: <foo-0001@example.com>
  62
  63        This text is part of the internal format of your mail folder, and is not
  64        a real message.  It is created automatically by the mail system software.
  65        If deleted, important folder data will be lost, and it will be re-created
  66        with the data reset to initial values.
  67
  68        EOF
  69
  70        signoff="Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
  71'
  72
  73test_expect_success setup '
  74        echo hello >file &&
  75        git add file &&
  76        test_tick &&
  77        git commit -m first &&
  78        git tag first &&
  79
  80        echo world >>file &&
  81        git add file &&
  82        test_tick &&
  83        git commit -s -F msg &&
  84        git tag second &&
  85
  86        git format-patch --stdout first >patch1 &&
  87        {
  88                echo "Message-Id: <1226501681-24923-1-git-send-email-bda@mnsspb.ru>" &&
  89                echo "X-Fake-Field: Line One" &&
  90                echo "X-Fake-Field: Line Two" &&
  91                echo "X-Fake-Field: Line Three" &&
  92                git format-patch --stdout first | sed -e "1d"
  93        } > patch1.eml &&
  94        {
  95                echo "X-Fake-Field: Line One" &&
  96                echo "X-Fake-Field: Line Two" &&
  97                echo "X-Fake-Field: Line Three" &&
  98                git format-patch --stdout first | sed -e "1d"
  99        } | append_cr >patch1-crlf.eml &&
 100        {
 101                printf "%255s\\n" ""
 102                echo "X-Fake-Field: Line One" &&
 103                echo "X-Fake-Field: Line Two" &&
 104                echo "X-Fake-Field: Line Three" &&
 105                git format-patch --stdout first | sed -e "1d"
 106        } > patch1-ws.eml &&
 107
 108        sed -n -e "3,\$p" msg >file &&
 109        git add file &&
 110        test_tick &&
 111        git commit -m third &&
 112
 113        git format-patch --stdout first >patch2 &&
 114
 115        git checkout -b lorem &&
 116        sed -n -e "11,\$p" msg >file &&
 117        head -n 9 msg >>file &&
 118        test_tick &&
 119        git commit -a -m "moved stuff" &&
 120
 121        echo goodbye >another &&
 122        git add another &&
 123        test_tick &&
 124        git commit -m "added another file" &&
 125
 126        git format-patch --stdout master >lorem-move.patch &&
 127        git format-patch --no-prefix --stdout master >lorem-zero.patch &&
 128
 129        git checkout -b rename &&
 130        git mv file renamed &&
 131        git commit -m "renamed a file" &&
 132
 133        git format-patch -M --stdout lorem >rename.patch &&
 134
 135        git reset --soft lorem^ &&
 136        git commit -m "renamed a file and added another" &&
 137
 138        git format-patch -M --stdout lorem^ >rename-add.patch &&
 139
 140        # reset time
 141        sane_unset test_tick &&
 142        test_tick
 143'
 144
 145test_expect_success 'am applies patch correctly' '
 146        rm -fr .git/rebase-apply &&
 147        git reset --hard &&
 148        git checkout first &&
 149        test_tick &&
 150        git am <patch1 &&
 151        test_path_is_missing .git/rebase-apply &&
 152        git diff --exit-code second &&
 153        test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
 154        test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
 155'
 156
 157test_expect_success 'am fails if index is dirty' '
 158        test_when_finished "rm -f dirtyfile" &&
 159        rm -fr .git/rebase-apply &&
 160        git reset --hard &&
 161        git checkout first &&
 162        echo dirtyfile >dirtyfile &&
 163        git add dirtyfile &&
 164        test_must_fail git am patch1 &&
 165        test_path_is_dir .git/rebase-apply &&
 166        test_cmp_rev first HEAD
 167'
 168
 169test_expect_success 'am applies patch e-mail not in a mbox' '
 170        rm -fr .git/rebase-apply &&
 171        git reset --hard &&
 172        git checkout first &&
 173        git am patch1.eml &&
 174        test_path_is_missing .git/rebase-apply &&
 175        git diff --exit-code second &&
 176        test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
 177        test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
 178'
 179
 180test_expect_success 'am applies patch e-mail not in a mbox with CRLF' '
 181        rm -fr .git/rebase-apply &&
 182        git reset --hard &&
 183        git checkout first &&
 184        git am patch1-crlf.eml &&
 185        test_path_is_missing .git/rebase-apply &&
 186        git diff --exit-code second &&
 187        test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
 188        test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
 189'
 190
 191test_expect_success 'am applies patch e-mail with preceding whitespace' '
 192        rm -fr .git/rebase-apply &&
 193        git reset --hard &&
 194        git checkout first &&
 195        git am patch1-ws.eml &&
 196        test_path_is_missing .git/rebase-apply &&
 197        git diff --exit-code second &&
 198        test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
 199        test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
 200'
 201
 202test_expect_success 'am with applypatch-msg hook' '
 203        test_when_finished "rm -f .git/hooks/applypatch-msg" &&
 204        rm -fr .git/rebase-apply &&
 205        git reset --hard &&
 206        git checkout first &&
 207        mkdir -p .git/hooks &&
 208        write_script .git/hooks/applypatch-msg <<-\EOF &&
 209        cat "$1" >actual-msg &&
 210        echo hook-message >"$1"
 211        EOF
 212        git am patch1 &&
 213        test_path_is_missing .git/rebase-apply &&
 214        git diff --exit-code second &&
 215        echo hook-message >expected &&
 216        git log -1 --format=format:%B >actual &&
 217        test_cmp expected actual &&
 218        git log -1 --format=format:%B second >expected &&
 219        test_cmp expected actual-msg
 220'
 221
 222test_expect_success 'am with failing applypatch-msg hook' '
 223        test_when_finished "rm -f .git/hooks/applypatch-msg" &&
 224        rm -fr .git/rebase-apply &&
 225        git reset --hard &&
 226        git checkout first &&
 227        mkdir -p .git/hooks &&
 228        write_script .git/hooks/applypatch-msg <<-\EOF &&
 229        exit 1
 230        EOF
 231        test_must_fail git am patch1 &&
 232        test_path_is_dir .git/rebase-apply &&
 233        git diff --exit-code first &&
 234        test_cmp_rev first HEAD
 235'
 236
 237test_expect_success 'setup: new author and committer' '
 238        GIT_AUTHOR_NAME="Another Thor" &&
 239        GIT_AUTHOR_EMAIL="a.thor@example.com" &&
 240        GIT_COMMITTER_NAME="Co M Miter" &&
 241        GIT_COMMITTER_EMAIL="c.miter@example.com" &&
 242        export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
 243'
 244
 245compare () {
 246        a=$(git cat-file commit "$2" | grep "^$1 ") &&
 247        b=$(git cat-file commit "$3" | grep "^$1 ") &&
 248        test "$a" = "$b"
 249}
 250
 251test_expect_success 'am changes committer and keeps author' '
 252        test_tick &&
 253        rm -fr .git/rebase-apply &&
 254        git reset --hard &&
 255        git checkout first &&
 256        git am patch2 &&
 257        test_path_is_missing .git/rebase-apply &&
 258        test "$(git rev-parse master^^)" = "$(git rev-parse HEAD^^)" &&
 259        git diff --exit-code master..HEAD &&
 260        git diff --exit-code master^..HEAD^ &&
 261        compare author master HEAD &&
 262        compare author master^ HEAD^ &&
 263        test "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" = \
 264             "$(git log -1 --pretty=format:"%cn <%ce>" HEAD)"
 265'
 266
 267test_expect_success 'am --signoff adds Signed-off-by: line' '
 268        rm -fr .git/rebase-apply &&
 269        git reset --hard &&
 270        git checkout -b master2 first &&
 271        git am --signoff <patch2 &&
 272        printf "%s\n" "$signoff" >expected &&
 273        echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >>expected &&
 274        git cat-file commit HEAD^ | grep "Signed-off-by:" >actual &&
 275        test_cmp expected actual &&
 276        echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
 277        git cat-file commit HEAD | grep "Signed-off-by:" >actual &&
 278        test_cmp expected actual
 279'
 280
 281test_expect_success 'am stays in branch' '
 282        echo refs/heads/master2 >expected &&
 283        git symbolic-ref HEAD >actual &&
 284        test_cmp expected actual
 285'
 286
 287test_expect_success 'am --signoff does not add Signed-off-by: line if already there' '
 288        git format-patch --stdout HEAD^ >patch3 &&
 289        sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2] [foo," patch3 >patch4 &&
 290        rm -fr .git/rebase-apply &&
 291        git reset --hard &&
 292        git checkout HEAD^ &&
 293        git am --signoff patch4 &&
 294        git cat-file commit HEAD >actual &&
 295        test $(grep -c "^Signed-off-by:" actual) -eq 1
 296'
 297
 298test_expect_success 'am without --keep removes Re: and [PATCH] stuff' '
 299        git rev-parse HEAD >expected &&
 300        git rev-parse master2 >actual &&
 301        test_cmp expected actual
 302'
 303
 304test_expect_success 'am --keep really keeps the subject' '
 305        rm -fr .git/rebase-apply &&
 306        git reset --hard &&
 307        git checkout HEAD^ &&
 308        git am --keep patch4 &&
 309        test_path_is_missing .git/rebase-apply &&
 310        git cat-file commit HEAD >actual &&
 311        grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual
 312'
 313
 314test_expect_success 'am --keep-non-patch really keeps the non-patch part' '
 315        rm -fr .git/rebase-apply &&
 316        git reset --hard &&
 317        git checkout HEAD^ &&
 318        git am --keep-non-patch patch4 &&
 319        test_path_is_missing .git/rebase-apply &&
 320        git cat-file commit HEAD >actual &&
 321        grep "^\[foo\] third" actual
 322'
 323
 324test_expect_success 'setup am -3' '
 325        rm -fr .git/rebase-apply &&
 326        git reset --hard &&
 327        git checkout -b base3way master2 &&
 328        sed -n -e "3,\$p" msg >file &&
 329        head -n 9 msg >>file &&
 330        git add file &&
 331        test_tick &&
 332        git commit -m "copied stuff"
 333'
 334
 335test_expect_success 'am -3 falls back to 3-way merge' '
 336        rm -fr .git/rebase-apply &&
 337        git reset --hard &&
 338        git checkout -b lorem2 base3way &&
 339        git am -3 lorem-move.patch &&
 340        test_path_is_missing .git/rebase-apply &&
 341        git diff --exit-code lorem
 342'
 343
 344test_expect_success 'am -3 -p0 can read --no-prefix patch' '
 345        rm -fr .git/rebase-apply &&
 346        git reset --hard &&
 347        git checkout -b lorem3 base3way &&
 348        git am -3 -p0 lorem-zero.patch &&
 349        test_path_is_missing .git/rebase-apply &&
 350        git diff --exit-code lorem
 351'
 352
 353test_expect_success 'am with config am.threeWay falls back to 3-way merge' '
 354        rm -fr .git/rebase-apply &&
 355        git reset --hard &&
 356        git checkout -b lorem4 base3way &&
 357        test_config am.threeWay 1 &&
 358        git am lorem-move.patch &&
 359        test_path_is_missing .git/rebase-apply &&
 360        git diff --exit-code lorem
 361'
 362
 363test_expect_success 'am with config am.threeWay overridden by --no-3way' '
 364        rm -fr .git/rebase-apply &&
 365        git reset --hard &&
 366        git checkout -b lorem5 base3way &&
 367        test_config am.threeWay 1 &&
 368        test_must_fail git am --no-3way lorem-move.patch &&
 369        test_path_is_dir .git/rebase-apply
 370'
 371
 372test_expect_success 'am can rename a file' '
 373        grep "^rename from" rename.patch &&
 374        rm -fr .git/rebase-apply &&
 375        git reset --hard &&
 376        git checkout lorem^0 &&
 377        git am rename.patch &&
 378        test_path_is_missing .git/rebase-apply &&
 379        git update-index --refresh &&
 380        git diff --exit-code rename
 381'
 382
 383test_expect_success 'am -3 can rename a file' '
 384        grep "^rename from" rename.patch &&
 385        rm -fr .git/rebase-apply &&
 386        git reset --hard &&
 387        git checkout lorem^0 &&
 388        git am -3 rename.patch &&
 389        test_path_is_missing .git/rebase-apply &&
 390        git update-index --refresh &&
 391        git diff --exit-code rename
 392'
 393
 394test_expect_success 'am -3 can rename a file after falling back to 3-way merge' '
 395        grep "^rename from" rename-add.patch &&
 396        rm -fr .git/rebase-apply &&
 397        git reset --hard &&
 398        git checkout lorem^0 &&
 399        git am -3 rename-add.patch &&
 400        test_path_is_missing .git/rebase-apply &&
 401        git update-index --refresh &&
 402        git diff --exit-code rename
 403'
 404
 405test_expect_success 'am -3 -q is quiet' '
 406        rm -fr .git/rebase-apply &&
 407        git checkout -f lorem2 &&
 408        git reset base3way --hard &&
 409        git am -3 -q lorem-move.patch >output.out 2>&1 &&
 410        ! test -s output.out
 411'
 412
 413test_expect_success 'am pauses on conflict' '
 414        rm -fr .git/rebase-apply &&
 415        git reset --hard &&
 416        git checkout lorem2^^ &&
 417        test_must_fail git am lorem-move.patch &&
 418        test -d .git/rebase-apply
 419'
 420
 421test_expect_success 'am --skip works' '
 422        echo goodbye >expected &&
 423        git am --skip &&
 424        test_path_is_missing .git/rebase-apply &&
 425        git diff --exit-code lorem2^^ -- file &&
 426        test_cmp expected another
 427'
 428
 429test_expect_success 'am --abort removes a stray directory' '
 430        mkdir .git/rebase-apply &&
 431        git am --abort &&
 432        test_path_is_missing .git/rebase-apply
 433'
 434
 435test_expect_success 'am refuses patches when paused' '
 436        rm -fr .git/rebase-apply &&
 437        git reset --hard &&
 438        git checkout lorem2^^ &&
 439
 440        test_must_fail git am lorem-move.patch &&
 441        test_path_is_dir .git/rebase-apply &&
 442        test_cmp_rev lorem2^^ HEAD &&
 443
 444        test_must_fail git am <lorem-move.patch &&
 445        test_path_is_dir .git/rebase-apply &&
 446        test_cmp_rev lorem2^^ HEAD
 447'
 448
 449test_expect_success 'am --resolved works' '
 450        echo goodbye >expected &&
 451        rm -fr .git/rebase-apply &&
 452        git reset --hard &&
 453        git checkout lorem2^^ &&
 454        test_must_fail git am lorem-move.patch &&
 455        test -d .git/rebase-apply &&
 456        echo resolved >>file &&
 457        git add file &&
 458        git am --resolved &&
 459        test_path_is_missing .git/rebase-apply &&
 460        test_cmp expected another
 461'
 462
 463test_expect_success 'am --resolved fails if index has no changes' '
 464        rm -fr .git/rebase-apply &&
 465        git reset --hard &&
 466        git checkout lorem2^^ &&
 467        test_must_fail git am lorem-move.patch &&
 468        test_path_is_dir .git/rebase-apply &&
 469        test_cmp_rev lorem2^^ HEAD &&
 470        test_must_fail git am --resolved &&
 471        test_path_is_dir .git/rebase-apply &&
 472        test_cmp_rev lorem2^^ HEAD
 473'
 474
 475test_expect_success 'am --resolved fails if index has unmerged entries' '
 476        rm -fr .git/rebase-apply &&
 477        git reset --hard &&
 478        git checkout second &&
 479        test_must_fail git am -3 lorem-move.patch &&
 480        test_path_is_dir .git/rebase-apply &&
 481        test_cmp_rev second HEAD &&
 482        test_must_fail git am --resolved >err &&
 483        test_path_is_dir .git/rebase-apply &&
 484        test_cmp_rev second HEAD &&
 485        test_i18ngrep "still have unmerged paths" err
 486'
 487
 488test_expect_success 'am takes patches from a Pine mailbox' '
 489        rm -fr .git/rebase-apply &&
 490        git reset --hard &&
 491        git checkout first &&
 492        cat pine patch1 | git am &&
 493        test_path_is_missing .git/rebase-apply &&
 494        git diff --exit-code master^..HEAD
 495'
 496
 497test_expect_success 'am fails on mail without patch' '
 498        rm -fr .git/rebase-apply &&
 499        git reset --hard &&
 500        test_must_fail git am <failmail &&
 501        git am --abort &&
 502        test_path_is_missing .git/rebase-apply
 503'
 504
 505test_expect_success 'am fails on empty patch' '
 506        rm -fr .git/rebase-apply &&
 507        git reset --hard &&
 508        echo "---" >>failmail &&
 509        test_must_fail git am <failmail &&
 510        git am --skip &&
 511        test_path_is_missing .git/rebase-apply
 512'
 513
 514test_expect_success 'am works from stdin in subdirectory' '
 515        rm -fr subdir &&
 516        rm -fr .git/rebase-apply &&
 517        git reset --hard &&
 518        git checkout first &&
 519        (
 520                mkdir -p subdir &&
 521                cd subdir &&
 522                git am <../patch1
 523        ) &&
 524        git diff --exit-code second
 525'
 526
 527test_expect_success 'am works from file (relative path given) in subdirectory' '
 528        rm -fr subdir &&
 529        rm -fr .git/rebase-apply &&
 530        git reset --hard &&
 531        git checkout first &&
 532        (
 533                mkdir -p subdir &&
 534                cd subdir &&
 535                git am ../patch1
 536        ) &&
 537        git diff --exit-code second
 538'
 539
 540test_expect_success 'am works from file (absolute path given) in subdirectory' '
 541        rm -fr subdir &&
 542        rm -fr .git/rebase-apply &&
 543        git reset --hard &&
 544        git checkout first &&
 545        P=$(pwd) &&
 546        (
 547                mkdir -p subdir &&
 548                cd subdir &&
 549                git am "$P/patch1"
 550        ) &&
 551        git diff --exit-code second
 552'
 553
 554test_expect_success 'am --committer-date-is-author-date' '
 555        rm -fr .git/rebase-apply &&
 556        git reset --hard &&
 557        git checkout first &&
 558        test_tick &&
 559        git am --committer-date-is-author-date patch1 &&
 560        git cat-file commit HEAD | sed -e "/^\$/q" >head1 &&
 561        sed -ne "/^author /s/.*> //p" head1 >at &&
 562        sed -ne "/^committer /s/.*> //p" head1 >ct &&
 563        test_cmp at ct
 564'
 565
 566test_expect_success 'am without --committer-date-is-author-date' '
 567        rm -fr .git/rebase-apply &&
 568        git reset --hard &&
 569        git checkout first &&
 570        test_tick &&
 571        git am patch1 &&
 572        git cat-file commit HEAD | sed -e "/^\$/q" >head1 &&
 573        sed -ne "/^author /s/.*> //p" head1 >at &&
 574        sed -ne "/^committer /s/.*> //p" head1 >ct &&
 575        ! test_cmp at ct
 576'
 577
 578# This checks for +0000 because TZ is set to UTC and that should
 579# show up when the current time is used. The date in message is set
 580# by test_tick that uses -0700 timezone; if this feature does not
 581# work, we will see that instead of +0000.
 582test_expect_success 'am --ignore-date' '
 583        rm -fr .git/rebase-apply &&
 584        git reset --hard &&
 585        git checkout first &&
 586        test_tick &&
 587        git am --ignore-date patch1 &&
 588        git cat-file commit HEAD | sed -e "/^\$/q" >head1 &&
 589        sed -ne "/^author /s/.*> //p" head1 >at &&
 590        grep "+0000" at
 591'
 592
 593test_expect_success 'am into an unborn branch' '
 594        git rev-parse first^{tree} >expected &&
 595        rm -fr .git/rebase-apply &&
 596        git reset --hard &&
 597        rm -fr subdir &&
 598        mkdir subdir &&
 599        git format-patch --numbered-files -o subdir -1 first &&
 600        (
 601                cd subdir &&
 602                git init &&
 603                git am 1
 604        ) &&
 605        (
 606                cd subdir &&
 607                git rev-parse HEAD^{tree} >../actual
 608        ) &&
 609        test_cmp expected actual
 610'
 611
 612test_expect_success 'am newline in subject' '
 613        rm -fr .git/rebase-apply &&
 614        git reset --hard &&
 615        git checkout first &&
 616        test_tick &&
 617        sed -e "s/second/second \\\n foo/" patch1 >patchnl &&
 618        git am <patchnl >output.out 2>&1 &&
 619        test_i18ngrep "^Applying: second \\\n foo$" output.out
 620'
 621
 622test_expect_success 'am -q is quiet' '
 623        rm -fr .git/rebase-apply &&
 624        git reset --hard &&
 625        git checkout first &&
 626        test_tick &&
 627        git am -q <patch1 >output.out 2>&1 &&
 628        ! test -s output.out
 629'
 630
 631test_expect_success 'am empty-file does not infloop' '
 632        rm -fr .git/rebase-apply &&
 633        git reset --hard &&
 634        touch empty-file &&
 635        test_tick &&
 636        test_must_fail git am empty-file 2>actual &&
 637        echo Patch format detection failed. >expected &&
 638        test_i18ncmp expected actual
 639'
 640
 641test_expect_success 'am --message-id really adds the message id' '
 642        rm -fr .git/rebase-apply &&
 643        git reset --hard &&
 644        git checkout HEAD^ &&
 645        git am --message-id patch1.eml &&
 646        test_path_is_missing .git/rebase-apply &&
 647        git cat-file commit HEAD | tail -n1 >actual &&
 648        grep Message-Id patch1.eml >expected &&
 649        test_cmp expected actual
 650'
 651
 652test_expect_success 'am.messageid really adds the message id' '
 653        rm -fr .git/rebase-apply &&
 654        git reset --hard &&
 655        git checkout HEAD^ &&
 656        test_config am.messageid true &&
 657        git am patch1.eml &&
 658        test_path_is_missing .git/rebase-apply &&
 659        git cat-file commit HEAD | tail -n1 >actual &&
 660        grep Message-Id patch1.eml >expected &&
 661        test_cmp expected actual
 662'
 663
 664test_expect_success 'am --message-id -s signs off after the message id' '
 665        rm -fr .git/rebase-apply &&
 666        git reset --hard &&
 667        git checkout HEAD^ &&
 668        git am -s --message-id patch1.eml &&
 669        test_path_is_missing .git/rebase-apply &&
 670        git cat-file commit HEAD | tail -n2 | head -n1 >actual &&
 671        grep Message-Id patch1.eml >expected &&
 672        test_cmp expected actual
 673'
 674
 675test_done