3 test_description
='Simple test cases for "stg redo"'
7 # Ignore our own output files.
8 cat >> .git
/info
/exclude
<<EOF
12 test_expect_success
'Initialize StGit stack with three patches' '
18 git commit -a -m p1 &&
20 git commit -a -m p2 &&
22 git commit -a -m p3 &&
26 test_expect_success
'Invalid number of patches to redo' '
27 command_error stg redo -n0 2>&1 |
28 grep -e "Bad number of undos to redo"
31 cat > expected.txt
<<EOF
36 test_expect_success
'Pop one patch ...' '
38 test "$(echo $(stg series))" = "+ p1 > p2 - p3" &&
39 test_cmp expected.txt a
42 cat > expected.txt
<<EOF
48 test_expect_success
'... undo it ...' '
50 test "$(echo $(stg series))" = "+ p1 + p2 > p3" &&
51 test_cmp expected.txt a
54 cat > expected.txt
<<EOF
59 test_expect_success
'... and redo' '
61 test "$(echo $(stg series))" = "+ p1 > p2 - p3" &&
62 test_cmp expected.txt a
65 cat > expected.txt
<<EOF
68 test_expect_success
'Pop three patches ...' '
73 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
74 test_cmp expected.txt a
77 cat > expected.txt
<<EOF
83 test_expect_success
'... undo it ...' '
87 test "$(echo $(stg series))" = "+ p1 + p2 > p3" &&
88 test_cmp expected.txt a
91 cat > expected.txt
<<EOF
95 test_expect_success
'... redo the first two pops ...' '
97 test "$(echo $(stg series))" = "> p1 - p2 - p3" &&
98 test_cmp expected.txt a
101 cat > expected.txt
<<EOF
104 test_expect_success
'... and the remaining one' '
106 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
107 test_cmp expected.txt a
110 cat > expected.txt
<<EOF
113 test_expect_success
'Redo past end of history' '
114 command_error stg redo &&
115 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
116 test_cmp expected.txt a