Test for generated patchname with trailing period
[stgit.git] / t / t3100-reset.sh
blobe9da6005c18e1fc306bffaf4ac12678dff6b4858
1 #!/bin/sh
3 test_description='Simple test cases for "stg reset"'
5 . ./test-lib.sh
7 # Ignore our own output files.
8 cat >> .git/info/exclude <<EOF
9 /expected.txt
10 EOF
12 test_expect_success 'Initialize StGit stack with three patches' '
13 stg init &&
14 echo 000 >> a &&
15 stg 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
27 cat > expected.txt <<EOF
28 000
29 111
30 EOF
31 test_expect_success 'Pop one patch ...' '
32 stg pop &&
33 test "$(echo $(stg series --all))" = "> p1 - p2 - p3" &&
34 test_cmp expected.txt a
37 cat > expected.txt <<EOF
38 000
39 111
40 222
41 EOF
42 test_expect_success '... and undo it' '
43 stg reset refs/stacks/master^~1 &&
44 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3" &&
45 test_cmp expected.txt a
48 cat > expected.txt <<EOF
49 000
50 111
51 222
52 333
53 EOF
54 test_expect_success 'Push one patch ...' '
55 stg push &&
56 test "$(echo $(stg series --all))" = "+ p1 + p2 > p3" &&
57 test_cmp expected.txt a
60 cat > expected.txt <<EOF
61 000
62 111
63 222
64 EOF
65 test_expect_success '... and undo it' '
66 stg reset refs/stacks/master^~1 &&
67 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3" &&
68 test_cmp expected.txt a
71 test_expect_success 'Commit one patch ...' '
72 stg commit &&
73 test "$(echo $(stg series --all))" = "> p2 - p3"
76 test_expect_success '... and undo it' '
77 stg reset refs/stacks/master^~1 &&
78 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3"
81 test_expect_success 'Hide a patch ...' '
82 stg hide p3 &&
83 test "$(echo $(stg series --all))" = "+ p1 > p2 ! p3"
86 test_expect_success '... undo the hiding ...' '
87 stg reset refs/stacks/master^~1 &&
88 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3"
91 test_expect_success '... unhide the patch ...' '
92 stg hide p3 && stg unhide p3 &&
93 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3"
96 test_expect_success '... and undo the unhiding' '
97 stg reset refs/stacks/master^~1 &&
98 test "$(echo $(stg series --all))" = "+ p1 > p2 ! p3" &&
99 stg unhide p3
102 cat > expected.txt <<EOF
106 test_expect_success 'Delete two patches ...' '
107 stg delete p2 p3 &&
108 test "$(echo $(stg series --all))" = "> p1" &&
109 test_cmp expected.txt a
112 test_expect_success '... and undo one of the deletions ...' '
113 stg reset refs/stacks/master^~1 p3 &&
114 test "$(echo $(stg series --all))" = "> p1 - p3" &&
115 test_cmp expected.txt a
118 test_expect_success '... then undo the first undo ...' '
119 stg reset refs/stacks/master^~1 &&
120 test "$(echo $(stg series --all))" = "> p1" &&
121 test_cmp expected.txt a
124 cat > expected.txt <<EOF
129 test_expect_success '... and undo the other deletion' '
130 stg reset refs/stacks/master^~3 p2 &&
131 stg push p2 &&
132 test "$(echo $(stg series --all))" = "+ p1 > p2" &&
133 test_cmp expected.txt a
136 cat > expected.txt <<EOF
142 test_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
149 cat > expected.txt <<EOF
154 test_expect_success '... and undo the refresh' '
155 stg reset refs/stacks/master^~2 &&
156 test "$(echo $(stg series --all))" = "+ p1 > p2" &&
157 test_cmp expected.txt a
160 test_done