demonstrate git-commit --dry-run exit code behaviour
[gitweb.git] / t / t7501-commit.sh
index f04798f87232fbbf705dd8a24300a76a2a6e435a..d58b097ff3b3d0e6e68d15491d38f1f32460f6e7 100755 (executable)
@@ -57,14 +57,51 @@ test_expect_success 'using invalid commit with -C' '
 '
 
 test_expect_success 'nothing to commit' '
+       git reset --hard &&
        test_must_fail git commit -m initial
 '
 
+test_expect_success '--dry-run fails with nothing to commit' '
+       test_must_fail git commit -m initial --dry-run
+'
+
+test_expect_success '--short fails with nothing to commit' '
+       test_must_fail git commit -m initial --short
+'
+
+test_expect_success '--porcelain fails with nothing to commit' '
+       test_must_fail git commit -m initial --porcelain
+'
+
+test_expect_success '--long fails with nothing to commit' '
+       test_must_fail git commit -m initial --long
+'
+
 test_expect_success 'setup: non-initial commit' '
        echo bongo bongo bongo >file &&
        git commit -m next -a
 '
 
+test_expect_success '--dry-run with stuff to commit returns ok' '
+       echo bongo bongo bongo >>file &&
+       git commit -m next -a --dry-run
+'
+
+test_expect_failure '--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' '
+       echo bongo bongo bongo >>file &&
+       git commit -m next -a --porcelain
+'
+
+test_expect_success '--long with stuff to commit returns ok' '
+       echo bongo bongo bongo >>file &&
+       git commit -m next -a --long
+'
+
 test_expect_success 'commit message from non-existing file' '
        echo more bongo: bongo bongo bongo bongo >file &&
        test_must_fail git commit -F gah -a