Disallow committing empty patches by default
[stgit.git] / t / t1303-commit.sh
bloba9637ea990662a87b8cc38914414dd08efe50934
1 #!/bin/sh
2 test_description='Test stg commit'
3 . ./test-lib.sh
5 test_expect_success 'Initialize the StGit repository' '
6 stg init &&
7 stg new -m p1 &&
8 stg new -m p2 &&
9 stg new -m p3 &&
10 stg new -m p4 &&
11 stg pop
14 test_expect_success 'Attempt to commit an empty patch' '
15 command_error stg commit p2 2>&1 | grep "Empty patch"
18 test_expect_success 'Commit middle patch' '
19 stg commit --allow-empty p2 &&
20 test "$(echo $(stg series))" = "+ p1 > p3 - p4"
23 test_expect_success 'Commit first patch' '
24 stg commit --allow-empty &&
25 test "$(echo $(stg series))" = "> p3 - p4"
28 test_expect_success 'Commit all patches' '
29 stg push &&
30 stg commit -a --allow-empty &&
31 test "$(echo $(stg series))" = ""
34 # stg commit with top != head should not succeed, since the committed
35 # patches are poptentially lost.
36 test_expect_success 'Commit when top != head (should fail)' '
37 stg new -m foo &&
38 git reset --hard HEAD^ &&
39 h=$(git rev-parse HEAD)
40 command_error stg commit --allow-empty &&
41 test "$(git rev-parse HEAD)" = "$h" &&
42 test "$(echo $(stg series))" = "> foo"
45 test_done