2 test_description
='Test the pick command'
7 'Attempt pick with uninitialized stack' \
9 command_error stg pick foo 2>&1 |
10 grep "master: branch not initialized"
14 'Initialize the StGIT repository' \
17 stg new A -m "a" && echo A > a && stg add a && stg refresh &&
18 stg new B -m "b" && echo B > b && stg add b && stg refresh &&
19 stg branch --clone foo &&
20 stg new C -m "c" && echo C > c && stg add c && stg refresh &&
21 stg new D-foo -m "d" && echo D > d && stg add d && stg refresh &&
23 echo AA >> a && echo BB >> b && echo CC >> c &&
25 stg new AAA -m "aaa" &&
26 echo "A" > a && echo "AAA" >> a && echo "AA" >> a && stg refresh &&
33 command_error stg pick 2>&1 |
34 grep "incorrect number of arguments"
38 'Pick --name with multiple patches' \
40 command_error stg pick --ref-branch foo --name C_and_E C E 2>&1 |
41 grep "name can only be specified with one patch"
48 test "$(echo $(stg series --applied --noprefix))" = "A B C" &&
49 test "$(echo $(cat c))" = "C"
53 'Pick --unapplied remote patch' \
55 stg pick --unapplied --ref-branch foo --name D D-foo &&
56 test "$(echo $(stg series --applied --noprefix))" = "A B C" &&
57 test "$(echo $(stg series --unapplied --noprefix))" = "D"
61 'Pick --file without --fold' \
63 command_error stg pick --file d D 2>&1 |
64 grep "file can only be specified with --fold"
68 'Pick local unapplied patch' \
71 test "$(echo $(stg series --applied --noprefix))" = "A B C D-1" &&
72 test "$(echo $(stg series --unapplied --noprefix))" = "D"
76 'Pick --fold --revert local patch' \
78 stg pick --fold --revert D &&
79 stg refresh && stg clean &&
80 test "$(echo $(stg series --applied --noprefix))" = "A B C" &&
81 test "$(echo $(stg series --unapplied --noprefix))" = "D"
85 'Pick --fold without applied patches' \
89 test "$(echo $(stg series --unapplied --noprefix))" = "A B C D" &&
90 test "$(echo $(stg status))" = "A d" &&
95 'Pick --fold --file' \
98 stg pick --fold --file a --file c foo:E &&
99 test "$(echo $(cat a))" = "A AA" &&
100 test "$(echo $(cat b))" = "B" &&
101 test "$(echo $(cat c))" = "C CC" &&
105 test_expect_success \
108 stg pick --revert C &&
109 test "$(stg top)" = "revert-C" &&
110 stg show | grep -E "Revert \"c\"" &&
114 test_expect_success \
115 'Pick with empty result' \
118 stg series -e | grep -E "0> A-1" &&
122 test_expect_success \
123 'Pick --fold with empty result' \
125 stg pick --fold -B foo A &&
126 test -z "$(stg status)"
129 test_expect_success \
130 'Pick --fold --files empty result' \
132 stg pick --fold -B foo A --file c &&
133 test -z "$(stg status)"
136 test_expect_success \
140 stg pick --update -B foo E &&
141 test "$(stg status)" = "M c" &&
142 test "$(echo $(cat c))" = "C CC" &&
146 test_expect_success \
147 'Pick --update without applied patches' \
150 command_error stg pick --update -B foo E 2>&1 |
151 grep "No patches applied"
154 test_expect_success \
155 'Pick commit with expose' \
165 "(imported from commit $(cat C-id))" \
167 test_when_finished rm -f C2-expected.txt C2-message.txt &&
168 stg pick --expose --name C2 $(cat C-id) &&
169 test "$(stg top)" = "C2" &&
170 git show --no-patch --pretty=format:%B > C2-message.txt &&
171 test_cmp C2-expected.txt C2-message.txt
174 test_expect_success \
175 'Pick too many commits' \
177 command_error stg pick --ref-branch foo $(cat C-id) D-foo 2>&1 |
178 grep "Unknown patch name"
181 test_expect_success \
182 'Pick with conflict' \
186 conflict stg pick foo:AAA 2>&1 |
187 grep "1 merge conflict(s)" &&
188 test "$(stg top)" = "AAA" &&
189 test "$(echo $(stg series -A --noprefix))" = "C2 A AAA" &&
190 test "$(echo $(stg status))" = "UU a" &&
195 test_expect_success \
196 'Pick --fold with conflict' \
198 conflict stg pick --fold --ref-branch=foo AAA 2>&1 |
199 grep "Merge conflict in a" &&
203 test_expect_success \
204 'Pick --fold --file with conflict' \
206 conflict stg pick --fold --file a -Bfoo AAA 2>&1 |
207 grep "AAA does not apply cleanly" &&
211 test_expect_success \
212 'Pick --update with conflict' \
214 conflict stg pick --update foo:AAA 2>&1 |
215 grep "AAA does not apply cleanly" &&