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 8564cb21 2019-08-08 stsp echo "got: no changes to stage" > $testroot/stderr.expected
160 8564cb21 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
162 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
163 8564cb21 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
165 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
168 a4f692bb 2019-08-04 stsp function test_stage_list {
169 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
171 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
173 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
174 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
178 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
179 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
180 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
181 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
183 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
184 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
185 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
186 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
188 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
189 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
190 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
191 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
192 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
193 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
194 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
195 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
196 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
197 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
198 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
200 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
201 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
202 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
206 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
207 a4f692bb 2019-08-04 stsp > $testroot/stdout)
209 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
210 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
212 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
213 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
214 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
218 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
220 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
221 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
222 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
223 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
225 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
226 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
228 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
232 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
233 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
234 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
236 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
238 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
239 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
243 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
244 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
246 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
248 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
250 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
251 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
252 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
253 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
255 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
257 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
259 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
260 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
261 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
265 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
266 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
268 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
269 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
270 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
274 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
275 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
276 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
278 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
280 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
281 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
282 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
285 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
287 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
288 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
290 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
293 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
294 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
295 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
297 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
299 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
300 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
304 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
305 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
307 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
309 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
310 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
311 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
313 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
314 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
315 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
319 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
320 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
321 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
323 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
325 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
326 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
327 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
330 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
332 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
333 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
335 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
339 d3e7c587 2019-08-03 stsp function test_double_stage {
340 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
342 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
344 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
345 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
348 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
349 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
350 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
351 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
352 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
354 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
355 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
356 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
358 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
359 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
360 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
364 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
366 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
367 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
368 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
371 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
372 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
374 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
375 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
376 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
380 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
381 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
382 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
384 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
385 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
386 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
390 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
391 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
393 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
394 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
395 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
396 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
398 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
399 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
400 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
404 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
405 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
406 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
408 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
409 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
411 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
412 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
414 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
417 c363b2c1 2019-08-03 stsp function test_stage_status {
418 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
420 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
422 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
423 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
427 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
428 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
429 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
430 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
431 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
432 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
433 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
434 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
436 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
437 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
438 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
439 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
440 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
441 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
442 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
444 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
445 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
447 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
448 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
449 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
453 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
454 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
456 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
457 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
458 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
459 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
460 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
461 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
463 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
464 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
466 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
467 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
468 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
472 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
473 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
474 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
475 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
476 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
478 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
479 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
480 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
484 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
485 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
486 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
487 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
488 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
490 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
491 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
493 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
497 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
498 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
500 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
502 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
503 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
507 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
508 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
509 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
510 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
512 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
514 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
515 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
516 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
517 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
518 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
519 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
520 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
522 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
523 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
524 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
527 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
529 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
530 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
531 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
536 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
537 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
538 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
540 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
541 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
543 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
544 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
546 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
549 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
550 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
552 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
554 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
555 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
559 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
560 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
561 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
562 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
564 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
566 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
567 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
569 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
570 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
571 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
574 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
575 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
577 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
578 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
579 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
582 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
583 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
585 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
586 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
587 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
591 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
592 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
593 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
594 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
596 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
597 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
598 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
601 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
603 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
604 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
605 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
610 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
611 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
612 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
614 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
615 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
617 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
618 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
620 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
623 24278f30 2019-08-03 stsp function test_stage_revert {
624 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
626 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
628 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
629 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
633 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
634 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
635 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
636 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
637 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
639 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
640 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
642 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
644 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
645 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
646 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
650 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
651 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
653 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
654 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
655 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
659 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
660 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
661 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
663 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
664 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
665 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
669 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
670 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
671 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
672 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
673 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
675 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
676 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
677 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
681 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
683 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
684 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
685 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
689 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
690 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
692 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
693 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
694 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
698 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
699 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
700 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
702 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
703 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
704 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
708 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
709 24278f30 2019-08-03 stsp 2> $testroot/stderr)
711 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
712 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
713 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
717 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stdout.expected
718 d3bcc3d1 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
720 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
721 d3bcc3d1 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
722 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
726 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
727 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
729 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
730 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
731 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
735 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
737 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
738 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
739 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
743 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
744 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
746 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
747 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
748 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
752 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
753 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
754 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
756 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
757 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
758 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
762 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
763 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
764 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
765 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
766 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
768 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
769 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
770 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
774 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
776 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
777 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
778 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
782 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
783 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
785 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
786 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
787 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
791 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
792 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
793 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
795 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
796 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
797 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
801 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
802 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
803 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
804 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
805 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
807 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
808 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
809 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
813 0f6d7415 2019-08-08 stsp echo "modified file again" >> $testroot/wt/alpha
814 0f6d7415 2019-08-08 stsp echo "modified added file again" >> $testroot/wt/foo
816 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout \
817 0f6d7415 2019-08-08 stsp 2> $testroot/stderr)
819 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
820 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
821 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
825 0f6d7415 2019-08-08 stsp echo "R alpha" > $testroot/stdout.expected
826 d3bcc3d1 2019-08-08 stsp echo "R foo" >> $testroot/stdout.expected
827 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
829 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
830 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
831 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
835 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
836 0f6d7415 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
838 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
839 0f6d7415 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
840 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
844 0f6d7415 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
845 0f6d7415 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
846 d3bcc3d1 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
847 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
848 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
850 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
851 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
853 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
856 408b4ebc 2019-08-03 stsp function test_stage_diff {
857 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
858 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
860 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
862 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
863 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
867 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
868 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
869 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
870 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
872 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
873 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
874 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
876 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
877 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
878 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
882 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
883 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
884 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
885 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
887 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
888 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
889 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
891 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
892 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
893 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
897 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
898 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
900 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
902 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
903 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
904 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
905 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
906 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
907 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
908 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
909 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
910 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
911 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
912 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
913 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
914 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
915 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
916 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
917 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
918 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
919 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
920 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
921 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
922 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
924 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
926 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
927 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
928 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
932 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
934 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
935 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
936 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
937 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
938 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
939 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
940 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
941 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
942 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
943 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
944 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
945 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
946 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
947 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
948 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
949 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
950 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
951 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
952 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
953 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
954 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
955 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
956 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
957 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
958 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
959 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
960 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
961 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
962 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
964 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
966 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
967 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
969 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
973 b9622844 2019-08-03 stsp function test_stage_histedit {
974 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
975 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
977 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
979 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
980 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
984 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
985 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
987 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
988 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
989 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
990 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
991 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
992 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
994 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
995 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
996 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
998 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
999 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1001 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1002 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1004 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
1005 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
1006 b9622844 2019-08-03 stsp test_done "$testroot" "1"
1010 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
1011 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1013 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1015 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1016 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1017 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1020 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1022 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1023 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1025 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1029 243d7cf1 2019-08-03 stsp function test_stage_rebase {
1030 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
1032 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1033 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1034 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1036 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1037 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1038 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1039 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1040 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1042 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1043 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
1045 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
1046 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1047 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1048 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
1050 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1052 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1053 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1057 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1058 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1060 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
1061 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1063 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
1064 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
1065 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
1069 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
1070 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1072 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1074 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1075 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1076 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1079 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1081 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1082 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1084 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1087 a76c42e6 2019-08-03 stsp function test_stage_update {
1088 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1090 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1092 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1093 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1097 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1098 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1100 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1101 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1103 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1104 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1106 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
1107 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1108 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1112 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1113 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1115 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1117 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1118 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1119 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1122 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1124 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1125 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1127 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1130 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
1131 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1133 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1135 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1136 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1140 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1141 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1142 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1143 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1144 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1146 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1147 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1148 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1150 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
1151 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1152 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1156 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1157 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1159 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1161 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1162 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1163 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1166 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1168 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1169 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1171 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1174 0f1cfa7f 2019-08-08 stsp function test_stage_commit_out_of_date {
1175 0f1cfa7f 2019-08-08 stsp local testroot=`test_init stage_commit_out_of_date`
1177 0f1cfa7f 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1179 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1180 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1184 0f1cfa7f 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
1185 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
1186 0f1cfa7f 2019-08-08 stsp echo "new file" > $testroot/wt/foo
1187 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
1188 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1190 0f1cfa7f 2019-08-08 stsp echo "changed file" > $testroot/repo/alpha
1191 0f1cfa7f 2019-08-08 stsp git_commit $testroot/repo -m "changed alpha in repo"
1193 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1194 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1196 0f1cfa7f 2019-08-08 stsp if [ "$ret" == "0" ]; then
1197 0f1cfa7f 2019-08-08 stsp echo "got commit command succeeded unexpectedly" >&2
1198 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "1"
1202 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1203 0f1cfa7f 2019-08-08 stsp echo -n "got: work tree must be updated before these changes " \
1204 0f1cfa7f 2019-08-08 stsp > $testroot/stderr.expected
1205 0f1cfa7f 2019-08-08 stsp echo "can be committed" >> $testroot/stderr.expected
1207 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1209 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1210 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1211 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1214 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1216 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1217 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1218 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1222 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout \
1223 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1224 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1225 0f1cfa7f 2019-08-08 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1227 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1229 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1230 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1231 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1234 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1236 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1237 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1238 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1242 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got unstage > /dev/null)
1243 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
1245 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1246 0f1cfa7f 2019-08-08 stsp echo "got update command failed unexpectedly" >&2
1247 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1251 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1252 0f1cfa7f 2019-08-08 stsp echo "C alpha" > $testroot/stdout.expected
1253 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1254 0f1cfa7f 2019-08-08 stsp echo "A foo" >> $testroot/stdout.expected
1255 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1257 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1258 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1259 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1263 0f1cfa7f 2019-08-08 stsp # resolve conflict
1264 0f1cfa7f 2019-08-08 stsp echo "resolved file" > $testroot/wt/alpha
1266 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
1268 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1270 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1271 0f1cfa7f 2019-08-08 stsp echo "got commit command failed unexpectedly" >&2
1272 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1276 0f1cfa7f 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1277 0f1cfa7f 2019-08-08 stsp echo "A foo" > $testroot/stdout.expected
1278 0f1cfa7f 2019-08-08 stsp echo "M alpha" >> $testroot/stdout.expected
1279 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1280 0f1cfa7f 2019-08-08 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1281 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1283 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1284 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1286 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1290 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1291 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1292 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1294 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1296 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1297 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1301 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1302 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1303 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1304 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1305 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1306 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1308 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1309 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1310 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1311 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1312 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1313 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1315 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1316 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1317 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1318 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1320 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1321 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1323 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1324 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1325 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1329 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1330 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1331 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1332 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1333 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1335 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1337 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1338 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1339 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1343 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1344 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1346 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1347 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1348 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1349 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1350 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1351 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1352 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1353 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1354 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1355 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1356 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1357 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1358 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1359 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1360 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1361 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1362 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1363 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1364 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1365 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1366 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1367 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1368 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1369 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1370 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1371 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1372 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1373 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1374 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1376 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1378 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1379 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1380 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1384 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1385 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1386 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1388 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1389 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1391 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1392 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1394 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1397 dc424a06 2019-08-07 stsp function test_stage_patch {
1398 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1400 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1401 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1402 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1403 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1405 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1407 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1408 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1412 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1413 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1414 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1416 dc424a06 2019-08-07 stsp # don't stage any hunks
1417 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1418 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1419 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1421 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1422 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1423 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1426 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1427 dc424a06 2019-08-07 stsp -----------------------------------------------
1428 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1435 dc424a06 2019-08-07 stsp -----------------------------------------------
1436 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1437 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1438 dc424a06 2019-08-07 stsp -----------------------------------------------
1439 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1448 dc424a06 2019-08-07 stsp -----------------------------------------------
1449 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1450 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1451 dc424a06 2019-08-07 stsp -----------------------------------------------
1452 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1458 dc424a06 2019-08-07 stsp -----------------------------------------------
1459 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1460 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1462 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1464 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1465 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1466 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1470 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1471 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1472 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1474 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1475 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1476 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1480 dc424a06 2019-08-07 stsp # stage middle hunk
1481 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1482 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1483 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1485 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1486 dc424a06 2019-08-07 stsp -----------------------------------------------
1487 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1494 dc424a06 2019-08-07 stsp -----------------------------------------------
1495 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1496 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1497 dc424a06 2019-08-07 stsp -----------------------------------------------
1498 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1507 dc424a06 2019-08-07 stsp -----------------------------------------------
1508 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1509 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1510 dc424a06 2019-08-07 stsp -----------------------------------------------
1511 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1517 dc424a06 2019-08-07 stsp -----------------------------------------------
1518 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1519 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1521 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1523 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1524 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1525 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1529 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1530 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1531 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1533 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1534 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1535 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1539 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1541 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1542 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1543 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1544 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1545 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1546 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1547 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1548 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1549 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1550 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1551 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1552 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1553 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1554 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1555 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1556 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1557 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1558 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1559 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1560 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1561 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1563 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1564 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1565 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1569 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1571 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1572 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1573 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1576 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1577 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1578 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1580 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1581 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1582 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1586 dc424a06 2019-08-07 stsp # stage last hunk
1587 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1588 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1589 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1591 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1592 dc424a06 2019-08-07 stsp -----------------------------------------------
1593 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1600 dc424a06 2019-08-07 stsp -----------------------------------------------
1601 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1602 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1603 dc424a06 2019-08-07 stsp -----------------------------------------------
1604 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1613 dc424a06 2019-08-07 stsp -----------------------------------------------
1614 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1615 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1616 dc424a06 2019-08-07 stsp -----------------------------------------------
1617 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1623 dc424a06 2019-08-07 stsp -----------------------------------------------
1624 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1625 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1627 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1629 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1630 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1631 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1635 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1636 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1637 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1639 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1640 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1641 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1645 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1647 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1648 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1649 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1650 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1651 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1652 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1653 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1654 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1655 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1656 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1657 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1658 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1659 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1660 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1661 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1662 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1663 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1664 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1666 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1667 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1669 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1672 af5a81b2 2019-08-08 stsp function test_stage_patch_twice {
1673 af5a81b2 2019-08-08 stsp local testroot=`test_init stage_patch_twice`
1675 af5a81b2 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1676 af5a81b2 2019-08-08 stsp (cd $testroot/repo && git add numbers)
1677 af5a81b2 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
1678 af5a81b2 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1680 af5a81b2 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1682 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1683 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1687 af5a81b2 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1688 af5a81b2 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1689 af5a81b2 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1691 af5a81b2 2019-08-08 stsp # stage middle hunk
1692 af5a81b2 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
1693 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1694 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1696 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1697 af5a81b2 2019-08-08 stsp -----------------------------------------------
1698 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1705 af5a81b2 2019-08-08 stsp -----------------------------------------------
1706 af5a81b2 2019-08-08 stsp M numbers (change 1 of 3)
1707 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1708 af5a81b2 2019-08-08 stsp -----------------------------------------------
1709 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1718 af5a81b2 2019-08-08 stsp -----------------------------------------------
1719 af5a81b2 2019-08-08 stsp M numbers (change 2 of 3)
1720 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1721 af5a81b2 2019-08-08 stsp -----------------------------------------------
1722 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1728 af5a81b2 2019-08-08 stsp -----------------------------------------------
1729 af5a81b2 2019-08-08 stsp M numbers (change 3 of 3)
1730 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1732 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1734 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1735 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1736 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1740 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1741 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1742 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1744 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1745 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1746 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1750 af5a81b2 2019-08-08 stsp # stage last hunk
1751 af5a81b2 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
1752 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1753 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1755 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1756 af5a81b2 2019-08-08 stsp -----------------------------------------------
1757 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@ b
1764 af5a81b2 2019-08-08 stsp -----------------------------------------------
1765 af5a81b2 2019-08-08 stsp M numbers (change 1 of 2)
1766 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1767 af5a81b2 2019-08-08 stsp -----------------------------------------------
1768 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@ b
1774 af5a81b2 2019-08-08 stsp -----------------------------------------------
1775 af5a81b2 2019-08-08 stsp M numbers (change 2 of 2)
1776 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1778 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1780 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1781 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1782 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1786 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1787 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1788 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1790 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1791 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1792 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1796 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1798 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1799 af5a81b2 2019-08-08 stsp > $testroot/stdout.expected
1800 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1801 af5a81b2 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
1802 af5a81b2 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1803 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1804 af5a81b2 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1805 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1806 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1807 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1808 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1809 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1810 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1819 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1826 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1828 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1829 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1830 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1834 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1836 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
1837 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1838 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
1839 af5a81b2 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
1840 af5a81b2 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
1841 af5a81b2 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
1842 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1843 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1844 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1845 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1853 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1855 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1856 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1858 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1861 dc424a06 2019-08-07 stsp function test_stage_patch_added {
1862 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1863 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1865 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1867 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1868 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1872 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1873 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1875 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1876 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1877 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1879 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1880 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1881 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1883 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1884 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1885 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1889 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1890 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1891 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1893 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1894 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1895 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1899 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1901 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1902 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1903 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1904 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1905 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1906 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1907 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1908 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1909 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1910 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1911 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1913 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1914 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1916 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1919 e70a841e 2019-08-08 stsp function test_stage_patch_added_twice {
1920 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_added_twice`
1921 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1923 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1925 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1926 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1930 e70a841e 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
1931 e70a841e 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1933 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1934 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1935 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout)
1937 e70a841e 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
1938 e70a841e 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1939 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1941 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1942 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1943 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1947 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1948 e70a841e 2019-08-08 stsp echo " A epsilon/new" > $testroot/stdout.expected
1949 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1951 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1952 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1953 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1957 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1958 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout 2> $testroot/stderr)
1960 e70a841e 2019-08-08 stsp if [ "$ret" == "0" ]; then
1961 e70a841e 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
1962 e70a841e 2019-08-08 stsp test_done "$testroot" "1"
1966 e70a841e 2019-08-08 stsp echo "got: epsilon/new: no changes to stage" > $testroot/stderr.expected
1967 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1969 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1970 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1971 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1975 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
1976 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1978 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1979 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1981 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1984 dc424a06 2019-08-07 stsp function test_stage_patch_removed {
1985 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
1986 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1988 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1990 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1991 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1995 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
1997 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1998 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1999 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
2001 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
2003 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
2004 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2005 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2007 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2008 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2009 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2013 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2014 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
2015 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2017 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2018 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2019 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2023 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2025 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2026 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
2027 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2028 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
2029 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
2030 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2031 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
2032 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
2033 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
2034 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
2035 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2037 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2038 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2040 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2043 e70a841e 2019-08-08 stsp function test_stage_patch_removed_twice {
2044 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_removed_twice`
2045 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2047 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2049 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2050 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2054 e70a841e 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
2056 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2057 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2058 e70a841e 2019-08-08 stsp beta > $testroot/stdout)
2060 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2062 e70a841e 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
2063 e70a841e 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2064 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2066 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2067 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2068 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2072 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2073 e70a841e 2019-08-08 stsp echo " D beta" > $testroot/stdout.expected
2074 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2076 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2077 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2078 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2082 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p beta \
2083 e70a841e 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2085 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2086 e70a841e 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
2087 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2091 e70a841e 2019-08-08 stsp echo -n > $testroot/stderr.expected
2092 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2094 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2095 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2096 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2100 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2101 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2103 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2104 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2106 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2109 b353a198 2019-08-07 stsp function test_stage_patch_quit {
2110 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
2112 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
2113 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2114 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2115 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2116 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2118 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2120 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2121 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2125 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2126 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2127 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2128 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
2130 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
2131 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
2132 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
2133 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2134 2db2652d 2019-08-07 stsp > $testroot/stdout)
2136 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2137 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
2138 b353a198 2019-08-07 stsp test_done "$testroot" "1"
2141 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
2142 b353a198 2019-08-07 stsp -----------------------------------------------
2143 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
2150 b353a198 2019-08-07 stsp -----------------------------------------------
2151 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
2152 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
2153 b353a198 2019-08-07 stsp -----------------------------------------------
2154 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
2163 b353a198 2019-08-07 stsp -----------------------------------------------
2164 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
2165 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
2167 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
2169 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2171 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2172 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2173 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2177 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2178 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
2179 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
2180 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2182 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2183 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2184 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2188 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2190 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2191 b353a198 2019-08-07 stsp > $testroot/stdout.expected
2192 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2193 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
2194 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
2195 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2196 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2197 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
2198 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2199 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
2200 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
2201 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
2202 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
2203 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
2204 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
2205 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
2206 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
2207 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
2208 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2210 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2211 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2213 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2217 eba70f38 2019-08-08 stsp function test_stage_patch_incomplete_script {
2218 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
2220 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
2221 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2222 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2223 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2224 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2226 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2228 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2229 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2233 eba70f38 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2234 eba70f38 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2235 eba70f38 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2237 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
2238 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2239 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2240 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2242 eba70f38 2019-08-08 stsp if [ "$ret" == "0" ]; then
2243 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2244 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
2247 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
2248 eba70f38 2019-08-08 stsp -----------------------------------------------
2249 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
2256 eba70f38 2019-08-08 stsp -----------------------------------------------
2257 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
2258 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
2259 eba70f38 2019-08-08 stsp -----------------------------------------------
2260 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
2269 eba70f38 2019-08-08 stsp -----------------------------------------------
2270 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
2272 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
2273 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
2274 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2276 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2277 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2278 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2282 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2284 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2285 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2286 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2290 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2291 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
2292 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2294 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2295 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2296 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2300 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2301 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
2302 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2304 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2305 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2307 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2311 fccbfb98 2019-08-03 stsp run_test test_stage_basic
2312 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
2313 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
2314 8564cb21 2019-08-08 stsp run_test test_stage_nonexistent
2315 a4f692bb 2019-08-04 stsp run_test test_stage_list
2316 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
2317 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
2318 d3e7c587 2019-08-03 stsp run_test test_double_stage
2319 c363b2c1 2019-08-03 stsp run_test test_stage_status
2320 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
2321 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
2322 24278f30 2019-08-03 stsp run_test test_stage_revert
2323 408b4ebc 2019-08-03 stsp run_test test_stage_diff
2324 b9622844 2019-08-03 stsp run_test test_stage_histedit
2325 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
2326 a76c42e6 2019-08-03 stsp run_test test_stage_update
2327 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
2328 0f1cfa7f 2019-08-08 stsp run_test test_stage_commit_out_of_date
2329 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
2330 dc424a06 2019-08-07 stsp run_test test_stage_patch
2331 af5a81b2 2019-08-08 stsp run_test test_stage_patch_twice
2332 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
2333 e70a841e 2019-08-08 stsp run_test test_stage_patch_added_twice
2334 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
2335 e70a841e 2019-08-08 stsp run_test test_stage_patch_removed_twice
2336 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
2337 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script