chiark / gitweb /
stgit.el: Add "d" for a few diff commands, similar to git.el
[stgit] / t / t3100-reset.sh
CommitLineData
3a3a4f2f
KH
1#!/bin/sh
2
3test_description='Simple test cases for "stg reset"'
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 stg pop
25'
26
27cat > expected.txt <<EOF
28000
29111
30EOF
31test_expect_success 'Pop one patch ...' '
32 stg pop &&
33 test "$(echo $(stg series --all))" = "> p1 - p2 - p3" &&
34 test_cmp expected.txt a
35'
36
37cat > expected.txt <<EOF
38000
39111
40222
41EOF
42test_expect_success '... and undo it' '
43 stg reset master.stgit^~1 &&
44 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3" &&
45 test_cmp expected.txt a
46'
47
48cat > expected.txt <<EOF
49000
50111
51222
52333
53EOF
54test_expect_success 'Push one patch ...' '
55 stg push &&
56 test "$(echo $(stg series --all))" = "+ p1 + p2 > p3" &&
57 test_cmp expected.txt a
58'
59
60cat > expected.txt <<EOF
61000
62111
63222
64EOF
65test_expect_success '... and undo it' '
66 stg reset master.stgit^~1 &&
67 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3" &&
68 test_cmp expected.txt a
69'
70
71test_expect_success 'Commit one patch ...' '
72 stg commit &&
73 test "$(echo $(stg series --all))" = "> p2 - p3"
74'
75
76test_expect_success '... and undo it' '
77 stg reset master.stgit^~1 &&
78 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3"
79'
80
81test_expect_success 'Hide a patch ...' '
82 stg hide p3 &&
83 test "$(echo $(stg series --all))" = "+ p1 > p2 ! p3"
84'
85
86test_expect_success '... undo the hiding ...' '
87 stg reset master.stgit^~1 &&
88 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3"
89'
90
91test_expect_success '... unhide the patch ...' '
92 stg hide p3 && stg unhide p3 &&
93 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3"
94'
95
96test_expect_success '... and undo the unhiding' '
97 stg reset master.stgit^~1 &&
98 test "$(echo $(stg series --all))" = "+ p1 > p2 ! p3" &&
99 stg unhide p3
100'
101
102cat > expected.txt <<EOF
103000
104111
105EOF
106test_expect_success 'Delete two patches ...' '
107 stg delete p2 p3 &&
108 test "$(echo $(stg series --all))" = "> p1" &&
109 test_cmp expected.txt a
110'
111
112test_expect_success '... and undo one of the deletions ...' '
113 stg reset master.stgit^~1 p3 &&
114 test "$(echo $(stg series --all))" = "> p1 - p3" &&
115 test_cmp expected.txt a
116'
117
118test_expect_success '... then undo the first undo ...' '
119 stg reset master.stgit^~1 &&
120 test "$(echo $(stg series --all))" = "> p1" &&
121 test_cmp expected.txt a
122'
123
124cat > expected.txt <<EOF
125000
126111
127222
128EOF
129test_expect_success '... and undo the other deletion' '
130 stg reset master.stgit^~3 p2 &&
131 stg push p2 &&
132 test "$(echo $(stg series --all))" = "+ p1 > p2" &&
133 test_cmp expected.txt a
134'
135
136cat > expected.txt <<EOF
137000
138111
139222
140ggg
141EOF
142test_expect_success 'Refresh a patch ...' '
143 echo ggg >> a &&
144 stg refresh &&
145 test "$(echo $(stg series --all))" = "+ p1 > p2" &&
146 test_cmp expected.txt a
147'
148
149cat > expected.txt <<EOF
150000
151111
152222
153EOF
154test_expect_success '... and undo the refresh' '
85aaed81 155 stg reset master.stgit^~2 &&
3a3a4f2f
KH
156 test "$(echo $(stg series --all))" = "+ p1 > p2" &&
157 test_cmp expected.txt a
158'
159
160test_done