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 24278f30 2019-08-03 stsp if [ "$ret" == "0" ]; then
712 24278f30 2019-08-03 stsp echo "revert command succeeded unexpectedly" >&2
713 24278f30 2019-08-03 stsp test_done "$testroot" "1"
717 24278f30 2019-08-03 stsp echo "got: beta: file is staged" > $testroot/stderr.expected
718 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
720 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
721 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
722 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
726 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
728 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
729 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
730 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
734 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
735 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
737 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
738 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
739 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
743 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
744 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
745 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
747 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
748 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
749 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
753 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
754 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
755 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
756 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
757 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
759 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
760 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
761 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
765 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
767 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
768 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
769 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
773 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
774 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
776 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
777 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
778 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
782 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
783 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
784 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
786 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
787 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
788 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
792 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
793 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
794 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
795 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
796 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
798 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
799 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
801 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
804 408b4ebc 2019-08-03 stsp function test_stage_diff {
805 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
806 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
808 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
810 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
811 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
815 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
816 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
817 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
818 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
820 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
821 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
822 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
824 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
825 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
826 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
830 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
831 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
832 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
833 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
835 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
836 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
837 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
839 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
840 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
841 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
845 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
846 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
848 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
850 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
851 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
852 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
853 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
854 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
855 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
856 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
857 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
858 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
859 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
860 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
861 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
862 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
863 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
864 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
865 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
866 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
867 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
868 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
869 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
870 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
872 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
874 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
875 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
876 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
880 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
882 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
883 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
884 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
885 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
886 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
887 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
888 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
889 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
890 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
891 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
892 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
893 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
894 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
895 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
896 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
897 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
898 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
899 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
900 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
901 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
902 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
903 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
904 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
905 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
906 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
907 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
908 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
909 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
910 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
912 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
914 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
915 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
917 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
921 b9622844 2019-08-03 stsp function test_stage_histedit {
922 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
923 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
925 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
927 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
928 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
932 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
933 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
935 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
936 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
937 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
938 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
939 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
940 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
942 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
943 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
944 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
946 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
947 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
949 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
950 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
952 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
953 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
954 b9622844 2019-08-03 stsp test_done "$testroot" "1"
958 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
959 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
961 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
963 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
964 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
965 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
968 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
970 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
971 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
973 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
977 243d7cf1 2019-08-03 stsp function test_stage_rebase {
978 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
980 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
981 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
982 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
984 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
985 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
986 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
987 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
988 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
990 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
991 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
993 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
994 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
995 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
996 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
998 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1000 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1001 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1005 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1006 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1008 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
1009 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1011 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
1012 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
1013 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
1017 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
1018 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1020 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1022 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1023 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1024 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1027 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1029 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1030 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1032 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1035 a76c42e6 2019-08-03 stsp function test_stage_update {
1036 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1038 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1040 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1041 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1045 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1046 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1048 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1049 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1051 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1052 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1054 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
1055 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1056 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1060 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1061 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1063 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1065 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1066 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1067 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1070 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1072 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1073 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1075 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1078 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
1079 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1081 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1083 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1084 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1088 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1089 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1090 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1091 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1092 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1094 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1095 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1096 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1098 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
1099 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1100 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1104 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1105 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1107 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1109 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1110 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1111 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1114 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1116 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1117 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1119 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1122 0f1cfa7f 2019-08-08 stsp function test_stage_commit_out_of_date {
1123 0f1cfa7f 2019-08-08 stsp local testroot=`test_init stage_commit_out_of_date`
1125 0f1cfa7f 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1127 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1128 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1132 0f1cfa7f 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
1133 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
1134 0f1cfa7f 2019-08-08 stsp echo "new file" > $testroot/wt/foo
1135 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
1136 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1138 0f1cfa7f 2019-08-08 stsp echo "changed file" > $testroot/repo/alpha
1139 0f1cfa7f 2019-08-08 stsp git_commit $testroot/repo -m "changed alpha in repo"
1141 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1142 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1144 0f1cfa7f 2019-08-08 stsp if [ "$ret" == "0" ]; then
1145 0f1cfa7f 2019-08-08 stsp echo "got commit command succeeded unexpectedly" >&2
1146 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "1"
1150 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1151 0f1cfa7f 2019-08-08 stsp echo -n "got: work tree must be updated before these changes " \
1152 0f1cfa7f 2019-08-08 stsp > $testroot/stderr.expected
1153 0f1cfa7f 2019-08-08 stsp echo "can be committed" >> $testroot/stderr.expected
1155 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1157 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1158 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1159 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1162 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1164 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1165 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1166 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1170 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout \
1171 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1172 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1173 0f1cfa7f 2019-08-08 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1175 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1177 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1178 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1179 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1182 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1184 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1185 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1186 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1190 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got unstage > /dev/null)
1191 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
1193 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1194 0f1cfa7f 2019-08-08 stsp echo "got update command failed unexpectedly" >&2
1195 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1199 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1200 0f1cfa7f 2019-08-08 stsp echo "C alpha" > $testroot/stdout.expected
1201 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1202 0f1cfa7f 2019-08-08 stsp echo "A foo" >> $testroot/stdout.expected
1203 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1205 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1206 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1207 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1211 0f1cfa7f 2019-08-08 stsp # resolve conflict
1212 0f1cfa7f 2019-08-08 stsp echo "resolved file" > $testroot/wt/alpha
1214 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
1216 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1218 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1219 0f1cfa7f 2019-08-08 stsp echo "got commit command failed unexpectedly" >&2
1220 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1224 0f1cfa7f 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1225 0f1cfa7f 2019-08-08 stsp echo "A foo" > $testroot/stdout.expected
1226 0f1cfa7f 2019-08-08 stsp echo "M alpha" >> $testroot/stdout.expected
1227 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1228 0f1cfa7f 2019-08-08 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1229 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1231 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1232 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1234 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1238 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1239 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1240 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1242 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1244 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1245 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1249 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1250 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1251 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1252 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1253 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1254 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1256 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1257 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1258 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1259 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1260 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1261 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1263 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1264 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1265 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1266 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1268 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1269 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1271 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1272 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1273 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1277 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1278 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1279 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1280 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1281 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1283 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1285 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1286 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1287 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1291 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1292 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1294 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1295 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1296 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1297 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1298 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1299 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1300 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1301 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1302 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1303 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1304 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1305 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1306 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1307 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1308 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1309 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1310 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1311 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1312 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1313 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1314 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1315 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1316 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1317 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1318 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1319 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1320 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1321 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1322 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1324 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1326 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1327 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1328 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1332 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1333 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1334 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1336 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1337 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1339 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1340 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1342 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1345 dc424a06 2019-08-07 stsp function test_stage_patch {
1346 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1348 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1349 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1350 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1351 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1353 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1355 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1356 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1360 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1361 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1362 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1364 dc424a06 2019-08-07 stsp # don't stage any hunks
1365 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1366 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1367 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1369 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1370 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1371 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1374 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1375 dc424a06 2019-08-07 stsp -----------------------------------------------
1376 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1383 dc424a06 2019-08-07 stsp -----------------------------------------------
1384 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1385 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1386 dc424a06 2019-08-07 stsp -----------------------------------------------
1387 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1396 dc424a06 2019-08-07 stsp -----------------------------------------------
1397 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1398 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1399 dc424a06 2019-08-07 stsp -----------------------------------------------
1400 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1406 dc424a06 2019-08-07 stsp -----------------------------------------------
1407 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1408 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1410 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1412 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1413 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1414 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1418 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1419 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1420 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1422 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1423 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1424 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1428 dc424a06 2019-08-07 stsp # stage middle hunk
1429 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1430 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1431 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1433 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1434 dc424a06 2019-08-07 stsp -----------------------------------------------
1435 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1442 dc424a06 2019-08-07 stsp -----------------------------------------------
1443 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1444 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1445 dc424a06 2019-08-07 stsp -----------------------------------------------
1446 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1455 dc424a06 2019-08-07 stsp -----------------------------------------------
1456 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1457 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1458 dc424a06 2019-08-07 stsp -----------------------------------------------
1459 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1465 dc424a06 2019-08-07 stsp -----------------------------------------------
1466 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1467 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1469 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1471 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1472 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1473 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1477 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1478 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1479 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1481 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1482 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1483 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1487 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1489 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1490 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1491 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1492 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1493 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1494 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1495 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1496 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1497 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1498 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1499 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1500 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1501 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1502 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1503 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1504 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1505 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1506 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1507 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1508 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1509 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1511 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1512 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1513 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1517 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1519 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1520 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1521 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1524 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1525 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1526 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1528 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1529 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1530 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1534 dc424a06 2019-08-07 stsp # stage last hunk
1535 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1536 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1537 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1539 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1540 dc424a06 2019-08-07 stsp -----------------------------------------------
1541 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1548 dc424a06 2019-08-07 stsp -----------------------------------------------
1549 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1550 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1551 dc424a06 2019-08-07 stsp -----------------------------------------------
1552 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1561 dc424a06 2019-08-07 stsp -----------------------------------------------
1562 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1563 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1564 dc424a06 2019-08-07 stsp -----------------------------------------------
1565 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1571 dc424a06 2019-08-07 stsp -----------------------------------------------
1572 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1573 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1575 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1577 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1578 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1579 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1583 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1584 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1585 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1587 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1588 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1589 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1593 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1595 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1596 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1597 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1598 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1599 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1600 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1601 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1602 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1603 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1604 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1605 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1606 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1607 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1608 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1609 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1610 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1611 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1612 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1614 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1615 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1617 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1620 dc424a06 2019-08-07 stsp function test_stage_patch_added {
1621 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1622 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1624 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1626 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1627 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1631 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1632 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1634 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1635 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1636 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1638 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1639 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1640 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1642 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1643 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1644 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1648 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1649 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1650 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1652 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1653 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1654 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1658 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1660 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1661 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1662 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1663 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1664 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1665 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1666 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1667 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1668 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1669 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1670 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1672 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1673 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1675 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1678 dc424a06 2019-08-07 stsp function test_stage_patch_removed {
1679 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
1680 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1682 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1684 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1685 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1689 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
1691 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1692 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1693 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
1695 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
1697 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
1698 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
1699 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1701 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1702 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1703 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1707 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1708 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
1709 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1711 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1712 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1713 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1717 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1719 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1720 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1721 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1722 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
1723 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1724 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1725 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
1726 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
1727 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
1728 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
1729 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1731 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1732 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1734 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1737 b353a198 2019-08-07 stsp function test_stage_patch_quit {
1738 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
1740 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1741 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
1742 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
1743 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
1744 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1746 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1748 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1749 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1753 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1754 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1755 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1756 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
1758 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
1759 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
1760 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
1761 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1762 2db2652d 2019-08-07 stsp > $testroot/stdout)
1764 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1765 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1766 b353a198 2019-08-07 stsp test_done "$testroot" "1"
1769 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1770 b353a198 2019-08-07 stsp -----------------------------------------------
1771 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
1778 b353a198 2019-08-07 stsp -----------------------------------------------
1779 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1780 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1781 b353a198 2019-08-07 stsp -----------------------------------------------
1782 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
1791 b353a198 2019-08-07 stsp -----------------------------------------------
1792 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1793 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
1795 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
1797 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1799 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1800 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1801 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1805 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1806 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1807 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
1808 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1810 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1811 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1812 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1816 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1818 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1819 b353a198 2019-08-07 stsp > $testroot/stdout.expected
1820 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1821 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1822 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1823 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1824 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1825 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1826 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1827 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1828 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1829 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
1830 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
1831 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
1832 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
1833 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
1834 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1835 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1836 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1838 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1839 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1841 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1845 eba70f38 2019-08-08 stsp function test_stage_patch_incomplete_script {
1846 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
1848 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1849 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
1850 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
1851 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
1852 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1854 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1856 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1857 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1861 eba70f38 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1862 eba70f38 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1863 eba70f38 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1865 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
1866 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1867 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1868 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
1870 eba70f38 2019-08-08 stsp if [ "$ret" == "0" ]; then
1871 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
1872 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
1875 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1876 eba70f38 2019-08-08 stsp -----------------------------------------------
1877 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
1884 eba70f38 2019-08-08 stsp -----------------------------------------------
1885 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
1886 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
1887 eba70f38 2019-08-08 stsp -----------------------------------------------
1888 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
1897 eba70f38 2019-08-08 stsp -----------------------------------------------
1898 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
1900 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
1901 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
1902 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1904 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1905 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1906 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1910 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1912 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1913 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1914 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1918 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1919 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
1920 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1922 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1923 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1924 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1928 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1929 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
1930 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1932 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1933 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1935 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1939 fccbfb98 2019-08-03 stsp run_test test_stage_basic
1940 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
1941 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
1942 8564cb21 2019-08-08 stsp run_test test_stage_nonexistent
1943 a4f692bb 2019-08-04 stsp run_test test_stage_list
1944 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
1945 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
1946 d3e7c587 2019-08-03 stsp run_test test_double_stage
1947 c363b2c1 2019-08-03 stsp run_test test_stage_status
1948 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
1949 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
1950 24278f30 2019-08-03 stsp run_test test_stage_revert
1951 408b4ebc 2019-08-03 stsp run_test test_stage_diff
1952 b9622844 2019-08-03 stsp run_test test_stage_histedit
1953 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
1954 a76c42e6 2019-08-03 stsp run_test test_stage_update
1955 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
1956 0f1cfa7f 2019-08-08 stsp run_test test_stage_commit_out_of_date
1957 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
1958 dc424a06 2019-08-07 stsp run_test test_stage_patch
1959 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
1960 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
1961 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
1962 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script