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 a4f692bb 2019-08-04 stsp function test_stage_list {
148 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
150 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
152 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
153 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
157 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
158 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
159 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
160 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
162 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
163 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
164 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
165 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
167 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
168 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
169 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
170 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
171 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
172 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
173 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
174 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
175 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
176 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
177 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
179 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
180 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
181 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
185 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
186 a4f692bb 2019-08-04 stsp > $testroot/stdout)
188 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
189 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
191 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
192 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
193 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
197 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
199 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
200 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
201 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
202 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
204 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
205 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
207 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
211 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
212 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
213 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
215 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
217 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
218 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
222 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
223 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
225 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
227 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
229 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
230 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
231 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
232 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
234 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
236 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
238 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
239 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
240 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
244 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
245 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
247 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
248 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
249 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
253 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
254 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
255 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
257 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
259 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
260 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
261 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
264 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
266 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
267 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
269 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
272 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
273 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
274 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
276 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
278 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
279 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
283 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
284 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
286 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
288 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
289 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
290 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
292 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
293 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
294 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
298 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
299 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
300 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
302 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
304 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
305 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
306 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
309 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
311 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
312 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
314 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
318 d3e7c587 2019-08-03 stsp function test_double_stage {
319 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
321 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
323 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
324 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
327 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
328 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
329 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
330 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
331 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
333 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
334 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
335 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
337 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
338 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
339 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
343 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
345 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
346 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
347 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
350 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
351 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
353 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
354 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
355 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
359 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
360 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
361 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
363 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
364 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
365 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
369 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
370 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
372 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
373 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
374 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
375 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
377 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
378 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
379 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
383 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
384 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
385 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
387 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
388 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
390 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
391 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
393 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
396 c363b2c1 2019-08-03 stsp function test_stage_status {
397 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
399 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
401 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
402 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
406 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
407 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
408 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
409 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
410 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
411 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
412 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
413 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
415 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
416 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
417 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
418 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
419 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
420 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
421 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
423 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
424 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
426 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
427 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
428 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
432 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
433 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
435 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
436 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
437 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
438 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
439 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
440 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
442 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
443 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
445 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
446 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
447 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
451 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
452 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
453 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
454 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
455 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
457 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
458 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
459 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
463 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
464 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
465 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
466 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
467 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
469 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
470 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
472 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
476 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
477 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
479 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
481 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
482 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
486 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
487 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
488 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
489 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
491 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
493 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
494 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
495 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
496 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
497 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
498 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
499 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
501 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
502 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
503 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
506 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
508 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
509 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
510 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
515 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
516 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
517 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
519 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
520 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
522 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
523 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
525 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
528 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
529 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
531 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
533 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
534 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
538 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
539 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
540 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
541 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
543 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
545 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
546 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
548 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
549 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
550 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
553 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
554 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
556 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
557 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
558 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
561 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
562 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
564 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
565 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
566 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
570 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
571 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
572 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
573 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
575 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
576 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
577 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
580 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
582 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
583 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
584 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
589 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
590 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
591 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
593 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
594 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
596 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
597 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
599 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
602 24278f30 2019-08-03 stsp function test_stage_revert {
603 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
605 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
607 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
608 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
612 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
613 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
614 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
615 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
616 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
618 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
619 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
621 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
623 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
624 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
625 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
629 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
630 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
632 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
633 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
634 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
638 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
639 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
640 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
642 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
643 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
644 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
648 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
649 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
650 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
651 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
652 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
654 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
655 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
656 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
660 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
662 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
663 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
664 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
668 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
669 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
671 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
672 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
673 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
677 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
678 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
679 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
681 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
682 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
683 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
687 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
688 24278f30 2019-08-03 stsp 2> $testroot/stderr)
690 24278f30 2019-08-03 stsp if [ "$ret" == "0" ]; then
691 24278f30 2019-08-03 stsp echo "revert command succeeded unexpectedly" >&2
692 24278f30 2019-08-03 stsp test_done "$testroot" "1"
696 24278f30 2019-08-03 stsp echo "got: beta: file is staged" > $testroot/stderr.expected
697 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
699 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
700 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
701 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
705 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
707 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
708 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
709 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
713 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
714 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
716 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
717 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
718 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
722 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
723 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
724 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
726 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
727 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
728 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
732 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
733 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
734 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
735 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
736 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
738 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
739 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
740 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
744 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
746 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
747 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
748 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
752 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
753 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
755 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
756 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
757 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
761 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
762 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
763 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
765 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
766 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
767 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
771 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
772 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
773 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
774 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
775 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
777 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
778 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
780 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
783 408b4ebc 2019-08-03 stsp function test_stage_diff {
784 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
785 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
787 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
789 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
790 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
794 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
795 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
796 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
797 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
799 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
800 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
801 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
803 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
804 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
805 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
809 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
810 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
811 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
812 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
814 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
815 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
816 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
818 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
819 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
820 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
824 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
825 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
827 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
829 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
830 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
831 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
832 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
833 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
834 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
835 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
836 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
837 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
838 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
839 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
840 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
841 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
842 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
843 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
844 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
845 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
846 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
847 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
848 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
849 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
851 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
853 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
854 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
855 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
859 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
861 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
862 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
863 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
864 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
865 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
866 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
867 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
868 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
869 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
870 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
871 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
872 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
873 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
874 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
875 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
876 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
877 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
878 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
879 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
880 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
881 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
882 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
883 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
884 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
885 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
886 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
887 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
888 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
889 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
891 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
893 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
894 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
896 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
900 b9622844 2019-08-03 stsp function test_stage_histedit {
901 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
902 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
904 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
906 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
907 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
911 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
912 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
914 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
915 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
916 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
917 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
918 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
919 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
921 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
922 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
923 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
925 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
926 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
928 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
929 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
931 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
932 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
933 b9622844 2019-08-03 stsp test_done "$testroot" "1"
937 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
938 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
940 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
942 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
943 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
944 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
947 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
949 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
950 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
952 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
956 243d7cf1 2019-08-03 stsp function test_stage_rebase {
957 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
959 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
960 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
961 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
963 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
964 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
965 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
966 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
967 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
969 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
970 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
972 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
973 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
974 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
975 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
977 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
979 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
980 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
984 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
985 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
987 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
988 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
990 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
991 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
992 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
996 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
997 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
999 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1001 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1002 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1003 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1006 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1008 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1009 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1011 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1014 a76c42e6 2019-08-03 stsp function test_stage_update {
1015 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1017 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1019 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1020 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1024 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1025 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1027 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1028 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1030 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1031 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1033 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
1034 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1035 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1039 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1040 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1042 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1044 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1045 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1046 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1049 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1051 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1052 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1054 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1057 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
1058 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1060 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1062 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1063 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1067 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1068 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1069 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1070 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1071 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1073 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1074 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1075 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1077 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
1078 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1079 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1083 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1084 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1086 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1088 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1089 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1090 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1093 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1095 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1096 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1098 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1101 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1102 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1103 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1105 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1107 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1108 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1112 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1113 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1114 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1115 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1116 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1117 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1119 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1120 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1121 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1122 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1123 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1124 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1126 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1127 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1128 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1129 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1131 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1132 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1134 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1135 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1136 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1140 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1141 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1142 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1143 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1144 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1146 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1148 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1149 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1150 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1154 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1155 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1157 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1158 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1159 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1160 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1161 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1162 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1163 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1164 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1165 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1166 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1167 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1168 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1169 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1170 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1171 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1172 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1173 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1174 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1175 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1176 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1177 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1178 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1179 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1180 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1181 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1182 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1183 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1184 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1185 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1187 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1189 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1190 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1191 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1195 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1196 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1197 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1199 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1200 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1202 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1203 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1205 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1208 dc424a06 2019-08-07 stsp function test_stage_patch {
1209 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1211 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1212 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1213 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1214 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1216 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1218 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1219 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1223 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1224 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1225 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1227 dc424a06 2019-08-07 stsp # don't stage any hunks
1228 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1229 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1230 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1232 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1233 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1234 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1237 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1238 dc424a06 2019-08-07 stsp -----------------------------------------------
1239 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1246 dc424a06 2019-08-07 stsp -----------------------------------------------
1247 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1248 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1249 dc424a06 2019-08-07 stsp -----------------------------------------------
1250 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1259 dc424a06 2019-08-07 stsp -----------------------------------------------
1260 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1261 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1262 dc424a06 2019-08-07 stsp -----------------------------------------------
1263 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1269 dc424a06 2019-08-07 stsp -----------------------------------------------
1270 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1271 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1273 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1275 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1276 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1277 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1281 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1282 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1283 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1285 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1286 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1287 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1291 dc424a06 2019-08-07 stsp # stage middle hunk
1292 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1293 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1294 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1296 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1297 dc424a06 2019-08-07 stsp -----------------------------------------------
1298 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1305 dc424a06 2019-08-07 stsp -----------------------------------------------
1306 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1307 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1308 dc424a06 2019-08-07 stsp -----------------------------------------------
1309 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1318 dc424a06 2019-08-07 stsp -----------------------------------------------
1319 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1320 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1321 dc424a06 2019-08-07 stsp -----------------------------------------------
1322 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1328 dc424a06 2019-08-07 stsp -----------------------------------------------
1329 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1330 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1332 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1334 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1335 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1336 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1340 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1341 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1342 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1344 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1345 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1346 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1350 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1352 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1353 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1354 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1355 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1356 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1357 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1358 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1359 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1360 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1361 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1362 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1363 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1364 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1365 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1366 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1367 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1368 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1369 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1370 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1371 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1372 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1374 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1375 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1376 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1380 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1382 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1383 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1384 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1387 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1388 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1389 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1391 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1392 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1393 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1397 dc424a06 2019-08-07 stsp # stage last hunk
1398 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1399 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1400 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1402 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1403 dc424a06 2019-08-07 stsp -----------------------------------------------
1404 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1411 dc424a06 2019-08-07 stsp -----------------------------------------------
1412 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1413 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1414 dc424a06 2019-08-07 stsp -----------------------------------------------
1415 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1424 dc424a06 2019-08-07 stsp -----------------------------------------------
1425 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1426 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1427 dc424a06 2019-08-07 stsp -----------------------------------------------
1428 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1434 dc424a06 2019-08-07 stsp -----------------------------------------------
1435 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1436 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1438 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1440 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1441 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1442 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1446 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1447 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1448 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1450 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1451 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1452 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1456 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1458 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1459 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1460 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1461 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1462 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1463 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1464 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1465 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1466 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1467 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1468 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1469 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1470 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1471 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1472 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1473 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1474 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1475 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1477 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1478 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1480 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1483 dc424a06 2019-08-07 stsp function test_stage_patch_added {
1484 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1485 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1487 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1489 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1490 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1494 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1495 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1497 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1498 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1499 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1501 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1502 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1503 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1505 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1506 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1507 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1511 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1512 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1513 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1515 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1516 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1517 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1521 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1523 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1524 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1525 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1526 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1527 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1528 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1529 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1530 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1531 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1532 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1533 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1535 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1536 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1538 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1541 dc424a06 2019-08-07 stsp function test_stage_patch_removed {
1542 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
1543 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1545 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1547 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1548 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1552 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
1554 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1555 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1556 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
1558 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
1560 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
1561 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
1562 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1564 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1565 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1566 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1570 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1571 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
1572 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1574 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1575 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1576 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1580 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1582 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1583 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1584 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1585 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
1586 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1587 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1588 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
1589 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
1590 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
1591 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
1592 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1594 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1595 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1597 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1600 b353a198 2019-08-07 stsp function test_stage_patch_quit {
1601 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
1603 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1604 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
1605 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
1606 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
1607 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1609 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1611 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1612 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1616 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1617 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1618 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1619 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
1621 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
1622 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
1623 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
1624 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1625 2db2652d 2019-08-07 stsp > $testroot/stdout)
1627 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1628 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1629 b353a198 2019-08-07 stsp test_done "$testroot" "1"
1632 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1633 b353a198 2019-08-07 stsp -----------------------------------------------
1634 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
1641 b353a198 2019-08-07 stsp -----------------------------------------------
1642 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1643 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1644 b353a198 2019-08-07 stsp -----------------------------------------------
1645 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
1654 b353a198 2019-08-07 stsp -----------------------------------------------
1655 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1656 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
1658 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
1660 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1662 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1663 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1664 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1668 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1669 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1670 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
1671 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1673 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1674 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1675 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1679 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1681 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1682 b353a198 2019-08-07 stsp > $testroot/stdout.expected
1683 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1684 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1685 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1686 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1687 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1688 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1689 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1690 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1691 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1692 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
1693 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
1694 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
1695 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
1696 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
1697 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1698 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1699 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1701 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1702 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1704 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1708 eba70f38 2019-08-08 stsp function test_stage_patch_incomplete_script {
1709 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
1711 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1712 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
1713 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
1714 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
1715 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1717 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1719 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1720 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1724 eba70f38 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1725 eba70f38 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1726 eba70f38 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1728 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
1729 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1730 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1731 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
1733 eba70f38 2019-08-08 stsp if [ "$ret" == "0" ]; then
1734 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
1735 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
1738 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1739 eba70f38 2019-08-08 stsp -----------------------------------------------
1740 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
1747 eba70f38 2019-08-08 stsp -----------------------------------------------
1748 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
1749 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
1750 eba70f38 2019-08-08 stsp -----------------------------------------------
1751 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
1760 eba70f38 2019-08-08 stsp -----------------------------------------------
1761 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
1763 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
1764 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
1765 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1767 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1768 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1769 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1773 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1775 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1776 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1777 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1781 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1782 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
1783 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1785 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1786 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1787 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1791 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1792 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
1793 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1795 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
1796 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1798 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
1802 fccbfb98 2019-08-03 stsp run_test test_stage_basic
1803 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
1804 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
1805 a4f692bb 2019-08-04 stsp run_test test_stage_list
1806 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
1807 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
1808 d3e7c587 2019-08-03 stsp run_test test_double_stage
1809 c363b2c1 2019-08-03 stsp run_test test_stage_status
1810 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
1811 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
1812 24278f30 2019-08-03 stsp run_test test_stage_revert
1813 408b4ebc 2019-08-03 stsp run_test test_stage_diff
1814 b9622844 2019-08-03 stsp run_test test_stage_histedit
1815 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
1816 a76c42e6 2019-08-03 stsp run_test test_stage_update
1817 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
1818 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
1819 dc424a06 2019-08-07 stsp run_test test_stage_patch
1820 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
1821 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
1822 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
1823 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script