chiark / gitweb /
stgit.el: Add "d" for a few diff commands, similar to git.el
[stgit] / t / t3104-redo.sh
CommitLineData
121c14e5
KH
1#!/bin/sh
2
3test_description='Simple test cases for "stg redo"'
4
5. ./test-lib.sh
6
7# Ignore our own output files.
8cat > .git/info/exclude <<EOF
9/expected.txt
10EOF
11
12test_expect_success 'Initialize StGit stack with three patches' '
13 stg init &&
14 echo 000 >> a &&
15 git add a &&
16 git commit -m a &&
17 echo 111 >> a &&
18 git commit -a -m p1 &&
19 echo 222 >> a &&
20 git commit -a -m p2 &&
21 echo 333 >> a &&
22 git commit -a -m p3 &&
23 stg uncommit -n 3
24'
25
26cat > expected.txt <<EOF
27000
28111
29222
30EOF
31test_expect_success 'Pop one patch ...' '
32 stg pop &&
33 test "$(echo $(stg series))" = "+ p1 > p2 - p3" &&
34 test_cmp expected.txt a
35'
36
37cat > expected.txt <<EOF
38000
39111
40222
41333
42EOF
43test_expect_success '... undo it ...' '
44 stg undo &&
45 test "$(echo $(stg series))" = "+ p1 + p2 > p3" &&
46 test_cmp expected.txt a
47'
48
49cat > expected.txt <<EOF
50000
51111
52222
53EOF
54test_expect_success '... and redo' '
55 stg redo &&
56 test "$(echo $(stg series))" = "+ p1 > p2 - p3" &&
57 test_cmp expected.txt a
58'
59
60cat > expected.txt <<EOF
61000
62EOF
63test_expect_success 'Pop three patches ...' '
64 stg push &&
65 stg pop &&
66 stg pop &&
67 stg pop &&
68 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
69 test_cmp expected.txt a
70'
71
72cat > expected.txt <<EOF
73000
74111
75222
76333
77EOF
78test_expect_success '... undo it ...' '
79 stg undo &&
80 stg undo &&
81 stg undo &&
82 test "$(echo $(stg series))" = "+ p1 + p2 > p3" &&
83 test_cmp expected.txt a
84'
85
86cat > expected.txt <<EOF
87000
88111
89EOF
90test_expect_success '... redo the first two pops ...' '
91 stg redo -n 2 &&
92 test "$(echo $(stg series))" = "> p1 - p2 - p3" &&
93 test_cmp expected.txt a
94'
95
96cat > expected.txt <<EOF
97000
98EOF
99test_expect_success '... and the remaining one' '
100 stg redo &&
101 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
102 test_cmp expected.txt a
103'
104
105cat > expected.txt <<EOF
106000
107EOF
108test_expect_success 'Redo past end of history' '
109 command_error stg redo &&
110 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
111 test_cmp expected.txt a
112'
113
114test_done