3 test_description='Simple test cases for "stg reset"'
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 &&
27 cat > expected.txt <<EOF
31 test_expect_success 'Pop one patch ...' '
33 test "$(echo $(stg series --all))" = "> p1 - p2 - p3" &&
34 test_cmp expected.txt a
37 cat > expected.txt <<EOF
42 test_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
48 cat > expected.txt <<EOF
54 test_expect_success 'Push one patch ...' '
56 test "$(echo $(stg series --all))" = "+ p1 + p2 > p3" &&
57 test_cmp expected.txt a
60 cat > expected.txt <<EOF
65 test_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
71 test_expect_success 'Commit one patch ...' '
73 test "$(echo $(stg series --all))" = "> p2 - p3"
76 test_expect_success '... and undo it' '
77 stg reset master.stgit^~1 &&
78 test "$(echo $(stg series --all))" = "+ p1 > p2 - p3"
81 test_expect_success 'Hide a patch ...' '
83 test "$(echo $(stg series --all))" = "+ p1 > p2 ! p3"
86 test_expect_success '... undo the hiding ...' '
87 stg reset master.stgit^~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 master.stgit^~1 &&
98 test "$(echo $(stg series --all))" = "+ p1 > p2 ! p3" &&
102 cat > expected.txt <<EOF
106 test_expect_success 'Delete two patches ...' '
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 master.stgit^~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 master.stgit^~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 master.stgit^~3 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 ...' '
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 master.stgit^~1 &&
156 test "$(echo $(stg series --all))" = "+ p1 > p2" &&
157 test_cmp expected.txt a