3 fccbfb98 2019-08-03 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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.
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.
17 fccbfb98 2019-08-03 stsp . ./common.sh
19 fccbfb98 2019-08-03 stsp function test_stage_basic {
20 fccbfb98 2019-08-03 stsp local testroot=`test_init stage_basic`
22 fccbfb98 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
25 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
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)
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)
39 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
41 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
42 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
44 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
47 31b20a6e 2019-08-06 stsp function test_stage_no_changes {
48 31b20a6e 2019-08-06 stsp local testroot=`test_init stage_no_changes`
50 31b20a6e 2019-08-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
52 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
53 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
57 31b20a6e 2019-08-06 stsp (cd $testroot/wt && got stage alpha beta > $testroot/stdout \
58 31b20a6e 2019-08-06 stsp 2> $testroot/stderr)
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"
66 2db2652d 2019-08-07 stsp echo "got: no changes to stage" > $testroot/stderr.expected
68 31b20a6e 2019-08-06 stsp cmp -s $testroot/stderr.expected $testroot/stderr
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"
76 31b20a6e 2019-08-06 stsp echo -n > $testroot/stdout.expected
77 31b20a6e 2019-08-06 stsp cmp -s $testroot/stdout.expected $testroot/stdout
79 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
80 31b20a6e 2019-08-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
82 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
85 8b13ce36 2019-08-08 stsp function test_stage_unversioned {
86 8b13ce36 2019-08-08 stsp local testroot=`test_init stage_unversioned`
88 8b13ce36 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
90 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
91 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
95 8b13ce36 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
96 8b13ce36 2019-08-08 stsp touch $testroot/wt/unversioned-file
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
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"
109 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage > $testroot/stdout)
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"
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
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"
126 8b13ce36 2019-08-08 stsp echo "modified file again" > $testroot/wt/alpha
128 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage unversioned-file > $testroot/stdout \
129 8b13ce36 2019-08-08 stsp 2> $testroot/stderr)
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"
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
140 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
141 8b13ce36 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
143 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
147 8564cb21 2019-08-08 stsp function test_stage_nonexistent {
148 8564cb21 2019-08-08 stsp local testroot=`test_init stage_nonexistent`
150 8564cb21 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
152 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
153 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
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 2a06fe5f 2019-08-24 stsp echo "got: nonexistent-file: No such file or directory" \
160 2a06fe5f 2019-08-24 stsp > $testroot/stderr.expected
161 8564cb21 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
163 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
164 8564cb21 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
166 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
169 a4f692bb 2019-08-04 stsp function test_stage_list {
170 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
172 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
174 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
175 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
179 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
180 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
181 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
182 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
184 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
185 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
186 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
187 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
189 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
190 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
191 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
192 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
193 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
194 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
195 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
196 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
197 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
198 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
199 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
201 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
202 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
203 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
207 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
208 a4f692bb 2019-08-04 stsp > $testroot/stdout)
210 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
211 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
213 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
214 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
215 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
219 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
221 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
222 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
223 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
224 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
226 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
227 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
229 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
233 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
234 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
235 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
237 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
239 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
240 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
244 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
245 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
247 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
249 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
251 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
252 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
253 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
254 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
256 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
258 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
260 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
261 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
262 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
266 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
267 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
269 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
270 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
271 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
275 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
276 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
277 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
279 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
281 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
282 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
283 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
286 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
288 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
289 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
291 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
294 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
295 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
296 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
298 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
300 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
301 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
305 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
306 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
308 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
310 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
311 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
312 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
314 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
315 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
316 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
320 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
321 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
322 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
324 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
326 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
327 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
331 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
333 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
334 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
336 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
340 d3e7c587 2019-08-03 stsp function test_double_stage {
341 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
343 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
345 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
346 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
349 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
350 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
351 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
352 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
353 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
355 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
356 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
357 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
359 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
360 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
361 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
365 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
367 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
368 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
369 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
372 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
373 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
375 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
376 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
377 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
381 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
382 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
383 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
385 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
386 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
387 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
391 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
392 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
394 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
395 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
396 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
397 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
399 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
400 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
401 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
405 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
406 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
407 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
409 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
410 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
412 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
413 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
415 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
418 c363b2c1 2019-08-03 stsp function test_stage_status {
419 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
421 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
423 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
424 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
428 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
429 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
430 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
431 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
432 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
433 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
434 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
435 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
437 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
438 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
439 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
440 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
441 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
442 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
443 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
445 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
446 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
448 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
449 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
450 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
454 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
455 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
457 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
458 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
459 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
460 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
461 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
462 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
464 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
465 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
467 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
468 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
469 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
473 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
474 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
475 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
476 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
477 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
479 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
480 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
481 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
485 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
486 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
487 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
488 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
489 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
491 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
492 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
494 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
498 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
499 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
501 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
503 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
504 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
508 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
509 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
510 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
511 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
513 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
515 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
516 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
517 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
518 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
519 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
520 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
521 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
523 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
524 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
525 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
528 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
530 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
531 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
532 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
537 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
538 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
539 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
541 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
542 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
544 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
545 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
547 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
550 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
551 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
553 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
555 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
556 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
560 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
561 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
562 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
563 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
565 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
567 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
568 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
570 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
571 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
572 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
575 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
576 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
578 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
579 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
580 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
583 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
584 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
586 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
587 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
588 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
592 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
593 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
594 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
595 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
597 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
598 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
599 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
602 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
604 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
605 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
606 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
611 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
612 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
613 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
615 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
616 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
618 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
619 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
621 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
624 24278f30 2019-08-03 stsp function test_stage_revert {
625 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
627 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
629 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
630 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
634 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
635 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
636 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
637 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
638 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
640 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
641 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
643 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
645 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
646 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
647 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
651 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
652 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
654 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
655 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
656 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
660 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
661 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
662 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
664 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
665 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
666 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
670 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
671 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
672 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
673 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
674 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
676 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
677 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
678 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
682 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
684 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
685 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
686 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
690 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
691 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
693 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
694 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
695 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
699 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
700 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
701 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
703 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
704 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
705 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
709 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
710 24278f30 2019-08-03 stsp 2> $testroot/stderr)
712 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
713 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
714 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
718 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stdout.expected
719 d3bcc3d1 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
721 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
722 d3bcc3d1 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
723 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
727 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
728 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
730 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
731 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
732 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
736 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
738 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
739 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
740 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
744 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
745 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
747 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
748 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
749 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
753 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
754 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
755 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
757 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
758 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
759 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
763 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
764 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
765 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
766 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
767 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
769 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
770 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
771 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
775 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
777 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
778 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
779 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
783 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
784 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
786 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
787 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
788 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
792 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
793 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
794 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
796 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
797 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
798 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
802 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
803 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
804 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
805 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
806 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
808 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
809 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
810 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
814 0f6d7415 2019-08-08 stsp echo "modified file again" >> $testroot/wt/alpha
815 0f6d7415 2019-08-08 stsp echo "modified added file again" >> $testroot/wt/foo
817 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout \
818 0f6d7415 2019-08-08 stsp 2> $testroot/stderr)
820 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
821 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
822 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
826 0f6d7415 2019-08-08 stsp echo "R alpha" > $testroot/stdout.expected
827 d3bcc3d1 2019-08-08 stsp echo "R foo" >> $testroot/stdout.expected
828 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
830 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
831 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
832 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
836 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
837 0f6d7415 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
839 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
840 0f6d7415 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
841 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
845 0f6d7415 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
846 0f6d7415 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
847 d3bcc3d1 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
848 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
849 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
851 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
852 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
854 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
857 408b4ebc 2019-08-03 stsp function test_stage_diff {
858 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
859 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
861 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
863 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
864 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
868 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
869 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
870 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
871 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
873 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
874 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
875 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
877 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
878 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
879 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
883 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
884 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
885 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
886 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
888 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
889 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
890 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
892 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
893 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
894 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
898 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
899 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
901 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
903 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
904 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
905 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
906 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
907 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
908 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
909 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
910 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
911 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
912 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
913 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
914 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
915 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
916 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
917 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
918 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
919 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
920 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
921 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
922 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
923 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
925 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
927 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
928 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
929 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
933 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
935 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
936 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
937 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
938 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
939 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
940 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
941 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
942 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
943 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
944 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
945 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
946 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
947 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
948 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
949 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
950 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
951 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
952 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
953 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
954 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
955 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
956 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
957 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
958 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
959 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
960 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
961 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
962 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
963 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
965 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
967 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
968 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
970 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
974 b9622844 2019-08-03 stsp function test_stage_histedit {
975 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
976 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
978 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
980 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
981 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
985 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
986 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
988 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
989 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
990 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
991 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
992 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
993 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
995 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
996 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
997 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
999 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
1000 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1002 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1003 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1005 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
1006 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
1007 b9622844 2019-08-03 stsp test_done "$testroot" "1"
1011 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
1012 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1014 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1016 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1017 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1018 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1021 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1023 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1024 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1026 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1030 243d7cf1 2019-08-03 stsp function test_stage_rebase {
1031 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
1033 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1034 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1035 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1037 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1038 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1039 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1040 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1041 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1043 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1044 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
1046 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
1047 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1048 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1049 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
1051 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1053 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1054 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1058 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1059 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1061 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
1062 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1064 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
1065 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
1066 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
1070 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
1071 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1073 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1075 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1076 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1077 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1080 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1082 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1083 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1085 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1088 a76c42e6 2019-08-03 stsp function test_stage_update {
1089 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1091 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1093 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1094 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1098 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1099 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1101 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1102 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1104 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1105 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1107 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
1108 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1109 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1113 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1114 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1116 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1118 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1119 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1120 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1123 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1125 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1126 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1128 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1131 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
1132 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1134 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1136 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1137 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1141 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1142 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1143 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1144 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1145 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1147 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1148 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1149 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1151 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
1152 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1153 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1157 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1158 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1160 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1162 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1163 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1164 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1167 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1169 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1170 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1172 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1175 0f1cfa7f 2019-08-08 stsp function test_stage_commit_out_of_date {
1176 0f1cfa7f 2019-08-08 stsp local testroot=`test_init stage_commit_out_of_date`
1178 0f1cfa7f 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1180 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1181 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1185 0f1cfa7f 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
1186 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
1187 0f1cfa7f 2019-08-08 stsp echo "new file" > $testroot/wt/foo
1188 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
1189 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1191 0f1cfa7f 2019-08-08 stsp echo "changed file" > $testroot/repo/alpha
1192 0f1cfa7f 2019-08-08 stsp git_commit $testroot/repo -m "changed alpha in repo"
1194 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1195 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1197 0f1cfa7f 2019-08-08 stsp if [ "$ret" == "0" ]; then
1198 0f1cfa7f 2019-08-08 stsp echo "got commit command succeeded unexpectedly" >&2
1199 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "1"
1203 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1204 0f1cfa7f 2019-08-08 stsp echo -n "got: work tree must be updated before these changes " \
1205 0f1cfa7f 2019-08-08 stsp > $testroot/stderr.expected
1206 0f1cfa7f 2019-08-08 stsp echo "can be committed" >> $testroot/stderr.expected
1208 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1210 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1211 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1212 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1215 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1217 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1218 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1219 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1223 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout \
1224 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1225 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1226 0f1cfa7f 2019-08-08 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1228 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1230 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1231 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1232 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1235 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1237 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1238 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1239 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1243 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got unstage > /dev/null)
1244 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
1246 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1247 0f1cfa7f 2019-08-08 stsp echo "got update command failed unexpectedly" >&2
1248 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1252 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1253 0f1cfa7f 2019-08-08 stsp echo "C alpha" > $testroot/stdout.expected
1254 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1255 0f1cfa7f 2019-08-08 stsp echo "A foo" >> $testroot/stdout.expected
1256 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1258 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1259 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1260 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1264 0f1cfa7f 2019-08-08 stsp # resolve conflict
1265 0f1cfa7f 2019-08-08 stsp echo "resolved file" > $testroot/wt/alpha
1267 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
1269 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1271 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1272 0f1cfa7f 2019-08-08 stsp echo "got commit command failed unexpectedly" >&2
1273 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1277 0f1cfa7f 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1278 0f1cfa7f 2019-08-08 stsp echo "A foo" > $testroot/stdout.expected
1279 0f1cfa7f 2019-08-08 stsp echo "M alpha" >> $testroot/stdout.expected
1280 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1281 0f1cfa7f 2019-08-08 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1282 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1284 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1285 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1287 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1291 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1292 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1293 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1295 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1297 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1298 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1302 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1303 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1304 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1305 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1306 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1307 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1309 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1310 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1311 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1312 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1313 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1314 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1316 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1317 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1318 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1319 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1321 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1322 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1324 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1325 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1326 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1330 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1331 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1332 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1333 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1334 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1336 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1338 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1339 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1340 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1344 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1345 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1347 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1348 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1349 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1350 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1351 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1352 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1353 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1354 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1355 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1356 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1357 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1358 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1359 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1360 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1361 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1362 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1363 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1364 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1365 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1366 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1367 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1368 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1369 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1370 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1371 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1372 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1373 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1374 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1375 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1377 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1379 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1380 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1381 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1385 72fd46fa 2019-09-06 stsp echo 'M alpha' > $testroot/stdout.expected
1386 72fd46fa 2019-09-06 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
1387 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1388 72fd46fa 2019-09-06 stsp echo 'M foo' >> $testroot/stdout.expected
1389 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1391 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1392 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1394 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1395 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1397 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1400 dc424a06 2019-08-07 stsp function test_stage_patch {
1401 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1403 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1404 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1405 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1406 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1408 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1410 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1411 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1415 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1416 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1417 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1419 dc424a06 2019-08-07 stsp # don't stage any hunks
1420 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1421 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1422 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1424 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1425 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1426 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1429 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1430 dc424a06 2019-08-07 stsp -----------------------------------------------
1431 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1438 dc424a06 2019-08-07 stsp -----------------------------------------------
1439 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1440 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1441 dc424a06 2019-08-07 stsp -----------------------------------------------
1442 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1451 dc424a06 2019-08-07 stsp -----------------------------------------------
1452 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1453 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1454 dc424a06 2019-08-07 stsp -----------------------------------------------
1455 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1461 dc424a06 2019-08-07 stsp -----------------------------------------------
1462 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1463 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1465 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1467 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1468 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1469 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1473 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1474 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1475 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1477 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1478 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1479 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1483 dc424a06 2019-08-07 stsp # stage middle hunk
1484 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1485 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1486 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1488 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1489 dc424a06 2019-08-07 stsp -----------------------------------------------
1490 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1497 dc424a06 2019-08-07 stsp -----------------------------------------------
1498 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1499 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1500 dc424a06 2019-08-07 stsp -----------------------------------------------
1501 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1510 dc424a06 2019-08-07 stsp -----------------------------------------------
1511 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1512 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1513 dc424a06 2019-08-07 stsp -----------------------------------------------
1514 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1520 dc424a06 2019-08-07 stsp -----------------------------------------------
1521 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1522 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1524 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1526 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1527 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1528 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1532 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1533 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1534 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1536 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1537 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1538 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1542 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1544 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1545 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1546 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1547 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1548 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1549 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1550 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1551 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1552 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1553 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1554 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1555 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1556 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1557 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1558 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1559 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1560 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1561 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1562 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1563 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1564 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1566 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1567 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1568 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1572 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1574 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1575 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1576 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1579 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1580 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1581 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1583 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1584 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1585 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1589 dc424a06 2019-08-07 stsp # stage last hunk
1590 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1591 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1592 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1594 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1595 dc424a06 2019-08-07 stsp -----------------------------------------------
1596 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1603 dc424a06 2019-08-07 stsp -----------------------------------------------
1604 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1605 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1606 dc424a06 2019-08-07 stsp -----------------------------------------------
1607 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1616 dc424a06 2019-08-07 stsp -----------------------------------------------
1617 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1618 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1619 dc424a06 2019-08-07 stsp -----------------------------------------------
1620 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1626 dc424a06 2019-08-07 stsp -----------------------------------------------
1627 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1628 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1630 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1632 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1633 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1634 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1638 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1639 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1640 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
1648 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1650 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1651 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1652 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1653 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1654 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1655 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1656 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1657 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1658 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1659 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1660 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1661 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1662 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1663 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1664 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1665 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1666 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1667 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1669 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1670 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1672 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1675 af5a81b2 2019-08-08 stsp function test_stage_patch_twice {
1676 af5a81b2 2019-08-08 stsp local testroot=`test_init stage_patch_twice`
1678 af5a81b2 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1679 af5a81b2 2019-08-08 stsp (cd $testroot/repo && git add numbers)
1680 af5a81b2 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
1681 af5a81b2 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1683 af5a81b2 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1685 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1686 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1690 af5a81b2 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1691 af5a81b2 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1692 af5a81b2 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1694 af5a81b2 2019-08-08 stsp # stage middle hunk
1695 af5a81b2 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
1696 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1697 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1699 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1700 af5a81b2 2019-08-08 stsp -----------------------------------------------
1701 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1708 af5a81b2 2019-08-08 stsp -----------------------------------------------
1709 af5a81b2 2019-08-08 stsp M numbers (change 1 of 3)
1710 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1711 af5a81b2 2019-08-08 stsp -----------------------------------------------
1712 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1721 af5a81b2 2019-08-08 stsp -----------------------------------------------
1722 af5a81b2 2019-08-08 stsp M numbers (change 2 of 3)
1723 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1724 af5a81b2 2019-08-08 stsp -----------------------------------------------
1725 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1731 af5a81b2 2019-08-08 stsp -----------------------------------------------
1732 af5a81b2 2019-08-08 stsp M numbers (change 3 of 3)
1733 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1735 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1737 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1738 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1739 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1743 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1744 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1745 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1747 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1748 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1749 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1753 af5a81b2 2019-08-08 stsp # stage last hunk
1754 af5a81b2 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
1755 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1756 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1758 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1759 af5a81b2 2019-08-08 stsp -----------------------------------------------
1760 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@ b
1767 af5a81b2 2019-08-08 stsp -----------------------------------------------
1768 af5a81b2 2019-08-08 stsp M numbers (change 1 of 2)
1769 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1770 af5a81b2 2019-08-08 stsp -----------------------------------------------
1771 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@ b
1777 af5a81b2 2019-08-08 stsp -----------------------------------------------
1778 af5a81b2 2019-08-08 stsp M numbers (change 2 of 2)
1779 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1781 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1783 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1784 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1785 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1789 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1790 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1791 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1793 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1794 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1795 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1799 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1801 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1802 af5a81b2 2019-08-08 stsp > $testroot/stdout.expected
1803 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1804 af5a81b2 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
1805 af5a81b2 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1806 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1807 af5a81b2 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1808 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1809 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1810 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1811 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1812 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1813 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1822 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1829 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1831 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1832 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1833 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1837 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1839 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
1840 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1841 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
1842 af5a81b2 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
1843 af5a81b2 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
1844 af5a81b2 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
1845 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1846 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1847 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1848 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1856 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1858 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1859 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1861 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1864 dc424a06 2019-08-07 stsp function test_stage_patch_added {
1865 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1866 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1868 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1870 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1871 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1875 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1876 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1878 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1879 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1880 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1882 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1883 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1884 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1886 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1887 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1888 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1892 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1893 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1894 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1896 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1897 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1898 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1902 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1904 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1905 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1906 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1907 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1908 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1909 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1910 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1911 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1912 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1913 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1914 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1916 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1917 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1919 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1922 e70a841e 2019-08-08 stsp function test_stage_patch_added_twice {
1923 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_added_twice`
1924 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1926 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1928 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1929 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1933 e70a841e 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
1934 e70a841e 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1936 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1937 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1938 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout)
1940 e70a841e 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
1941 e70a841e 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1942 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1944 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1945 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1946 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1950 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1951 e70a841e 2019-08-08 stsp echo " A epsilon/new" > $testroot/stdout.expected
1952 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1954 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1955 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1956 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1960 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1961 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout 2> $testroot/stderr)
1963 e70a841e 2019-08-08 stsp if [ "$ret" == "0" ]; then
1964 e70a841e 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
1965 e70a841e 2019-08-08 stsp test_done "$testroot" "1"
1969 e70a841e 2019-08-08 stsp echo "got: epsilon/new: no changes to stage" > $testroot/stderr.expected
1970 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1972 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1973 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1974 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1978 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
1979 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1981 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1982 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1984 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1987 dc424a06 2019-08-07 stsp function test_stage_patch_removed {
1988 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
1989 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1991 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1993 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1994 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1998 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
2000 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
2001 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2002 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
2004 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
2006 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
2007 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2008 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2010 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2011 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2012 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2016 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2017 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
2018 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2020 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2021 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2022 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2026 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2028 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2029 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
2030 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2031 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
2032 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
2033 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2034 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
2035 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
2036 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
2037 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
2038 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2040 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2041 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2043 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2046 e70a841e 2019-08-08 stsp function test_stage_patch_removed_twice {
2047 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_removed_twice`
2048 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2050 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2052 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2053 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2057 e70a841e 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
2059 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2060 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2061 e70a841e 2019-08-08 stsp beta > $testroot/stdout)
2063 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2065 e70a841e 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
2066 e70a841e 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2067 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2069 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2070 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2071 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2075 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2076 e70a841e 2019-08-08 stsp echo " D beta" > $testroot/stdout.expected
2077 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2079 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2080 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2081 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2085 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p beta \
2086 e70a841e 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2088 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2089 e70a841e 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
2090 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2094 e70a841e 2019-08-08 stsp echo -n > $testroot/stderr.expected
2095 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2097 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2098 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2099 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2103 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2104 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2106 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2107 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2109 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2112 b353a198 2019-08-07 stsp function test_stage_patch_quit {
2113 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
2115 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
2116 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2117 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2118 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2119 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2121 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2123 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2124 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2128 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2129 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2130 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2131 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
2133 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
2134 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
2135 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
2136 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2137 2db2652d 2019-08-07 stsp > $testroot/stdout)
2139 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2140 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
2141 b353a198 2019-08-07 stsp test_done "$testroot" "1"
2144 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
2145 b353a198 2019-08-07 stsp -----------------------------------------------
2146 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
2153 b353a198 2019-08-07 stsp -----------------------------------------------
2154 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
2155 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
2156 b353a198 2019-08-07 stsp -----------------------------------------------
2157 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
2166 b353a198 2019-08-07 stsp -----------------------------------------------
2167 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
2168 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
2170 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
2172 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2174 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2175 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2176 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2180 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2181 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
2182 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
2183 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2185 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2186 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2187 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2191 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2193 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2194 b353a198 2019-08-07 stsp > $testroot/stdout.expected
2195 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2196 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
2197 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
2198 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2199 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2200 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
2201 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2202 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
2203 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
2204 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
2205 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
2206 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
2207 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
2208 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
2209 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
2210 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
2211 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2213 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2214 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2216 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2220 eba70f38 2019-08-08 stsp function test_stage_patch_incomplete_script {
2221 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
2223 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
2224 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2225 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2226 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2227 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2229 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2231 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2232 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2236 eba70f38 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2237 eba70f38 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2238 eba70f38 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2240 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
2241 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2242 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2243 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2245 eba70f38 2019-08-08 stsp if [ "$ret" == "0" ]; then
2246 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2247 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
2250 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
2251 eba70f38 2019-08-08 stsp -----------------------------------------------
2252 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
2259 eba70f38 2019-08-08 stsp -----------------------------------------------
2260 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
2261 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
2262 eba70f38 2019-08-08 stsp -----------------------------------------------
2263 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
2272 eba70f38 2019-08-08 stsp -----------------------------------------------
2273 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
2275 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
2276 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
2277 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2279 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2280 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2281 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2285 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2287 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2288 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2289 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2293 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2294 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
2295 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2297 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2298 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2299 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2303 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2304 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
2305 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2307 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2308 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2310 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2314 fccbfb98 2019-08-03 stsp run_test test_stage_basic
2315 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
2316 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
2317 8564cb21 2019-08-08 stsp run_test test_stage_nonexistent
2318 a4f692bb 2019-08-04 stsp run_test test_stage_list
2319 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
2320 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
2321 d3e7c587 2019-08-03 stsp run_test test_double_stage
2322 c363b2c1 2019-08-03 stsp run_test test_stage_status
2323 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
2324 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
2325 24278f30 2019-08-03 stsp run_test test_stage_revert
2326 408b4ebc 2019-08-03 stsp run_test test_stage_diff
2327 b9622844 2019-08-03 stsp run_test test_stage_histedit
2328 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
2329 a76c42e6 2019-08-03 stsp run_test test_stage_update
2330 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
2331 0f1cfa7f 2019-08-08 stsp run_test test_stage_commit_out_of_date
2332 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
2333 dc424a06 2019-08-07 stsp run_test test_stage_patch
2334 af5a81b2 2019-08-08 stsp run_test test_stage_patch_twice
2335 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
2336 e70a841e 2019-08-08 stsp run_test test_stage_patch_added_twice
2337 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
2338 e70a841e 2019-08-08 stsp run_test test_stage_patch_removed_twice
2339 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
2340 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script