Blame


1 fccbfb98 2019-08-03 stsp #!/bin/sh
2 fccbfb98 2019-08-03 stsp #
3 fccbfb98 2019-08-03 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 fccbfb98 2019-08-03 stsp #
5 fccbfb98 2019-08-03 stsp # Permission to use, copy, modify, and distribute this software for any
6 fccbfb98 2019-08-03 stsp # purpose with or without fee is hereby granted, provided that the above
7 fccbfb98 2019-08-03 stsp # copyright notice and this permission notice appear in all copies.
8 fccbfb98 2019-08-03 stsp #
9 fccbfb98 2019-08-03 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 fccbfb98 2019-08-03 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 fccbfb98 2019-08-03 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 fccbfb98 2019-08-03 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 fccbfb98 2019-08-03 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 fccbfb98 2019-08-03 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 fccbfb98 2019-08-03 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 fccbfb98 2019-08-03 stsp
17 fccbfb98 2019-08-03 stsp . ./common.sh
18 fccbfb98 2019-08-03 stsp
19 fccbfb98 2019-08-03 stsp function test_stage_basic {
20 fccbfb98 2019-08-03 stsp local testroot=`test_init stage_basic`
21 fccbfb98 2019-08-03 stsp
22 fccbfb98 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 fccbfb98 2019-08-03 stsp ret="$?"
24 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
25 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
26 fccbfb98 2019-08-03 stsp return 1
27 fccbfb98 2019-08-03 stsp fi
28 fccbfb98 2019-08-03 stsp
29 fccbfb98 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
30 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
31 fccbfb98 2019-08-03 stsp echo "new file" > $testroot/wt/foo
32 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
33 fccbfb98 2019-08-03 stsp
34 88d0e355 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
35 88d0e355 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
36 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
37 ec9d9b2f 2019-08-08 stsp (cd $testroot/wt && got stage > $testroot/stdout)
38 d3e7c587 2019-08-03 stsp
39 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
40 d3e7c587 2019-08-03 stsp ret="$?"
41 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
42 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
43 d3e7c587 2019-08-03 stsp fi
44 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
45 d3e7c587 2019-08-03 stsp }
46 d3e7c587 2019-08-03 stsp
47 31b20a6e 2019-08-06 stsp function test_stage_no_changes {
48 31b20a6e 2019-08-06 stsp local testroot=`test_init stage_no_changes`
49 31b20a6e 2019-08-06 stsp
50 31b20a6e 2019-08-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
51 31b20a6e 2019-08-06 stsp ret="$?"
52 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
53 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
54 31b20a6e 2019-08-06 stsp return 1
55 31b20a6e 2019-08-06 stsp fi
56 31b20a6e 2019-08-06 stsp
57 31b20a6e 2019-08-06 stsp (cd $testroot/wt && got stage alpha beta > $testroot/stdout \
58 31b20a6e 2019-08-06 stsp 2> $testroot/stderr)
59 31b20a6e 2019-08-06 stsp ret="$?"
60 31b20a6e 2019-08-06 stsp if [ "$ret" == "0" ]; then
61 31b20a6e 2019-08-06 stsp echo "got stage command succeeded unexpectedly" >&2
62 31b20a6e 2019-08-06 stsp test_done "$testroot" "1"
63 31b20a6e 2019-08-06 stsp return 1
64 31b20a6e 2019-08-06 stsp fi
65 31b20a6e 2019-08-06 stsp
66 2db2652d 2019-08-07 stsp echo "got: no changes to stage" > $testroot/stderr.expected
67 31b20a6e 2019-08-06 stsp
68 31b20a6e 2019-08-06 stsp cmp -s $testroot/stderr.expected $testroot/stderr
69 31b20a6e 2019-08-06 stsp ret="$?"
70 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
71 31b20a6e 2019-08-06 stsp diff -u $testroot/stderr.expected $testroot/stderr
72 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
73 31b20a6e 2019-08-06 stsp return 1
74 31b20a6e 2019-08-06 stsp fi
75 31b20a6e 2019-08-06 stsp
76 31b20a6e 2019-08-06 stsp echo -n > $testroot/stdout.expected
77 31b20a6e 2019-08-06 stsp cmp -s $testroot/stdout.expected $testroot/stdout
78 31b20a6e 2019-08-06 stsp ret="$?"
79 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
80 31b20a6e 2019-08-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
81 31b20a6e 2019-08-06 stsp fi
82 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
83 31b20a6e 2019-08-06 stsp }
84 31b20a6e 2019-08-06 stsp
85 8b13ce36 2019-08-08 stsp function test_stage_unversioned {
86 8b13ce36 2019-08-08 stsp local testroot=`test_init stage_unversioned`
87 8b13ce36 2019-08-08 stsp
88 8b13ce36 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
89 8b13ce36 2019-08-08 stsp ret="$?"
90 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
91 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
92 8b13ce36 2019-08-08 stsp return 1
93 8b13ce36 2019-08-08 stsp fi
94 8b13ce36 2019-08-08 stsp
95 8b13ce36 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
96 8b13ce36 2019-08-08 stsp touch $testroot/wt/unversioned-file
97 8b13ce36 2019-08-08 stsp
98 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
99 8b13ce36 2019-08-08 stsp echo "M alpha" > $testroot/stdout.expected
100 8b13ce36 2019-08-08 stsp echo "? unversioned-file" >> $testroot/stdout.expected
101 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
102 8b13ce36 2019-08-08 stsp ret="$?"
103 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
104 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
105 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
106 8b13ce36 2019-08-08 stsp return 1
107 8b13ce36 2019-08-08 stsp fi
108 8b13ce36 2019-08-08 stsp
109 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage > $testroot/stdout)
110 8b13ce36 2019-08-08 stsp ret="$?"
111 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
112 8b13ce36 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
113 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
114 8b13ce36 2019-08-08 stsp return 1
115 8b13ce36 2019-08-08 stsp fi
116 8b13ce36 2019-08-08 stsp
117 8b13ce36 2019-08-08 stsp echo " M alpha" > $testroot/stdout.expected
118 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
119 8b13ce36 2019-08-08 stsp ret="$?"
120 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
121 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
122 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
123 8b13ce36 2019-08-08 stsp return 1
124 8b13ce36 2019-08-08 stsp fi
125 8b13ce36 2019-08-08 stsp
126 8b13ce36 2019-08-08 stsp echo "modified file again" > $testroot/wt/alpha
127 8b13ce36 2019-08-08 stsp
128 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage unversioned-file > $testroot/stdout \
129 8b13ce36 2019-08-08 stsp 2> $testroot/stderr)
130 8b13ce36 2019-08-08 stsp ret="$?"
131 8b13ce36 2019-08-08 stsp if [ "$ret" == "0" ]; then
132 8b13ce36 2019-08-08 stsp echo "got stage command succeed unexpectedly" >&2
133 8b13ce36 2019-08-08 stsp test_done "$testroot" "1"
134 8b13ce36 2019-08-08 stsp return 1
135 8b13ce36 2019-08-08 stsp fi
136 8b13ce36 2019-08-08 stsp
137 8b13ce36 2019-08-08 stsp echo "got: no changes to stage" > $testroot/stderr.expected
138 8b13ce36 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
139 8b13ce36 2019-08-08 stsp ret="$?"
140 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
141 8b13ce36 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
142 8b13ce36 2019-08-08 stsp fi
143 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
144 8564cb21 2019-08-08 stsp
145 8564cb21 2019-08-08 stsp }
146 8564cb21 2019-08-08 stsp
147 8564cb21 2019-08-08 stsp function test_stage_nonexistent {
148 8564cb21 2019-08-08 stsp local testroot=`test_init stage_nonexistent`
149 8564cb21 2019-08-08 stsp
150 8564cb21 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
151 8564cb21 2019-08-08 stsp ret="$?"
152 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
153 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
154 8564cb21 2019-08-08 stsp return 1
155 8564cb21 2019-08-08 stsp fi
156 8b13ce36 2019-08-08 stsp
157 8564cb21 2019-08-08 stsp (cd $testroot/wt && got stage nonexistent-file \
158 8564cb21 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
159 8564cb21 2019-08-08 stsp echo "got: no changes to stage" > $testroot/stderr.expected
160 8564cb21 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
161 8564cb21 2019-08-08 stsp ret="$?"
162 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
163 8564cb21 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
164 8564cb21 2019-08-08 stsp fi
165 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
166 8b13ce36 2019-08-08 stsp }
167 8b13ce36 2019-08-08 stsp
168 a4f692bb 2019-08-04 stsp function test_stage_list {
169 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
170 a4f692bb 2019-08-04 stsp
171 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
172 a4f692bb 2019-08-04 stsp ret="$?"
173 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
174 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
175 a4f692bb 2019-08-04 stsp return 1
176 a4f692bb 2019-08-04 stsp fi
177 a4f692bb 2019-08-04 stsp
178 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
179 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
180 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
181 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
182 a4f692bb 2019-08-04 stsp
183 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
184 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
185 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
186 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
187 a4f692bb 2019-08-04 stsp
188 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
189 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
190 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
191 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
192 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
193 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
194 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
195 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
196 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
197 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
198 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
199 a4f692bb 2019-08-04 stsp ret="$?"
200 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
201 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
202 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
203 a4f692bb 2019-08-04 stsp return 1
204 a4f692bb 2019-08-04 stsp fi
205 a4f692bb 2019-08-04 stsp
206 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
207 a4f692bb 2019-08-04 stsp > $testroot/stdout)
208 a4f692bb 2019-08-04 stsp
209 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
210 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
211 a4f692bb 2019-08-04 stsp ret="$?"
212 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
213 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
214 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
215 a4f692bb 2019-08-04 stsp return 1
216 a4f692bb 2019-08-04 stsp fi
217 a4f692bb 2019-08-04 stsp
218 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
219 a4f692bb 2019-08-04 stsp
220 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
221 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
222 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
223 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
224 a4f692bb 2019-08-04 stsp ret="$?"
225 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
226 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
227 a4f692bb 2019-08-04 stsp fi
228 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
229 a4f692bb 2019-08-04 stsp
230 a4f692bb 2019-08-04 stsp }
231 a4f692bb 2019-08-04 stsp
232 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
233 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
234 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
235 ebf48fd5 2019-08-03 stsp
236 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
237 ebf48fd5 2019-08-03 stsp ret="$?"
238 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
239 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
240 ebf48fd5 2019-08-03 stsp return 1
241 ebf48fd5 2019-08-03 stsp fi
242 ebf48fd5 2019-08-03 stsp
243 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
244 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
245 ebf48fd5 2019-08-03 stsp
246 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
247 ebf48fd5 2019-08-03 stsp
248 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
249 ebf48fd5 2019-08-03 stsp
250 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
251 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
252 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
253 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
254 ebf48fd5 2019-08-03 stsp
255 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
256 ebf48fd5 2019-08-03 stsp
257 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
258 ebf48fd5 2019-08-03 stsp ret="$?"
259 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
260 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
261 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
262 ebf48fd5 2019-08-03 stsp return 1
263 ebf48fd5 2019-08-03 stsp fi
264 ebf48fd5 2019-08-03 stsp
265 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
266 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
267 ebf48fd5 2019-08-03 stsp ret="$?"
268 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
269 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
270 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
271 ebf48fd5 2019-08-03 stsp return 1
272 ebf48fd5 2019-08-03 stsp fi
273 ebf48fd5 2019-08-03 stsp
274 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
275 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
276 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
277 735ef5ac 2019-08-03 stsp
278 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
279 735ef5ac 2019-08-03 stsp ret="$?"
280 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
281 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
282 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
283 735ef5ac 2019-08-03 stsp return 1
284 735ef5ac 2019-08-03 stsp fi
285 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
286 735ef5ac 2019-08-03 stsp ret="$?"
287 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
288 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
289 735ef5ac 2019-08-03 stsp fi
290 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
291 735ef5ac 2019-08-03 stsp }
292 735ef5ac 2019-08-03 stsp
293 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
294 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
295 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
296 735ef5ac 2019-08-03 stsp
297 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
298 735ef5ac 2019-08-03 stsp ret="$?"
299 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
300 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
301 735ef5ac 2019-08-03 stsp return 1
302 735ef5ac 2019-08-03 stsp fi
303 735ef5ac 2019-08-03 stsp
304 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
305 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
306 735ef5ac 2019-08-03 stsp
307 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
308 735ef5ac 2019-08-03 stsp
309 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
310 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
311 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
312 735ef5ac 2019-08-03 stsp ret="$?"
313 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
314 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
315 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
316 735ef5ac 2019-08-03 stsp return 1
317 735ef5ac 2019-08-03 stsp fi
318 735ef5ac 2019-08-03 stsp
319 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
320 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
321 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
322 ebf48fd5 2019-08-03 stsp
323 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
324 ebf48fd5 2019-08-03 stsp ret="$?"
325 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
326 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
327 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
328 ebf48fd5 2019-08-03 stsp return 1
329 ebf48fd5 2019-08-03 stsp fi
330 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
331 ebf48fd5 2019-08-03 stsp ret="$?"
332 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
333 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
334 ebf48fd5 2019-08-03 stsp fi
335 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
336 ebf48fd5 2019-08-03 stsp }
337 ebf48fd5 2019-08-03 stsp
338 ebf48fd5 2019-08-03 stsp
339 d3e7c587 2019-08-03 stsp function test_double_stage {
340 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
341 d3e7c587 2019-08-03 stsp
342 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
343 d3e7c587 2019-08-03 stsp ret="$?"
344 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
345 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
346 d3e7c587 2019-08-03 stsp return 1
347 d3e7c587 2019-08-03 stsp fi
348 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
349 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
350 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
351 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
352 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
353 d3e7c587 2019-08-03 stsp
354 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
355 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
356 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
357 d3e7c587 2019-08-03 stsp ret="$?"
358 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
359 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
360 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
361 d3e7c587 2019-08-03 stsp return 1
362 d3e7c587 2019-08-03 stsp fi
363 d3e7c587 2019-08-03 stsp
364 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
365 9c5c5eed 2019-08-03 stsp ret="$?"
366 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
367 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
368 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
369 d3e7c587 2019-08-03 stsp return 1
370 d3e7c587 2019-08-03 stsp fi
371 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
372 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
373 d3e7c587 2019-08-03 stsp ret="$?"
374 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
375 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
376 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
377 d3e7c587 2019-08-03 stsp return 1
378 d3e7c587 2019-08-03 stsp fi
379 d3e7c587 2019-08-03 stsp
380 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
381 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
382 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
383 d3e7c587 2019-08-03 stsp ret="$?"
384 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
385 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
386 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
387 d3e7c587 2019-08-03 stsp return 1
388 d3e7c587 2019-08-03 stsp fi
389 d3e7c587 2019-08-03 stsp
390 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
391 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
392 d3e7c587 2019-08-03 stsp
393 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
394 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
395 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
396 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
397 d3e7c587 2019-08-03 stsp ret="$?"
398 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
399 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
400 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
401 d3e7c587 2019-08-03 stsp return 1
402 d3e7c587 2019-08-03 stsp fi
403 d3e7c587 2019-08-03 stsp
404 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
405 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
406 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
407 fccbfb98 2019-08-03 stsp
408 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
409 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
410 fccbfb98 2019-08-03 stsp ret="$?"
411 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
412 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
413 fccbfb98 2019-08-03 stsp fi
414 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
415 fccbfb98 2019-08-03 stsp }
416 fccbfb98 2019-08-03 stsp
417 c363b2c1 2019-08-03 stsp function test_stage_status {
418 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
419 c363b2c1 2019-08-03 stsp
420 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
421 c363b2c1 2019-08-03 stsp ret="$?"
422 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
423 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
424 c363b2c1 2019-08-03 stsp return 1
425 c363b2c1 2019-08-03 stsp fi
426 c363b2c1 2019-08-03 stsp
427 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
428 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
429 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
430 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
431 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
432 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
433 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
434 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
435 c363b2c1 2019-08-03 stsp
436 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
437 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
438 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
439 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
440 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
441 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
442 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
443 c363b2c1 2019-08-03 stsp
444 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
445 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
446 c363b2c1 2019-08-03 stsp ret="$?"
447 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
448 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
449 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
450 244725f2 2019-08-03 stsp return 1
451 c363b2c1 2019-08-03 stsp fi
452 244725f2 2019-08-03 stsp
453 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
454 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
455 244725f2 2019-08-03 stsp
456 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
457 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
458 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
459 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
460 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
461 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
462 244725f2 2019-08-03 stsp
463 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
464 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
465 244725f2 2019-08-03 stsp ret="$?"
466 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
467 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
468 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
469 244725f2 2019-08-03 stsp return 1
470 244725f2 2019-08-03 stsp fi
471 244725f2 2019-08-03 stsp
472 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
473 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
474 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
475 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
476 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
477 244725f2 2019-08-03 stsp ret="$?"
478 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
479 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
480 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
481 244725f2 2019-08-03 stsp return 1
482 244725f2 2019-08-03 stsp fi
483 244725f2 2019-08-03 stsp
484 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
485 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
486 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
487 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
488 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
489 244725f2 2019-08-03 stsp ret="$?"
490 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
491 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
492 244725f2 2019-08-03 stsp fi
493 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
494 244725f2 2019-08-03 stsp
495 c363b2c1 2019-08-03 stsp }
496 c363b2c1 2019-08-03 stsp
497 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
498 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
499 1e1446d3 2019-08-03 stsp
500 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
501 1e1446d3 2019-08-03 stsp ret="$?"
502 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
503 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
504 1e1446d3 2019-08-03 stsp return 1
505 1e1446d3 2019-08-03 stsp fi
506 1e1446d3 2019-08-03 stsp
507 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
508 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
509 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
510 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
511 1e1446d3 2019-08-03 stsp
512 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
513 1e1446d3 2019-08-03 stsp
514 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
515 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
516 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
517 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
518 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
519 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
520 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
521 1e1446d3 2019-08-03 stsp ret="$?"
522 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
523 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
524 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
525 1e1446d3 2019-08-03 stsp return 1
526 1e1446d3 2019-08-03 stsp fi
527 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
528 1e1446d3 2019-08-03 stsp ret="$?"
529 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
530 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
531 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
532 1e1446d3 2019-08-03 stsp return 1
533 1e1446d3 2019-08-03 stsp fi
534 1e1446d3 2019-08-03 stsp done
535 1e1446d3 2019-08-03 stsp
536 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
537 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
538 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
539 1e1446d3 2019-08-03 stsp
540 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
541 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
542 1e1446d3 2019-08-03 stsp ret="$?"
543 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
544 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
545 1e1446d3 2019-08-03 stsp fi
546 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
547 1e1446d3 2019-08-03 stsp }
548 1e1446d3 2019-08-03 stsp
549 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
550 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
551 9acbc4fa 2019-08-03 stsp
552 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
553 9acbc4fa 2019-08-03 stsp ret="$?"
554 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
555 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
556 9acbc4fa 2019-08-03 stsp return 1
557 9acbc4fa 2019-08-03 stsp fi
558 9acbc4fa 2019-08-03 stsp
559 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
560 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
561 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
562 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
563 9acbc4fa 2019-08-03 stsp
564 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
565 9acbc4fa 2019-08-03 stsp
566 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
567 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
568 9acbc4fa 2019-08-03 stsp ret="$?"
569 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
570 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
571 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
572 9acbc4fa 2019-08-03 stsp return 1
573 9acbc4fa 2019-08-03 stsp fi
574 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
575 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
576 6d022e97 2019-08-04 stsp ret="$?"
577 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
578 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
579 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
580 6d022e97 2019-08-04 stsp return 1
581 6d022e97 2019-08-04 stsp fi
582 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
583 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
584 9acbc4fa 2019-08-03 stsp ret="$?"
585 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
586 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
587 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
588 9acbc4fa 2019-08-03 stsp return 1
589 9acbc4fa 2019-08-03 stsp fi
590 9acbc4fa 2019-08-03 stsp
591 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
592 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
593 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
594 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
595 9acbc4fa 2019-08-03 stsp ret="$?"
596 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
597 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
598 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
599 9acbc4fa 2019-08-03 stsp return 1
600 9acbc4fa 2019-08-03 stsp fi
601 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
602 9acbc4fa 2019-08-03 stsp ret="$?"
603 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
604 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
605 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
606 9acbc4fa 2019-08-03 stsp return 1
607 9acbc4fa 2019-08-03 stsp fi
608 9acbc4fa 2019-08-03 stsp done
609 9acbc4fa 2019-08-03 stsp
610 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
611 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
612 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
613 9acbc4fa 2019-08-03 stsp
614 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
615 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
616 9acbc4fa 2019-08-03 stsp ret="$?"
617 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
618 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
619 9acbc4fa 2019-08-03 stsp fi
620 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
621 9acbc4fa 2019-08-03 stsp }
622 24278f30 2019-08-03 stsp
623 24278f30 2019-08-03 stsp function test_stage_revert {
624 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
625 24278f30 2019-08-03 stsp
626 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
627 24278f30 2019-08-03 stsp ret="$?"
628 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
629 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
630 24278f30 2019-08-03 stsp return 1
631 24278f30 2019-08-03 stsp fi
632 24278f30 2019-08-03 stsp
633 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
634 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
635 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
636 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
637 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
638 24278f30 2019-08-03 stsp
639 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
640 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
641 24278f30 2019-08-03 stsp
642 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
643 24278f30 2019-08-03 stsp ret="$?"
644 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
645 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
646 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
647 24278f30 2019-08-03 stsp return 1
648 24278f30 2019-08-03 stsp fi
649 24278f30 2019-08-03 stsp
650 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
651 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
652 24278f30 2019-08-03 stsp ret="$?"
653 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
654 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
655 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
656 24278f30 2019-08-03 stsp return 1
657 24278f30 2019-08-03 stsp fi
658 24278f30 2019-08-03 stsp
659 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
660 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
661 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
662 24278f30 2019-08-03 stsp ret="$?"
663 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
664 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
665 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
666 24278f30 2019-08-03 stsp return 1
667 24278f30 2019-08-03 stsp fi
668 9acbc4fa 2019-08-03 stsp
669 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
670 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
671 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
672 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
673 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
674 24278f30 2019-08-03 stsp ret="$?"
675 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
676 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
677 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
678 24278f30 2019-08-03 stsp return 1
679 24278f30 2019-08-03 stsp fi
680 24278f30 2019-08-03 stsp
681 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
682 24278f30 2019-08-03 stsp ret="$?"
683 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
684 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
685 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
686 24278f30 2019-08-03 stsp return 1
687 24278f30 2019-08-03 stsp fi
688 24278f30 2019-08-03 stsp
689 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
690 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
691 24278f30 2019-08-03 stsp ret="$?"
692 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
693 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
694 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
695 24278f30 2019-08-03 stsp return 1
696 24278f30 2019-08-03 stsp fi
697 24278f30 2019-08-03 stsp
698 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
699 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
700 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
701 24278f30 2019-08-03 stsp ret="$?"
702 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
703 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
704 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
705 24278f30 2019-08-03 stsp return 1
706 24278f30 2019-08-03 stsp fi
707 24278f30 2019-08-03 stsp
708 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
709 24278f30 2019-08-03 stsp 2> $testroot/stderr)
710 24278f30 2019-08-03 stsp ret="$?"
711 24278f30 2019-08-03 stsp if [ "$ret" == "0" ]; then
712 24278f30 2019-08-03 stsp echo "revert command succeeded unexpectedly" >&2
713 24278f30 2019-08-03 stsp test_done "$testroot" "1"
714 24278f30 2019-08-03 stsp return 1
715 24278f30 2019-08-03 stsp fi
716 24278f30 2019-08-03 stsp
717 24278f30 2019-08-03 stsp echo "got: beta: file is staged" > $testroot/stderr.expected
718 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
719 24278f30 2019-08-03 stsp ret="$?"
720 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
721 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
722 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
723 24278f30 2019-08-03 stsp return 1
724 24278f30 2019-08-03 stsp fi
725 24278f30 2019-08-03 stsp
726 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
727 24278f30 2019-08-03 stsp ret="$?"
728 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
729 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
730 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
731 24278f30 2019-08-03 stsp return 1
732 24278f30 2019-08-03 stsp fi
733 24278f30 2019-08-03 stsp
734 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
735 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
736 24278f30 2019-08-03 stsp ret="$?"
737 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
738 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
739 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
740 24278f30 2019-08-03 stsp return 1
741 24278f30 2019-08-03 stsp fi
742 24278f30 2019-08-03 stsp
743 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
744 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
745 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
746 24278f30 2019-08-03 stsp ret="$?"
747 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
748 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
749 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
750 24278f30 2019-08-03 stsp return 1
751 24278f30 2019-08-03 stsp fi
752 24278f30 2019-08-03 stsp
753 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
754 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
755 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
756 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
757 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
758 24278f30 2019-08-03 stsp ret="$?"
759 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
760 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
761 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
762 24278f30 2019-08-03 stsp return 1
763 24278f30 2019-08-03 stsp fi
764 24278f30 2019-08-03 stsp
765 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
766 24278f30 2019-08-03 stsp ret="$?"
767 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
768 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
769 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
770 24278f30 2019-08-03 stsp return 1
771 24278f30 2019-08-03 stsp fi
772 24278f30 2019-08-03 stsp
773 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
774 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
775 24278f30 2019-08-03 stsp ret="$?"
776 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
777 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
778 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
779 24278f30 2019-08-03 stsp return 1
780 24278f30 2019-08-03 stsp fi
781 24278f30 2019-08-03 stsp
782 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
783 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
784 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
785 24278f30 2019-08-03 stsp ret="$?"
786 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
787 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
788 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
789 24278f30 2019-08-03 stsp return 1
790 24278f30 2019-08-03 stsp fi
791 24278f30 2019-08-03 stsp
792 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
793 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
794 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
795 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
796 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
797 408b4ebc 2019-08-03 stsp ret="$?"
798 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
799 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
800 408b4ebc 2019-08-03 stsp fi
801 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
802 408b4ebc 2019-08-03 stsp }
803 408b4ebc 2019-08-03 stsp
804 408b4ebc 2019-08-03 stsp function test_stage_diff {
805 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
806 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
807 408b4ebc 2019-08-03 stsp
808 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
809 408b4ebc 2019-08-03 stsp ret="$?"
810 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
811 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
812 408b4ebc 2019-08-03 stsp return 1
813 408b4ebc 2019-08-03 stsp fi
814 408b4ebc 2019-08-03 stsp
815 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
816 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
817 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
818 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
819 98eaaa12 2019-08-03 stsp
820 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
821 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
822 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
823 98eaaa12 2019-08-03 stsp ret="$?"
824 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
825 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
826 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
827 98eaaa12 2019-08-03 stsp return 1
828 98eaaa12 2019-08-03 stsp fi
829 408b4ebc 2019-08-03 stsp
830 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
831 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
832 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
833 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
834 408b4ebc 2019-08-03 stsp
835 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
836 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
837 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
838 408b4ebc 2019-08-03 stsp ret="$?"
839 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
840 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
841 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
842 408b4ebc 2019-08-03 stsp return 1
843 408b4ebc 2019-08-03 stsp fi
844 408b4ebc 2019-08-03 stsp
845 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
846 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
847 408b4ebc 2019-08-03 stsp
848 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
849 408b4ebc 2019-08-03 stsp
850 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
851 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
852 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
853 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
854 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
855 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
856 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
857 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
858 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
859 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
860 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
861 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
862 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
863 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
864 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
865 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
866 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
867 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
868 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
869 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
870 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
871 98eaaa12 2019-08-03 stsp
872 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
873 98eaaa12 2019-08-03 stsp ret="$?"
874 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
875 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
876 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
877 98eaaa12 2019-08-03 stsp return 1
878 98eaaa12 2019-08-03 stsp fi
879 98eaaa12 2019-08-03 stsp
880 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
881 98eaaa12 2019-08-03 stsp
882 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
883 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
884 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
885 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
886 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
887 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
888 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
889 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
890 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
891 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
892 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
893 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
894 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
895 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
896 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
897 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
898 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
899 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
900 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
901 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
902 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
903 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
904 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
905 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
906 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
907 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
908 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
909 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
910 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
911 408b4ebc 2019-08-03 stsp
912 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
913 24278f30 2019-08-03 stsp ret="$?"
914 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
915 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
916 24278f30 2019-08-03 stsp fi
917 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
918 408b4ebc 2019-08-03 stsp
919 24278f30 2019-08-03 stsp }
920 b9622844 2019-08-03 stsp
921 b9622844 2019-08-03 stsp function test_stage_histedit {
922 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
923 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
924 b9622844 2019-08-03 stsp
925 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
926 b9622844 2019-08-03 stsp ret="$?"
927 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
928 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
929 b9622844 2019-08-03 stsp return 1
930 b9622844 2019-08-03 stsp fi
931 b9622844 2019-08-03 stsp
932 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
933 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
934 b9622844 2019-08-03 stsp
935 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
936 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
937 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
938 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
939 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
940 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
941 24278f30 2019-08-03 stsp
942 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
943 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
944 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
945 b9622844 2019-08-03 stsp
946 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
947 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
948 b9622844 2019-08-03 stsp
949 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
950 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
951 b9622844 2019-08-03 stsp ret="$?"
952 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
953 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
954 b9622844 2019-08-03 stsp test_done "$testroot" "1"
955 b9622844 2019-08-03 stsp return 1
956 b9622844 2019-08-03 stsp fi
957 b9622844 2019-08-03 stsp
958 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
959 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
960 b9622844 2019-08-03 stsp
961 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
962 b9622844 2019-08-03 stsp ret="$?"
963 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
964 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
965 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
966 b9622844 2019-08-03 stsp return 1
967 b9622844 2019-08-03 stsp fi
968 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
969 b9622844 2019-08-03 stsp ret="$?"
970 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
971 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
972 b9622844 2019-08-03 stsp fi
973 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
974 243d7cf1 2019-08-03 stsp
975 243d7cf1 2019-08-03 stsp }
976 243d7cf1 2019-08-03 stsp
977 243d7cf1 2019-08-03 stsp function test_stage_rebase {
978 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
979 243d7cf1 2019-08-03 stsp
980 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
981 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
982 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
983 243d7cf1 2019-08-03 stsp
984 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
985 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
986 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
987 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
988 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
989 243d7cf1 2019-08-03 stsp
990 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
991 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
992 243d7cf1 2019-08-03 stsp
993 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
994 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
995 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
996 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
997 243d7cf1 2019-08-03 stsp
998 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
999 243d7cf1 2019-08-03 stsp ret="$?"
1000 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1001 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1002 243d7cf1 2019-08-03 stsp return 1
1003 243d7cf1 2019-08-03 stsp fi
1004 243d7cf1 2019-08-03 stsp
1005 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1006 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1007 b9622844 2019-08-03 stsp
1008 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
1009 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1010 243d7cf1 2019-08-03 stsp ret="$?"
1011 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
1012 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
1013 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
1014 243d7cf1 2019-08-03 stsp return 1
1015 243d7cf1 2019-08-03 stsp fi
1016 243d7cf1 2019-08-03 stsp
1017 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
1018 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1019 243d7cf1 2019-08-03 stsp
1020 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1021 243d7cf1 2019-08-03 stsp ret="$?"
1022 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1023 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1024 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1025 243d7cf1 2019-08-03 stsp return 1
1026 243d7cf1 2019-08-03 stsp fi
1027 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1028 243d7cf1 2019-08-03 stsp ret="$?"
1029 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1030 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1031 243d7cf1 2019-08-03 stsp fi
1032 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1033 b9622844 2019-08-03 stsp }
1034 b9622844 2019-08-03 stsp
1035 a76c42e6 2019-08-03 stsp function test_stage_update {
1036 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1037 a76c42e6 2019-08-03 stsp
1038 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1039 a76c42e6 2019-08-03 stsp ret="$?"
1040 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1041 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1042 a76c42e6 2019-08-03 stsp return 1
1043 a76c42e6 2019-08-03 stsp fi
1044 243d7cf1 2019-08-03 stsp
1045 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1046 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1047 a76c42e6 2019-08-03 stsp
1048 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1049 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1050 a76c42e6 2019-08-03 stsp
1051 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1052 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1053 a76c42e6 2019-08-03 stsp ret="$?"
1054 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
1055 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1056 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1057 a76c42e6 2019-08-03 stsp return 1
1058 a76c42e6 2019-08-03 stsp fi
1059 a76c42e6 2019-08-03 stsp
1060 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1061 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1062 a76c42e6 2019-08-03 stsp
1063 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1064 a76c42e6 2019-08-03 stsp ret="$?"
1065 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1066 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1067 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1068 a76c42e6 2019-08-03 stsp return 1
1069 a76c42e6 2019-08-03 stsp fi
1070 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1071 a76c42e6 2019-08-03 stsp ret="$?"
1072 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1073 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1074 a76c42e6 2019-08-03 stsp fi
1075 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1076 a76c42e6 2019-08-03 stsp }
1077 f0b75401 2019-08-03 stsp
1078 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
1079 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1080 f0b75401 2019-08-03 stsp
1081 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1082 f0b75401 2019-08-03 stsp ret="$?"
1083 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1084 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1085 f0b75401 2019-08-03 stsp return 1
1086 f0b75401 2019-08-03 stsp fi
1087 f0b75401 2019-08-03 stsp
1088 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1089 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1090 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1091 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1092 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1093 a76c42e6 2019-08-03 stsp
1094 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1095 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1096 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1097 f0b75401 2019-08-03 stsp ret="$?"
1098 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
1099 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1100 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1101 f0b75401 2019-08-03 stsp return 1
1102 f0b75401 2019-08-03 stsp fi
1103 f0b75401 2019-08-03 stsp
1104 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1105 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1106 f0b75401 2019-08-03 stsp
1107 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1108 f0b75401 2019-08-03 stsp ret="$?"
1109 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1110 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1111 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1112 5f8a88c6 2019-08-03 stsp return 1
1113 5f8a88c6 2019-08-03 stsp fi
1114 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1115 5f8a88c6 2019-08-03 stsp ret="$?"
1116 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1117 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1118 5f8a88c6 2019-08-03 stsp fi
1119 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1120 5f8a88c6 2019-08-03 stsp }
1121 0f1cfa7f 2019-08-08 stsp
1122 0f1cfa7f 2019-08-08 stsp function test_stage_commit_out_of_date {
1123 0f1cfa7f 2019-08-08 stsp local testroot=`test_init stage_commit_out_of_date`
1124 0f1cfa7f 2019-08-08 stsp
1125 0f1cfa7f 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1126 0f1cfa7f 2019-08-08 stsp ret="$?"
1127 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1128 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1129 0f1cfa7f 2019-08-08 stsp return 1
1130 0f1cfa7f 2019-08-08 stsp fi
1131 0f1cfa7f 2019-08-08 stsp
1132 0f1cfa7f 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
1133 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
1134 0f1cfa7f 2019-08-08 stsp echo "new file" > $testroot/wt/foo
1135 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
1136 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1137 0f1cfa7f 2019-08-08 stsp
1138 0f1cfa7f 2019-08-08 stsp echo "changed file" > $testroot/repo/alpha
1139 0f1cfa7f 2019-08-08 stsp git_commit $testroot/repo -m "changed alpha in repo"
1140 0f1cfa7f 2019-08-08 stsp
1141 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1142 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1143 0f1cfa7f 2019-08-08 stsp ret="$?"
1144 0f1cfa7f 2019-08-08 stsp if [ "$ret" == "0" ]; then
1145 0f1cfa7f 2019-08-08 stsp echo "got commit command succeeded unexpectedly" >&2
1146 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "1"
1147 0f1cfa7f 2019-08-08 stsp return 1
1148 0f1cfa7f 2019-08-08 stsp fi
1149 0f1cfa7f 2019-08-08 stsp
1150 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1151 0f1cfa7f 2019-08-08 stsp echo -n "got: work tree must be updated before these changes " \
1152 0f1cfa7f 2019-08-08 stsp > $testroot/stderr.expected
1153 0f1cfa7f 2019-08-08 stsp echo "can be committed" >> $testroot/stderr.expected
1154 5f8a88c6 2019-08-03 stsp
1155 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1156 0f1cfa7f 2019-08-08 stsp ret="$?"
1157 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1158 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1159 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1160 0f1cfa7f 2019-08-08 stsp return 1
1161 0f1cfa7f 2019-08-08 stsp fi
1162 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1163 0f1cfa7f 2019-08-08 stsp ret="$?"
1164 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1165 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1166 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1167 0f1cfa7f 2019-08-08 stsp return 1
1168 0f1cfa7f 2019-08-08 stsp fi
1169 0f1cfa7f 2019-08-08 stsp
1170 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout \
1171 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1172 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1173 0f1cfa7f 2019-08-08 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1174 0f1cfa7f 2019-08-08 stsp
1175 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1176 0f1cfa7f 2019-08-08 stsp ret="$?"
1177 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1178 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1179 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1180 0f1cfa7f 2019-08-08 stsp return 1
1181 0f1cfa7f 2019-08-08 stsp fi
1182 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1183 0f1cfa7f 2019-08-08 stsp ret="$?"
1184 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1185 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1186 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1187 0f1cfa7f 2019-08-08 stsp return 1
1188 0f1cfa7f 2019-08-08 stsp fi
1189 0f1cfa7f 2019-08-08 stsp
1190 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got unstage > /dev/null)
1191 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
1192 0f1cfa7f 2019-08-08 stsp ret="$?"
1193 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1194 0f1cfa7f 2019-08-08 stsp echo "got update command failed unexpectedly" >&2
1195 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1196 0f1cfa7f 2019-08-08 stsp return 1
1197 0f1cfa7f 2019-08-08 stsp fi
1198 0f1cfa7f 2019-08-08 stsp
1199 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1200 0f1cfa7f 2019-08-08 stsp echo "C alpha" > $testroot/stdout.expected
1201 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1202 0f1cfa7f 2019-08-08 stsp echo "A foo" >> $testroot/stdout.expected
1203 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1204 0f1cfa7f 2019-08-08 stsp ret="$?"
1205 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1206 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1207 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1208 0f1cfa7f 2019-08-08 stsp return 1
1209 0f1cfa7f 2019-08-08 stsp fi
1210 0f1cfa7f 2019-08-08 stsp
1211 0f1cfa7f 2019-08-08 stsp # resolve conflict
1212 0f1cfa7f 2019-08-08 stsp echo "resolved file" > $testroot/wt/alpha
1213 0f1cfa7f 2019-08-08 stsp
1214 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
1215 0f1cfa7f 2019-08-08 stsp
1216 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1217 0f1cfa7f 2019-08-08 stsp ret="$?"
1218 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1219 0f1cfa7f 2019-08-08 stsp echo "got commit command failed unexpectedly" >&2
1220 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1221 0f1cfa7f 2019-08-08 stsp return 1
1222 0f1cfa7f 2019-08-08 stsp fi
1223 0f1cfa7f 2019-08-08 stsp
1224 0f1cfa7f 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1225 0f1cfa7f 2019-08-08 stsp echo "A foo" > $testroot/stdout.expected
1226 0f1cfa7f 2019-08-08 stsp echo "M alpha" >> $testroot/stdout.expected
1227 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1228 0f1cfa7f 2019-08-08 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1229 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1230 0f1cfa7f 2019-08-08 stsp ret="$?"
1231 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1232 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1233 0f1cfa7f 2019-08-08 stsp fi
1234 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1235 0f1cfa7f 2019-08-08 stsp
1236 0f1cfa7f 2019-08-08 stsp }
1237 0f1cfa7f 2019-08-08 stsp
1238 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1239 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1240 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1241 5f8a88c6 2019-08-03 stsp
1242 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1243 5f8a88c6 2019-08-03 stsp ret="$?"
1244 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1245 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1246 5f8a88c6 2019-08-03 stsp return 1
1247 5f8a88c6 2019-08-03 stsp fi
1248 5f8a88c6 2019-08-03 stsp
1249 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1250 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1251 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1252 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1253 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1254 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1255 5f8a88c6 2019-08-03 stsp
1256 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1257 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1258 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1259 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1260 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1261 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1262 5f8a88c6 2019-08-03 stsp
1263 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1264 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1265 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1266 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1267 5f8a88c6 2019-08-03 stsp
1268 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1269 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1270 5f8a88c6 2019-08-03 stsp ret="$?"
1271 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1272 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1273 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1274 5f8a88c6 2019-08-03 stsp return 1
1275 5f8a88c6 2019-08-03 stsp fi
1276 5f8a88c6 2019-08-03 stsp
1277 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1278 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1279 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1280 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1281 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1282 5f8a88c6 2019-08-03 stsp
1283 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1284 5f8a88c6 2019-08-03 stsp ret="$?"
1285 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1286 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1287 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1288 f0b75401 2019-08-03 stsp return 1
1289 f0b75401 2019-08-03 stsp fi
1290 5f8a88c6 2019-08-03 stsp
1291 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1292 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1293 5f8a88c6 2019-08-03 stsp
1294 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1295 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1296 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1297 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1298 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1299 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1300 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1301 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1302 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1303 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1304 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1305 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1306 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1307 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1308 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1309 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1310 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1311 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1312 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1313 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1314 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1315 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1316 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1317 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1318 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1319 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1320 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1321 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1322 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1323 5f8a88c6 2019-08-03 stsp
1324 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1325 f0b75401 2019-08-03 stsp ret="$?"
1326 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1327 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1328 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1329 5f8a88c6 2019-08-03 stsp return 1
1330 f0b75401 2019-08-03 stsp fi
1331 5f8a88c6 2019-08-03 stsp
1332 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1333 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1334 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1335 5f8a88c6 2019-08-03 stsp
1336 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1337 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1338 5f8a88c6 2019-08-03 stsp ret="$?"
1339 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1340 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1341 5f8a88c6 2019-08-03 stsp fi
1342 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1343 f0b75401 2019-08-03 stsp }
1344 dc424a06 2019-08-07 stsp
1345 dc424a06 2019-08-07 stsp function test_stage_patch {
1346 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1347 dc424a06 2019-08-07 stsp
1348 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1349 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1350 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1351 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1352 dc424a06 2019-08-07 stsp
1353 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1354 dc424a06 2019-08-07 stsp ret="$?"
1355 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1356 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1357 dc424a06 2019-08-07 stsp return 1
1358 dc424a06 2019-08-07 stsp fi
1359 dc424a06 2019-08-07 stsp
1360 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1361 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1362 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1363 dc424a06 2019-08-07 stsp
1364 dc424a06 2019-08-07 stsp # don't stage any hunks
1365 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1366 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1367 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1368 dc424a06 2019-08-07 stsp ret="$?"
1369 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1370 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1371 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1372 dc424a06 2019-08-07 stsp return 1
1373 dc424a06 2019-08-07 stsp fi
1374 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1375 dc424a06 2019-08-07 stsp -----------------------------------------------
1376 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1377 dc424a06 2019-08-07 stsp 1
1378 dc424a06 2019-08-07 stsp -2
1379 dc424a06 2019-08-07 stsp +a
1380 dc424a06 2019-08-07 stsp 3
1381 dc424a06 2019-08-07 stsp 4
1382 dc424a06 2019-08-07 stsp 5
1383 dc424a06 2019-08-07 stsp -----------------------------------------------
1384 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1385 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1386 dc424a06 2019-08-07 stsp -----------------------------------------------
1387 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1388 dc424a06 2019-08-07 stsp 4
1389 dc424a06 2019-08-07 stsp 5
1390 dc424a06 2019-08-07 stsp 6
1391 dc424a06 2019-08-07 stsp -7
1392 dc424a06 2019-08-07 stsp +b
1393 dc424a06 2019-08-07 stsp 8
1394 dc424a06 2019-08-07 stsp 9
1395 dc424a06 2019-08-07 stsp 10
1396 dc424a06 2019-08-07 stsp -----------------------------------------------
1397 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1398 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1399 dc424a06 2019-08-07 stsp -----------------------------------------------
1400 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1401 dc424a06 2019-08-07 stsp 13
1402 dc424a06 2019-08-07 stsp 14
1403 dc424a06 2019-08-07 stsp 15
1404 dc424a06 2019-08-07 stsp -16
1405 dc424a06 2019-08-07 stsp +c
1406 dc424a06 2019-08-07 stsp -----------------------------------------------
1407 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1408 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1409 dc424a06 2019-08-07 stsp EOF
1410 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1411 dc424a06 2019-08-07 stsp ret="$?"
1412 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1413 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1414 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1415 dc424a06 2019-08-07 stsp return 1
1416 dc424a06 2019-08-07 stsp fi
1417 f0b75401 2019-08-03 stsp
1418 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1419 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1420 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1421 dc424a06 2019-08-07 stsp ret="$?"
1422 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1423 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1424 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1425 dc424a06 2019-08-07 stsp return 1
1426 dc424a06 2019-08-07 stsp fi
1427 dc424a06 2019-08-07 stsp
1428 dc424a06 2019-08-07 stsp # stage middle hunk
1429 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1430 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1431 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1432 dc424a06 2019-08-07 stsp
1433 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1434 dc424a06 2019-08-07 stsp -----------------------------------------------
1435 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1436 dc424a06 2019-08-07 stsp 1
1437 dc424a06 2019-08-07 stsp -2
1438 dc424a06 2019-08-07 stsp +a
1439 dc424a06 2019-08-07 stsp 3
1440 dc424a06 2019-08-07 stsp 4
1441 dc424a06 2019-08-07 stsp 5
1442 dc424a06 2019-08-07 stsp -----------------------------------------------
1443 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1444 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1445 dc424a06 2019-08-07 stsp -----------------------------------------------
1446 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1447 dc424a06 2019-08-07 stsp 4
1448 dc424a06 2019-08-07 stsp 5
1449 dc424a06 2019-08-07 stsp 6
1450 dc424a06 2019-08-07 stsp -7
1451 dc424a06 2019-08-07 stsp +b
1452 dc424a06 2019-08-07 stsp 8
1453 dc424a06 2019-08-07 stsp 9
1454 dc424a06 2019-08-07 stsp 10
1455 dc424a06 2019-08-07 stsp -----------------------------------------------
1456 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1457 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1458 dc424a06 2019-08-07 stsp -----------------------------------------------
1459 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1460 dc424a06 2019-08-07 stsp 13
1461 dc424a06 2019-08-07 stsp 14
1462 dc424a06 2019-08-07 stsp 15
1463 dc424a06 2019-08-07 stsp -16
1464 dc424a06 2019-08-07 stsp +c
1465 dc424a06 2019-08-07 stsp -----------------------------------------------
1466 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1467 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1468 dc424a06 2019-08-07 stsp EOF
1469 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1470 dc424a06 2019-08-07 stsp ret="$?"
1471 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1472 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1473 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1474 dc424a06 2019-08-07 stsp return 1
1475 dc424a06 2019-08-07 stsp fi
1476 dc424a06 2019-08-07 stsp
1477 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1478 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1479 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1480 dc424a06 2019-08-07 stsp ret="$?"
1481 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1482 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1483 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1484 dc424a06 2019-08-07 stsp return 1
1485 dc424a06 2019-08-07 stsp fi
1486 dc424a06 2019-08-07 stsp
1487 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1488 dc424a06 2019-08-07 stsp
1489 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1490 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1491 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1492 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1493 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1494 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1495 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1496 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1497 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1498 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1499 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1500 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1501 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1502 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1503 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1504 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1505 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1506 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1507 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1508 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1509 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1510 dc424a06 2019-08-07 stsp ret="$?"
1511 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1512 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1513 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1514 dc424a06 2019-08-07 stsp return 1
1515 dc424a06 2019-08-07 stsp fi
1516 dc424a06 2019-08-07 stsp
1517 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1518 dc424a06 2019-08-07 stsp ret="$?"
1519 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1520 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1521 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1522 dc424a06 2019-08-07 stsp return 1
1523 dc424a06 2019-08-07 stsp fi
1524 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1525 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1526 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1527 dc424a06 2019-08-07 stsp ret="$?"
1528 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1529 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1530 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1531 dc424a06 2019-08-07 stsp return 1
1532 dc424a06 2019-08-07 stsp fi
1533 dc424a06 2019-08-07 stsp
1534 dc424a06 2019-08-07 stsp # stage last hunk
1535 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1536 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1537 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1538 dc424a06 2019-08-07 stsp
1539 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1540 dc424a06 2019-08-07 stsp -----------------------------------------------
1541 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1542 dc424a06 2019-08-07 stsp 1
1543 dc424a06 2019-08-07 stsp -2
1544 dc424a06 2019-08-07 stsp +a
1545 dc424a06 2019-08-07 stsp 3
1546 dc424a06 2019-08-07 stsp 4
1547 dc424a06 2019-08-07 stsp 5
1548 dc424a06 2019-08-07 stsp -----------------------------------------------
1549 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1550 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1551 dc424a06 2019-08-07 stsp -----------------------------------------------
1552 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1553 dc424a06 2019-08-07 stsp 4
1554 dc424a06 2019-08-07 stsp 5
1555 dc424a06 2019-08-07 stsp 6
1556 dc424a06 2019-08-07 stsp -7
1557 dc424a06 2019-08-07 stsp +b
1558 dc424a06 2019-08-07 stsp 8
1559 dc424a06 2019-08-07 stsp 9
1560 dc424a06 2019-08-07 stsp 10
1561 dc424a06 2019-08-07 stsp -----------------------------------------------
1562 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1563 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1564 dc424a06 2019-08-07 stsp -----------------------------------------------
1565 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1566 dc424a06 2019-08-07 stsp 13
1567 dc424a06 2019-08-07 stsp 14
1568 dc424a06 2019-08-07 stsp 15
1569 dc424a06 2019-08-07 stsp -16
1570 dc424a06 2019-08-07 stsp +c
1571 dc424a06 2019-08-07 stsp -----------------------------------------------
1572 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1573 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1574 dc424a06 2019-08-07 stsp EOF
1575 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1576 dc424a06 2019-08-07 stsp ret="$?"
1577 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1578 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1579 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1580 dc424a06 2019-08-07 stsp return 1
1581 dc424a06 2019-08-07 stsp fi
1582 dc424a06 2019-08-07 stsp
1583 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1584 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1585 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1586 dc424a06 2019-08-07 stsp ret="$?"
1587 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1588 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1589 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1590 dc424a06 2019-08-07 stsp return 1
1591 dc424a06 2019-08-07 stsp fi
1592 dc424a06 2019-08-07 stsp
1593 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1594 dc424a06 2019-08-07 stsp
1595 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1596 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1597 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1598 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1599 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1600 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1601 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1602 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1603 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1604 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1605 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1606 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1607 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1608 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1609 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1610 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1611 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1612 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1613 dc424a06 2019-08-07 stsp ret="$?"
1614 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1615 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1616 dc424a06 2019-08-07 stsp fi
1617 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1618 dc424a06 2019-08-07 stsp }
1619 dc424a06 2019-08-07 stsp
1620 dc424a06 2019-08-07 stsp function test_stage_patch_added {
1621 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1622 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1623 dc424a06 2019-08-07 stsp
1624 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1625 dc424a06 2019-08-07 stsp ret="$?"
1626 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1627 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1628 dc424a06 2019-08-07 stsp return 1
1629 dc424a06 2019-08-07 stsp fi
1630 dc424a06 2019-08-07 stsp
1631 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1632 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1633 dc424a06 2019-08-07 stsp
1634 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1635 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1636 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1637 dc424a06 2019-08-07 stsp
1638 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1639 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1640 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1641 dc424a06 2019-08-07 stsp ret="$?"
1642 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1643 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1644 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1645 dc424a06 2019-08-07 stsp return 1
1646 dc424a06 2019-08-07 stsp fi
1647 dc424a06 2019-08-07 stsp
1648 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1649 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1650 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1651 dc424a06 2019-08-07 stsp ret="$?"
1652 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1653 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1654 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1655 dc424a06 2019-08-07 stsp return 1
1656 dc424a06 2019-08-07 stsp fi
1657 dc424a06 2019-08-07 stsp
1658 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1659 dc424a06 2019-08-07 stsp
1660 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1661 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1662 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1663 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1664 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1665 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1666 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1667 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1668 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1669 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1670 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1671 dc424a06 2019-08-07 stsp ret="$?"
1672 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1673 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1674 dc424a06 2019-08-07 stsp fi
1675 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1676 dc424a06 2019-08-07 stsp }
1677 dc424a06 2019-08-07 stsp
1678 dc424a06 2019-08-07 stsp function test_stage_patch_removed {
1679 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
1680 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1681 dc424a06 2019-08-07 stsp
1682 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1683 dc424a06 2019-08-07 stsp ret="$?"
1684 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1685 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1686 dc424a06 2019-08-07 stsp return 1
1687 dc424a06 2019-08-07 stsp fi
1688 dc424a06 2019-08-07 stsp
1689 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
1690 dc424a06 2019-08-07 stsp
1691 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1692 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1693 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
1694 dc424a06 2019-08-07 stsp
1695 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
1696 dc424a06 2019-08-07 stsp
1697 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
1698 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
1699 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1700 dc424a06 2019-08-07 stsp ret="$?"
1701 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1702 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1703 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1704 dc424a06 2019-08-07 stsp return 1
1705 dc424a06 2019-08-07 stsp fi
1706 dc424a06 2019-08-07 stsp
1707 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1708 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
1709 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1710 dc424a06 2019-08-07 stsp ret="$?"
1711 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1712 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1713 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1714 dc424a06 2019-08-07 stsp return 1
1715 dc424a06 2019-08-07 stsp fi
1716 dc424a06 2019-08-07 stsp
1717 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1718 dc424a06 2019-08-07 stsp
1719 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1720 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1721 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1722 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
1723 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1724 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1725 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
1726 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
1727 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
1728 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
1729 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1730 dc424a06 2019-08-07 stsp ret="$?"
1731 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1732 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1733 dc424a06 2019-08-07 stsp fi
1734 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1735 dc424a06 2019-08-07 stsp }
1736 b353a198 2019-08-07 stsp
1737 b353a198 2019-08-07 stsp function test_stage_patch_quit {
1738 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
1739 b353a198 2019-08-07 stsp
1740 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1741 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
1742 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
1743 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
1744 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1745 b353a198 2019-08-07 stsp
1746 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1747 b353a198 2019-08-07 stsp ret="$?"
1748 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1749 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1750 b353a198 2019-08-07 stsp return 1
1751 b353a198 2019-08-07 stsp fi
1752 dc424a06 2019-08-07 stsp
1753 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1754 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1755 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1756 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
1757 b353a198 2019-08-07 stsp
1758 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
1759 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
1760 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
1761 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1762 2db2652d 2019-08-07 stsp > $testroot/stdout)
1763 b353a198 2019-08-07 stsp ret="$?"
1764 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1765 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1766 b353a198 2019-08-07 stsp test_done "$testroot" "1"
1767 b353a198 2019-08-07 stsp return 1
1768 b353a198 2019-08-07 stsp fi
1769 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1770 b353a198 2019-08-07 stsp -----------------------------------------------
1771 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
1772 b353a198 2019-08-07 stsp 1
1773 b353a198 2019-08-07 stsp -2
1774 b353a198 2019-08-07 stsp +a
1775 b353a198 2019-08-07 stsp 3
1776 b353a198 2019-08-07 stsp 4
1777 b353a198 2019-08-07 stsp 5
1778 b353a198 2019-08-07 stsp -----------------------------------------------
1779 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1780 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1781 b353a198 2019-08-07 stsp -----------------------------------------------
1782 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
1783 b353a198 2019-08-07 stsp 4
1784 b353a198 2019-08-07 stsp 5
1785 b353a198 2019-08-07 stsp 6
1786 b353a198 2019-08-07 stsp -7
1787 b353a198 2019-08-07 stsp +b
1788 b353a198 2019-08-07 stsp 8
1789 b353a198 2019-08-07 stsp 9
1790 b353a198 2019-08-07 stsp 10
1791 b353a198 2019-08-07 stsp -----------------------------------------------
1792 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1793 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
1794 88f33a19 2019-08-08 stsp D zzz
1795 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
1796 b353a198 2019-08-07 stsp EOF
1797 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1798 b353a198 2019-08-07 stsp ret="$?"
1799 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1800 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1801 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1802 b353a198 2019-08-07 stsp return 1
1803 b353a198 2019-08-07 stsp fi
1804 b353a198 2019-08-07 stsp
1805 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1806 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1807 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
1808 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1809 b353a198 2019-08-07 stsp ret="$?"
1810 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1811 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1812 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1813 b353a198 2019-08-07 stsp return 1
1814 b353a198 2019-08-07 stsp fi
1815 b353a198 2019-08-07 stsp
1816 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1817 b353a198 2019-08-07 stsp
1818 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1819 b353a198 2019-08-07 stsp > $testroot/stdout.expected
1820 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1821 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1822 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1823 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1824 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1825 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1826 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1827 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1828 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1829 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
1830 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
1831 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
1832 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
1833 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
1834 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1835 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1836 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1837 b353a198 2019-08-07 stsp ret="$?"
1838 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1839 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1840 b353a198 2019-08-07 stsp fi
1841 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1842 b353a198 2019-08-07 stsp
1843 b353a198 2019-08-07 stsp }
1844 b353a198 2019-08-07 stsp
1845 eba70f38 2019-08-08 stsp function test_stage_patch_incomplete_script {
1846 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
1847 eba70f38 2019-08-08 stsp
1848 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1849 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
1850 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
1851 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
1852 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1853 eba70f38 2019-08-08 stsp
1854 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1855 eba70f38 2019-08-08 stsp ret="$?"
1856 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1857 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1858 eba70f38 2019-08-08 stsp return 1
1859 eba70f38 2019-08-08 stsp fi
1860 eba70f38 2019-08-08 stsp
1861 eba70f38 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1862 eba70f38 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1863 eba70f38 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1864 eba70f38 2019-08-08 stsp
1865 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
1866 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1867 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1868 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
1869 eba70f38 2019-08-08 stsp ret="$?"
1870 eba70f38 2019-08-08 stsp if [ "$ret" == "0" ]; then
1871 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
1872 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
1873 eba70f38 2019-08-08 stsp return 1
1874 eba70f38 2019-08-08 stsp fi
1875 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1876 eba70f38 2019-08-08 stsp -----------------------------------------------
1877 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
1878 eba70f38 2019-08-08 stsp 1
1879 eba70f38 2019-08-08 stsp -2
1880 eba70f38 2019-08-08 stsp +a
1881 eba70f38 2019-08-08 stsp 3
1882 eba70f38 2019-08-08 stsp 4
1883 eba70f38 2019-08-08 stsp 5
1884 eba70f38 2019-08-08 stsp -----------------------------------------------
1885 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
1886 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
1887 eba70f38 2019-08-08 stsp -----------------------------------------------
1888 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
1889 eba70f38 2019-08-08 stsp 4
1890 eba70f38 2019-08-08 stsp 5
1891 eba70f38 2019-08-08 stsp 6
1892 eba70f38 2019-08-08 stsp -7
1893 eba70f38 2019-08-08 stsp +b
1894 eba70f38 2019-08-08 stsp 8
1895 eba70f38 2019-08-08 stsp 9
1896 eba70f38 2019-08-08 stsp 10
1897 eba70f38 2019-08-08 stsp -----------------------------------------------
1898 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
1899 eba70f38 2019-08-08 stsp EOF
1900 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
1901 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
1902 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1903 eba70f38 2019-08-08 stsp ret="$?"
1904 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1905 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1906 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1907 eba70f38 2019-08-08 stsp return 1
1908 eba70f38 2019-08-08 stsp fi
1909 eba70f38 2019-08-08 stsp
1910 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1911 eba70f38 2019-08-08 stsp ret="$?"
1912 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1913 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1914 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1915 eba70f38 2019-08-08 stsp return 1
1916 eba70f38 2019-08-08 stsp fi
1917 eba70f38 2019-08-08 stsp
1918 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1919 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
1920 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1921 eba70f38 2019-08-08 stsp ret="$?"
1922 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1923 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1924 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1925 eba70f38 2019-08-08 stsp return 1
1926 eba70f38 2019-08-08 stsp fi
1927 eba70f38 2019-08-08 stsp
1928 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1929 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
1930 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1931 eba70f38 2019-08-08 stsp ret="$?"
1932 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1933 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1934 eba70f38 2019-08-08 stsp fi
1935 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1936 eba70f38 2019-08-08 stsp
1937 eba70f38 2019-08-08 stsp }
1938 eba70f38 2019-08-08 stsp
1939 fccbfb98 2019-08-03 stsp run_test test_stage_basic
1940 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
1941 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
1942 8564cb21 2019-08-08 stsp run_test test_stage_nonexistent
1943 a4f692bb 2019-08-04 stsp run_test test_stage_list
1944 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
1945 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
1946 d3e7c587 2019-08-03 stsp run_test test_double_stage
1947 c363b2c1 2019-08-03 stsp run_test test_stage_status
1948 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
1949 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
1950 24278f30 2019-08-03 stsp run_test test_stage_revert
1951 408b4ebc 2019-08-03 stsp run_test test_stage_diff
1952 b9622844 2019-08-03 stsp run_test test_stage_histedit
1953 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
1954 a76c42e6 2019-08-03 stsp run_test test_stage_update
1955 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
1956 0f1cfa7f 2019-08-08 stsp run_test test_stage_commit_out_of_date
1957 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
1958 dc424a06 2019-08-07 stsp run_test test_stage_patch
1959 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
1960 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
1961 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
1962 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script