Commit | Line | Data |
---|---|---|
069a1e95 KH |
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 && | |
c7506039 | 16 | stg add a && |
069a1e95 KH |
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 && | |
08a1d356 GH |
24 | stg uncommit -n 3 && |
25 | test "$(stg id)" = "$(stg id $(stg top))" | |
069a1e95 KH |
26 | ' |
27 | ||
28 | cat > expected.txt <<EOF | |
29 | C a | |
30 | EOF | |
31 | test_expect_success 'Pop middle patch, creating a conflict' ' | |
1056440b | 32 | conflict stg pop p2 && |
069a1e95 KH |
33 | stg status a > actual.txt && |
34 | test_cmp expected.txt actual.txt && | |
08a1d356 GH |
35 | test "$(echo $(stg series))" = "+ p1 > p3 - p2" && |
36 | test "$(stg id)" = "$(stg id $(stg top))" | |
069a1e95 KH |
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 && | |
08a1d356 GH |
43 | test "$(echo $(stg series))" = "+ p1 > p3 - p2" && |
44 | test "$(stg id)" = "$(stg id $(stg top))" | |
069a1e95 KH |
45 | ' |
46 | ||
47 | cat > expected.txt <<EOF | |
48 | EOF | |
ba52890d | 49 | test_expect_success 'Try to undo with --hard' ' |
069a1e95 KH |
50 | stg undo --hard && |
51 | stg status a > actual.txt && | |
52 | test_cmp expected.txt actual.txt && | |
ba52890d | 53 | test "$(echo $(stg series))" = "+ p1 + p2 > p3" && |
08a1d356 | 54 | test "$(stg id)" = "$(stg id $(stg top))" |
069a1e95 KH |
55 | ' |
56 | ||
57 | test_done |