summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTay Ray Chuan <rctay89@gmail.com>2014-02-22 03:16:54 +0800
committerJunio C Hamano <gitster@pobox.com>2014-02-24 09:16:53 -0800
commit9cbcc2a7ca5b09ff57b52b7f6e422228f6cfd451 (patch)
tree9e222f23a65644a855e1225a72deee2e05d6d7e6
parent5f95c9f850b19b368c43ae399cc831b17a26a5ac (diff)
downloadgit-tc/commit-dry-run-exit-status-tests.tar.gz
demonstrate git-commit --dry-run exit code behaviourtc/commit-dry-run-exit-status-tests
In particular, show that --short and --porcelain, while implying --dry-run, do not return the same exit code as --dry-run. This is due to the wt_status.commitable flag being set only when a long status is requested. No fix is provided here; with [1], it should be trivial to fix though - just a matter of calling wt_status_mark_commitable(). [1] http://article.gmane.org/gmane.comp.version-control.git/242489 Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/t7501-commit.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 94eec83b37..d58b097ff3 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -61,11 +61,47 @@ test_expect_success 'nothing to commit' '
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