Merge branch 'nd/status-refresh-progress'
[gitweb.git] / t / t7501-commit.sh
index 9dbbd01fc07724e378a864e3fe735269665a9bc3..f1349af56edd17483120a1e177c70282759778d3 100755 (executable)
@@ -47,7 +47,7 @@ test_expect_success 'paths and -a do not mix' '
 test_expect_success PERL 'can use paths with --interactive' '
        echo bong-o-bong >file &&
        # 2: update, 1:st path, that is all, 7: quit
-       ( echo 2; echo 1; echo; echo 7 ) |
+       test_write_lines 2 1 "" 7 |
        git commit -m foo --interactive file &&
        git reset --hard HEAD^
 '
@@ -99,12 +99,12 @@ test_expect_success '--dry-run with stuff to commit returns ok' '
        git commit -m next -a --dry-run
 '
 
-test_expect_failure '--short with stuff to commit returns ok' '
+test_expect_success '--short with stuff to commit returns ok' '
        echo bongo bongo bongo >>file &&
        git commit -m next -a --short
 '
 
-test_expect_failure '--porcelain with stuff to commit returns ok' '
+test_expect_success '--porcelain with stuff to commit returns ok' '
        echo bongo bongo bongo >>file &&
        git commit -m next -a --porcelain
 '
@@ -293,7 +293,7 @@ test_expect_success PERL 'interactive add' '
 test_expect_success PERL "commit --interactive doesn't change index if editor aborts" '
        echo zoo >file &&
        test_must_fail git diff --exit-code >diff1 &&
-       (echo u ; echo "*" ; echo q) |
+       test_write_lines u "*" q |
        (
                EDITOR=: &&
                export EDITOR &&
@@ -411,8 +411,8 @@ test_expect_success 'sign off (1)' '
        git commit -s -m "thank you" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
        (
-               echo thank you
-               echo
+               echo thank you &&
+               echo &&
                git var GIT_COMMITTER_IDENT |
                sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
        ) >expected &&
@@ -430,9 +430,9 @@ test_expect_success 'sign off (2)' '
 $existing" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
        (
-               echo thank you
-               echo
-               echo $existing
+               echo thank you &&
+               echo &&
+               echo $existing &&
                git var GIT_COMMITTER_IDENT |
                sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
        ) >expected &&
@@ -450,9 +450,9 @@ test_expect_success 'signoff gap' '
 $alt" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
        (
-               echo welcome
-               echo
-               echo $alt
+               echo welcome &&
+               echo &&
+               echo $alt &&
                git var GIT_COMMITTER_IDENT |
                sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
        ) >expected &&
@@ -470,11 +470,11 @@ We have now
 $alt" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
        (
-               echo welcome
-               echo
-               echo We have now
-               echo $alt
-               echo
+               echo welcome &&
+               echo &&
+               echo We have now &&
+               echo $alt &&
+               echo &&
                git var GIT_COMMITTER_IDENT |
                sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
        ) >expected &&
@@ -491,11 +491,11 @@ non-trailer line
 Myfooter: x" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
        (
-               echo subject
-               echo
-               echo non-trailer line
-               echo Myfooter: x
-               echo
+               echo subject &&
+               echo &&
+               echo non-trailer line &&
+               echo Myfooter: x &&
+               echo &&
                echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
        ) >expected &&
        test_cmp expected actual &&
@@ -508,15 +508,31 @@ non-trailer line
 Myfooter: x" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
        (
-               echo subject
-               echo
-               echo non-trailer line
-               echo Myfooter: x
+               echo subject &&
+               echo &&
+               echo non-trailer line &&
+               echo Myfooter: x &&
                echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
        ) >expected &&
        test_cmp expected actual
 '
 
+test_expect_success 'signoff not confused by ---' '
+       cat >expected <<-EOF &&
+               subject
+
+               body
+               ---
+               these dashes confuse the parser!
+
+               Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+       EOF
+       # should be a noop, since we already signed
+       git commit --allow-empty --signoff -F expected &&
+       git log -1 --pretty=format:%B >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'multiple -m' '
 
        >negative &&
@@ -524,10 +540,10 @@ test_expect_success 'multiple -m' '
        git commit -m "one" -m "two" -m "three" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
        (
-               echo one
-               echo
-               echo two
-               echo
+               echo one &&
+               echo &&
+               echo two &&
+               echo &&
                echo three
        ) >expected &&
        test_cmp expected actual
@@ -582,13 +598,11 @@ test_expect_success 'same tree (merge and amend merge)' '
 
        git merge -s ours side -m "empty ok" &&
        git diff HEAD^ HEAD >actual &&
-       : >expected &&
-       test_cmp expected actual &&
+       test_must_be_empty actual &&
 
        git commit --amend -m "empty really ok" &&
        git diff HEAD^ HEAD >actual &&
-       : >expected &&
-       test_cmp expected actual
+       test_must_be_empty actual
 
 '
 
@@ -677,11 +691,17 @@ test_expect_success '--dry-run with conflicts fixed from a merge' '
        git checkout -b branch-2 HEAD^1 &&
        echo "commit-2-state" >test-file &&
        git commit -m "commit 2" -i test-file &&
-       ! $(git merge --no-commit commit-1) &&
+       test_must_fail git merge --no-commit commit-1 &&
        echo "commit-2-state" >test-file &&
        git add test-file &&
        git commit --dry-run &&
        git commit -m "conflicts fixed from merge."
 '
 
+test_expect_success '--dry-run --short' '
+       >test-file &&
+       git add test-file &&
+       git commit --dry-run --short
+'
+
 test_done