From: Stephan Beyer Date: Sat, 31 May 2008 22:11:43 +0000 (+0200) Subject: Merge t4150-am-subdir.sh and t4151-am.sh into t4150-am.sh X-Git-Tag: v1.5.6-rc1~6^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8ec00d0534c28763ed07533920daa47baca0d6a6;p=git.git Merge t4150-am-subdir.sh and t4151-am.sh into t4150-am.sh This patch moves the am test cases in t4150-am.sh and the am subdirectory test cases from t/t4150-am-subdir.sh into t/4151-am.sh. Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- diff --git a/t/t4150-am-subdir.sh b/t/t4150-am-subdir.sh deleted file mode 100755 index 52069b469..000000000 --- a/t/t4150-am-subdir.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh - -test_description='git am running from a subdirectory' - -. ./test-lib.sh - -test_expect_success setup ' - echo hello >world && - git add world && - test_tick && - git commit -m initial && - git tag initial && - echo goodbye >world && - git add world && - test_tick && - git commit -m second && - git format-patch --stdout HEAD^ >patchfile && - : >expect -' - -test_expect_success 'am regularly from stdin' ' - git checkout initial && - git am actual && - test_cmp expect actual -' - -test_expect_success 'am regularly from file' ' - git checkout initial && - git am patchfile && - git diff master >actual && - test_cmp expect actual -' - -test_expect_success 'am regularly from stdin in subdirectory' ' - rm -fr subdir && - git checkout initial && - ( - mkdir -p subdir && - cd subdir && - git am <../patchfile - ) && - git diff master>actual && - test_cmp expect actual -' - -test_expect_success 'am regularly from file in subdirectory' ' - rm -fr subdir && - git checkout initial && - ( - mkdir -p subdir && - cd subdir && - git am ../patchfile - ) && - git diff master >actual && - test_cmp expect actual -' - -test_expect_success 'am regularly from file in subdirectory with full path' ' - rm -fr subdir && - git checkout initial && - P=$(pwd) && - ( - mkdir -p subdir && - cd subdir && - git am "$P/patchfile" - ) && - git diff master >actual && - test_cmp expect actual -' - -test_done diff --git a/t/t4150-am.sh b/t/t4150-am.sh new file mode 100755 index 000000000..722ae96cd --- /dev/null +++ b/t/t4150-am.sh @@ -0,0 +1,260 @@ +#!/bin/sh + +test_description='git am running' + +. ./test-lib.sh + +cat >msg <failmail <pine < +Subject: DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA +Message-ID: + +This text is part of the internal format of your mail folder, and is not +a real message. It is created automatically by the mail system software. +If deleted, important folder data will be lost, and it will be re-created +with the data reset to initial values. + +EOF + +echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected + +test_expect_success setup ' + echo hello >file && + git add file && + test_tick && + git commit -m first && + git tag first && + echo world >>file && + git add file && + test_tick && + git commit -s -F msg && + git tag second && + git format-patch --stdout first >patch1 && + sed -n -e "3,\$p" msg >file && + git add file && + test_tick && + git commit -m third && + git format-patch --stdout first >patch2 && + git checkout -b lorem && + sed -n -e "11,\$p" msg >file && + head -n 9 msg >>file && + test_tick && + git commit -a -m "moved stuff" && + echo goodbye >another && + git add another && + test_tick && + git commit -m "added another file" && + git format-patch --stdout master >lorem-move.patch +' + +# reset time +unset test_tick +test_tick + +test_expect_success 'am applies patch correctly' ' + git checkout first && + test_tick && + git am " = \ + "$(git log -1 --pretty=format:"%cn <%ce>" HEAD)" +' + +test_expect_success 'am --signoff adds Signed-off-by: line' ' + git checkout -b master2 first && + git am --signoff " >>expected && + git cat-file commit HEAD^ | grep "Signed-off-by:" >actual && + test_cmp actual expected && + echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected && + git cat-file commit HEAD | grep "Signed-off-by:" >actual && + test_cmp actual expected +' + +test_expect_success 'am stays in branch' ' + test "refs/heads/master2" = "$(git symbolic-ref HEAD)" +' + +test_expect_success 'am --signoff does not add Signed-off-by: line if already there' ' + git format-patch --stdout HEAD^ >patch3 && + sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2," patch3 >patch4 + git checkout HEAD^ && + git am --signoff patch4 && + test "$(git cat-file commit HEAD | grep -c "^Signed-off-by:")" -eq 1 +' + +test_expect_success 'am without --keep removes Re: and [PATCH] stuff' ' + test "$(git rev-parse HEAD)" = "$(git rev-parse master2)" +' + +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_expect_success 'am -3 falls back to 3-way merge' ' + git checkout -b lorem2 master2 && + sed -n -e "3,\$p" msg >file && + head -n 9 msg >>file && + git add file && + test_tick && + git commit -m "copied stuff" && + git am -3 lorem-move.patch && + ! test -d .dotest && + test -z "$(git diff lorem)" +' + +test_expect_success 'am pauses on conflict' ' + git checkout lorem2^^ && + ! git am lorem-move.patch && + test -d .dotest +' + +test_expect_success 'am --skip works' ' + git am --skip && + ! test -d .dotest && + 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 && + echo resolved >>file && + git add file && + git am --resolved && + ! test -d .dotest && + 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 -z "$(git diff master^..HEAD)" +' + +test_expect_success 'am fails on mail without patch' ' + ! git am >failmail && + ! git am msg <failmail <pine < -Subject: DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA -Message-ID: - -This text is part of the internal format of your mail folder, and is not -a real message. It is created automatically by the mail system software. -If deleted, important folder data will be lost, and it will be re-created -with the data reset to initial values. - -EOF - -echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected - -test_expect_success setup ' - echo hello >file && - git add file && - test_tick && - git commit -m first && - git tag first && - echo world >>file && - git add file && - test_tick && - git commit -s -F msg && - git tag second && - git format-patch --stdout first >patch1 && - sed -n -e "3,\$p" msg >file && - git add file && - test_tick && - git commit -m third && - git format-patch --stdout first >patch2 && - git checkout -b lorem && - sed -n -e "11,\$p" msg >file && - head -n 9 msg >>file && - test_tick && - git commit -a -m "moved stuff" && - echo goodbye >another && - git add another && - test_tick && - git commit -m "added another file" && - git format-patch --stdout master >lorem-move.patch -' - -# reset time -unset test_tick -test_tick - -test_expect_success 'am applies patch correctly' ' - git checkout first && - test_tick && - git am " = \ - "$(git log -1 --pretty=format:"%cn <%ce>" HEAD)" -' - -test_expect_success 'am --signoff adds Signed-off-by: line' ' - git checkout -b master2 first && - git am --signoff " >>expected && - git cat-file commit HEAD^ | grep "Signed-off-by:" >actual && - test_cmp actual expected && - echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected && - git cat-file commit HEAD | grep "Signed-off-by:" >actual && - test_cmp actual expected -' - -test_expect_success 'am stays in branch' ' - test "refs/heads/master2" = "$(git symbolic-ref HEAD)" -' - -test_expect_success 'am --signoff does not add Signed-off-by: line if already there' ' - git format-patch --stdout HEAD^ >patch3 && - sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2," patch3 >patch4 - git checkout HEAD^ && - git am --signoff patch4 && - test "$(git cat-file commit HEAD | grep -c "^Signed-off-by:")" -eq 1 -' - -test_expect_success 'am without --keep removes Re: and [PATCH] stuff' ' - test "$(git rev-parse HEAD)" = "$(git rev-parse master2)" -' - -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_expect_success 'am -3 falls back to 3-way merge' ' - git checkout -b lorem2 master2 && - sed -n -e "3,\$p" msg >file && - head -n 9 msg >>file && - git add file && - test_tick && - git commit -m "copied stuff" && - git am -3 lorem-move.patch && - ! test -d .dotest && - test -z "$(git diff lorem)" -' - -test_expect_success 'am pauses on conflict' ' - git checkout lorem2^^ && - ! git am lorem-move.patch && - test -d .dotest -' - -test_expect_success 'am --skip works' ' - git am --skip && - ! test -d .dotest && - 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 && - echo resolved >>file && - git add file && - git am --resolved && - ! test -d .dotest && - 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 -z "$(git diff master^..HEAD)" -' - -test_expect_success 'am fails on mail without patch' ' - ! git am >failmail && - ! git am