Merge branch 'mh/show-branch-color' into sb/show-branch-parse-options
[gitweb.git] / t / t4150-am.sh
index 722ae96cd5d320e3a8d5771e81d76165b3166b3e..d6ebbaebe2c258a4694cfb709809e13d24084231 100755 (executable)
@@ -102,7 +102,7 @@ test_expect_success 'am applies patch correctly' '
        git checkout first &&
        test_tick &&
        git am <patch1 &&
-       ! test -d .dotest &&
+       ! test -d .git/rebase-apply &&
        test -z "$(git diff second)" &&
        test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
        test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
@@ -110,7 +110,7 @@ test_expect_success 'am applies patch correctly' '
 
 GIT_AUTHOR_NAME="Another Thor"
 GIT_AUTHOR_EMAIL="a.thor@example.com"
-GIT_COMMITTER_NAME="Co M Miter" 
+GIT_COMMITTER_NAME="Co M Miter"
 GIT_COMMITTER_EMAIL="c.miter@example.com"
 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
 
@@ -123,7 +123,7 @@ test_expect_success 'am changes committer and keeps author' '
        test_tick &&
        git checkout first &&
        git am patch2 &&
-       ! test -d .dotest &&
+       ! test -d .git/rebase-apply &&
        test "$(git rev-parse master^^)" = "$(git rev-parse HEAD^^)" &&
        test -z "$(git diff master..HEAD)" &&
        test -z "$(git diff master^..HEAD^)" &&
@@ -163,9 +163,9 @@ test_expect_success 'am without --keep removes Re: and [PATCH] stuff' '
 test_expect_success 'am --keep really keeps the subject' '
        git checkout HEAD^ &&
        git am --keep patch4 &&
-       ! test -d .dotest &&
-       git-cat-file commit HEAD |
-               grep -q -F "Re: Re: Re: [PATCH 1/5 v2] third"
+       ! test -d .git/rebase-apply &&
+       git cat-file commit HEAD |
+               fgrep "Re: Re: Re: [PATCH 1/5 v2] third"
 '
 
 test_expect_success 'am -3 falls back to 3-way merge' '
@@ -176,51 +176,51 @@ test_expect_success 'am -3 falls back to 3-way merge' '
        test_tick &&
        git commit -m "copied stuff" &&
        git am -3 lorem-move.patch &&
-       ! test -d .dotest &&
+       ! test -d .git/rebase-apply &&
        test -z "$(git diff lorem)"
 '
 
 test_expect_success 'am pauses on conflict' '
        git checkout lorem2^^ &&
-       ! git am lorem-move.patch &&
-       test -d .dotest
+       test_must_fail git am lorem-move.patch &&
+       test -d .git/rebase-apply
 '
 
 test_expect_success 'am --skip works' '
        git am --skip &&
-       ! test -d .dotest &&
+       ! test -d .git/rebase-apply &&
        test -z "$(git diff lorem2^^ -- file)" &&
        test goodbye = "$(cat another)"
 '
 
 test_expect_success 'am --resolved works' '
        git checkout lorem2^^ &&
-       ! git am lorem-move.patch &&
-       test -d .dotest &&
+       test_must_fail git am lorem-move.patch &&
+       test -d .git/rebase-apply &&
        echo resolved >>file &&
        git add file &&
        git am --resolved &&
-       ! test -d .dotest &&
+       ! test -d .git/rebase-apply &&
        test goodbye = "$(cat another)"
 '
 
 test_expect_success 'am takes patches from a Pine mailbox' '
        git checkout first &&
        cat pine patch1 | git am &&
-       ! test -d .dotest &&
+       ! test -d .git/rebase-apply &&
        test -z "$(git diff master^..HEAD)"
 '
 
 test_expect_success 'am fails on mail without patch' '
-       ! git am <failmail &&
-       rm -r .dotest/
+       test_must_fail git am <failmail &&
+       rm -r .git/rebase-apply/
 '
 
 test_expect_success 'am fails on empty patch' '
        echo "---" >>failmail &&
-       ! git am <failmail &&
+       test_must_fail git am <failmail &&
        git am --skip &&
-       ! test -d .dotest
+       ! test -d .git/rebase-apply
 '
 
 test_expect_success 'am works from stdin in subdirectory' '
@@ -257,4 +257,52 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' '
        test -z "$(git diff second)"
 '
 
+test_expect_success 'am --committer-date-is-author-date' '
+       git checkout first &&
+       test_tick &&
+       git am --committer-date-is-author-date patch1 &&
+       git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
+       at=$(sed -ne "/^author /s/.*> //p" head1) &&
+       ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
+       test "$at" = "$ct"
+'
+
+test_expect_success 'am without --committer-date-is-author-date' '
+       git checkout first &&
+       test_tick &&
+       git am patch1 &&
+       git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
+       at=$(sed -ne "/^author /s/.*> //p" head1) &&
+       ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
+       test "$at" != "$ct"
+'
+
+# This checks for +0000 because TZ is set to UTC and that should
+# show up when the current time is used. The date in message is set
+# by test_tick that uses -0700 timezone; if this feature does not
+# work, we will see that instead of +0000.
+test_expect_success 'am --ignore-date' '
+       git checkout first &&
+       test_tick &&
+       git am --ignore-date patch1 &&
+       git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
+       at=$(sed -ne "/^author /s/.*> //p" head1) &&
+       echo "$at" | grep "+0000"
+'
+
+test_expect_success 'am into an unborn branch' '
+       rm -fr subdir &&
+       mkdir -p subdir &&
+       git format-patch --numbered-files -o subdir -1 first &&
+       (
+               cd subdir &&
+               git init &&
+               git am 1
+       ) &&
+       result=$(
+               cd subdir && git rev-parse HEAD^{tree}
+       ) &&
+       test "z$result" = "z$(git rev-parse first^{tree})"
+'
+
 test_done