Remove the assert in CommitData.parse() function
[stgit] / t / t3103-undo-hard.sh
1 #!/bin/sh
2
3 test_description='Simple test cases for "stg undo"'
4
5 . ./test-lib.sh
6
7 # Ignore our own output files.
8 cat > .git/info/exclude <<EOF
9 /expected.txt
10 /actual.txt
11 EOF
12
13 test_expect_success 'Initialize StGit stack with three patches' '
14 stg init &&
15 echo 000 >> a &&
16 stg add a &&
17 git commit -m a &&
18 echo 111 >> a &&
19 git commit -a -m p1 &&
20 echo 222 >> a &&
21 git commit -a -m p2 &&
22 echo 333 >> a &&
23 git commit -a -m p3 &&
24 stg uncommit -n 3 &&
25 test "$(stg id)" = "$(stg id $(stg top))"
26 '
27
28 cat > expected.txt <<EOF
29 C a
30 EOF
31 test_expect_success 'Pop middle patch, creating a conflict' '
32 conflict stg pop p2 &&
33 stg status a > actual.txt &&
34 test_cmp expected.txt actual.txt &&
35 test "$(echo $(stg series))" = "+ p1 > p3 - p2" &&
36 test "$(stg id)" = "$(stg id $(stg top))"
37 '
38
39 test_expect_success 'Try to undo without --hard' '
40 command_error stg undo &&
41 stg status a > actual.txt &&
42 test_cmp expected.txt actual.txt &&
43 test "$(echo $(stg series))" = "+ p1 > p3 - p2" &&
44 test "$(stg id)" = "$(stg id $(stg top))"
45 '
46
47 cat > expected.txt <<EOF
48 EOF
49 test_expect_success 'Try to undo with --hard' '
50 stg undo --hard &&
51 stg status a > actual.txt &&
52 test_cmp expected.txt actual.txt &&
53 test "$(echo $(stg series))" = "+ p1 + p2 > p3" &&
54 test "$(stg id)" = "$(stg id $(stg top))"
55 '
56
57 test_done