Preserve picked patch name when possible
[stgit.git] / t / t1303-commit.sh
blob4738abfbed88c7aedda2edf3874c4b880c48eb69
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>err &&
16 grep "Empty patch" err
19 test_expect_success 'Commit middle patch' '
20 stg commit --allow-empty p2 &&
21 test "$(echo $(stg series))" = "+ p1 > p3 - p4"
24 test_expect_success 'Commit first patch' '
25 stg commit --allow-empty &&
26 test "$(echo $(stg series))" = "> p3 - p4"
29 test_expect_success 'Commit all patches' '
30 stg push &&
31 stg commit -a --allow-empty &&
32 test "$(echo $(stg series))" = ""
35 # stg commit with top != head should not succeed, since the committed
36 # patches are poptentially lost.
37 test_expect_success 'Commit when top != head (should fail)' '
38 stg new -m foo &&
39 git reset --hard HEAD^ &&
40 h=$(git rev-parse HEAD)
41 command_error stg commit --allow-empty &&
42 test "$(git rev-parse HEAD)" = "$h" &&
43 test "$(echo $(stg series))" = "> foo"
46 test_done