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 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $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 a4f692bb 2019-08-04 stsp function test_stage_list {
86 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
88 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
90 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
91 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
95 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
96 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
97 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
98 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
100 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
101 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
102 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
103 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
105 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
106 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
107 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
108 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
109 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
110 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
111 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
112 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
113 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
114 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
115 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
117 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
118 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
119 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
123 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
124 a4f692bb 2019-08-04 stsp > $testroot/stdout)
126 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
127 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
129 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
130 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
131 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
135 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
137 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
138 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
139 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
140 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
142 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
143 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
145 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
149 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
150 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
151 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
153 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
155 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
156 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
160 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
161 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
163 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
165 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
167 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
168 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
169 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
170 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
172 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
174 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
176 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
177 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
178 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
182 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
183 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
185 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
186 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
187 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
191 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
192 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
193 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
195 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
197 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
198 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
199 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
202 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
204 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
205 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
207 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
210 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
211 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
212 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
214 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
216 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
217 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
221 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
222 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
224 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
226 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
227 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
228 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
230 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
231 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
232 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
236 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
237 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
238 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
240 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
242 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
243 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
244 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
247 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
249 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
250 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
252 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
256 d3e7c587 2019-08-03 stsp function test_double_stage {
257 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
259 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
261 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
262 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
265 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
266 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
267 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
268 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
269 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
271 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
272 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
273 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
275 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
276 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
277 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
281 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
283 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
284 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
285 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
288 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
289 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
291 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
292 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
293 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
297 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
298 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
299 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
301 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
302 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
303 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
307 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
308 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
310 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
311 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
312 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
313 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
315 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
316 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
317 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
321 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
322 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
323 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
325 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
326 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
328 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
329 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
331 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
334 c363b2c1 2019-08-03 stsp function test_stage_status {
335 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
337 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
339 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
340 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
344 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
345 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
346 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
347 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
348 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
349 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
350 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
351 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
353 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
354 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
355 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
356 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
357 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
358 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
359 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
361 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
362 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
364 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
365 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
366 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
370 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
371 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
373 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
374 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
375 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
376 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
377 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
378 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
380 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
381 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
383 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
384 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
385 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
389 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
390 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
391 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
392 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
393 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
395 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
396 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
397 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
401 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
402 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
403 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
404 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
405 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
407 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
408 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
410 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
414 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
415 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
417 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
419 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
420 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
424 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
425 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
426 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
427 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
429 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
431 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
432 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
433 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
434 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
435 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
436 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
437 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
439 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
440 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
441 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
444 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
446 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
447 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
453 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
454 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
455 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
457 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
458 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
460 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
461 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
463 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
466 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
467 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
469 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
471 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
472 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
476 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
477 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
478 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
479 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
481 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
483 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
484 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
486 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
487 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
488 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
491 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
492 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
494 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
495 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
496 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
499 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
500 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
502 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
503 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
504 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
508 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
509 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
510 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
511 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
513 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
514 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
515 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
518 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
520 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
521 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
522 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
527 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
528 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
529 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
531 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
532 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
534 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
535 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
537 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
540 24278f30 2019-08-03 stsp function test_stage_revert {
541 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
543 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
545 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
546 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
550 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
551 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
552 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
553 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
554 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
556 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
557 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
559 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
561 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
562 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
563 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
567 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
568 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
570 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
571 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
572 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
576 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
577 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
578 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
580 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
581 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
582 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
586 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
587 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
588 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
589 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
590 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
592 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
593 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
594 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
598 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
600 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
601 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
602 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
606 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
607 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
609 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
610 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
611 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
615 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
616 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
617 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
619 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
620 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
621 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
625 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
626 24278f30 2019-08-03 stsp 2> $testroot/stderr)
628 24278f30 2019-08-03 stsp if [ "$ret" == "0" ]; then
629 24278f30 2019-08-03 stsp echo "revert command succeeded unexpectedly" >&2
630 24278f30 2019-08-03 stsp test_done "$testroot" "1"
634 24278f30 2019-08-03 stsp echo "got: beta: file is staged" > $testroot/stderr.expected
635 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
637 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
638 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
639 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
643 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
645 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
646 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
647 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
651 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
652 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
654 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
655 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
656 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
660 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
661 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
662 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
664 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
665 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
666 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
670 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
671 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
672 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
673 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
674 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
676 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
677 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
678 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
682 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
684 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
685 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
686 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
690 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
691 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
693 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
694 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
695 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
699 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
700 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
701 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
703 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
704 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
705 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
709 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
710 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
711 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
712 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
713 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
715 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
716 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
718 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
721 408b4ebc 2019-08-03 stsp function test_stage_diff {
722 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
723 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
725 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
727 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
728 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
732 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
733 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
734 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
735 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
737 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
738 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
739 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
741 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
742 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
743 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
747 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
748 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
749 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
750 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
752 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
753 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
754 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
756 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
757 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
758 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
762 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
763 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
765 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
767 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
768 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
769 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
770 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
771 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
772 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
773 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
774 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
775 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
776 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
777 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
778 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
779 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
780 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
781 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
782 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
783 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
784 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
785 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
787 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
789 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
790 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
791 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
795 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
797 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
798 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
799 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
800 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
801 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
802 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
803 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
804 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
805 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
806 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
807 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
808 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
809 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
810 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
811 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
812 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
813 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
814 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
815 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
816 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
817 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
818 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
819 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
820 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
821 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
822 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
823 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
824 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
825 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
827 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
829 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
830 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
832 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
836 b9622844 2019-08-03 stsp function test_stage_histedit {
837 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
838 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
840 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
842 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
843 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
847 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
848 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
850 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
851 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
852 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
853 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
854 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
855 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
857 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
858 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
859 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
861 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
862 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
864 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
865 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
867 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
868 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
869 b9622844 2019-08-03 stsp test_done "$testroot" "1"
873 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
874 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
876 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
878 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
879 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
880 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
883 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
885 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
886 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
888 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
892 243d7cf1 2019-08-03 stsp function test_stage_rebase {
893 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
895 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
896 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
897 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
899 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
900 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
901 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
902 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
903 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
905 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
906 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
908 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
909 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
910 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
911 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
913 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
915 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
916 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
920 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
921 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
923 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
924 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
926 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
927 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
928 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
932 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
933 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
935 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
937 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
938 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
939 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
942 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
944 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
945 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
947 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
950 a76c42e6 2019-08-03 stsp function test_stage_update {
951 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
953 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
955 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
956 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
960 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
961 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
963 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
964 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
966 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
967 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
969 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
970 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
971 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
975 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
976 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
978 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
980 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
981 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
982 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
985 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
987 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
988 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
990 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
993 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
994 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
996 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
998 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
999 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1003 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1004 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1005 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1006 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1007 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1009 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1010 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1011 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1013 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
1014 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1015 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1019 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1020 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1022 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1024 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1025 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1026 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1029 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1031 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1032 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1034 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1037 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1038 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1039 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1041 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1043 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1044 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1048 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1049 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1050 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1051 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1052 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1053 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1055 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1056 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1057 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1058 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1059 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1060 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1062 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1063 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1064 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1065 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1067 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1068 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1070 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1071 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1072 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1076 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1077 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1078 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1079 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1080 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1082 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1084 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1085 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1086 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1090 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1091 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1093 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1094 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1095 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1096 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1097 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1098 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1099 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1100 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1101 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1102 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1103 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1104 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1105 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1106 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1107 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1108 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1109 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1110 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1111 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1112 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1113 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1114 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1115 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1116 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1117 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1118 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1119 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1120 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1121 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1123 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1125 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1126 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1127 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1131 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1132 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1133 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1135 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1136 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1138 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1139 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1141 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1144 dc424a06 2019-08-07 stsp function test_stage_patch {
1145 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1147 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1148 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1149 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1150 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1152 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1154 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1155 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1159 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1160 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1161 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1163 dc424a06 2019-08-07 stsp # don't stage any hunks
1164 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1165 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1166 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1168 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1169 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1170 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1173 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1174 dc424a06 2019-08-07 stsp -----------------------------------------------
1175 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1182 dc424a06 2019-08-07 stsp -----------------------------------------------
1184 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1185 dc424a06 2019-08-07 stsp -----------------------------------------------
1186 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1195 dc424a06 2019-08-07 stsp -----------------------------------------------
1197 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1198 dc424a06 2019-08-07 stsp -----------------------------------------------
1199 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1205 dc424a06 2019-08-07 stsp -----------------------------------------------
1207 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1209 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1211 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1212 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1213 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1217 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1218 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1219 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1221 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1222 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1223 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1227 dc424a06 2019-08-07 stsp # stage middle hunk
1228 dc424a06 2019-08-07 stsp printf "n\ny\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 cat > $testroot/stdout.expected <<EOF
1233 dc424a06 2019-08-07 stsp -----------------------------------------------
1234 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1241 dc424a06 2019-08-07 stsp -----------------------------------------------
1243 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1244 dc424a06 2019-08-07 stsp -----------------------------------------------
1245 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1254 dc424a06 2019-08-07 stsp -----------------------------------------------
1256 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1257 dc424a06 2019-08-07 stsp -----------------------------------------------
1258 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1264 dc424a06 2019-08-07 stsp -----------------------------------------------
1266 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1268 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1270 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1271 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1272 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1276 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1277 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1278 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1280 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1281 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1282 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1286 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1288 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1289 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1290 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1291 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1292 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1293 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1294 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1295 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1296 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1297 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1298 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1299 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1300 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1301 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1302 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1303 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1304 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1305 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1306 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1307 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1308 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1310 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1311 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1312 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1316 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1318 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1319 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1320 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1323 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1324 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1325 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1327 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1328 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1329 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1333 dc424a06 2019-08-07 stsp # stage last hunk
1334 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1335 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1336 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1338 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1339 dc424a06 2019-08-07 stsp -----------------------------------------------
1340 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1347 dc424a06 2019-08-07 stsp -----------------------------------------------
1349 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1350 dc424a06 2019-08-07 stsp -----------------------------------------------
1351 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1360 dc424a06 2019-08-07 stsp -----------------------------------------------
1362 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1363 dc424a06 2019-08-07 stsp -----------------------------------------------
1364 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1370 dc424a06 2019-08-07 stsp -----------------------------------------------
1372 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1374 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1376 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1377 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1378 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1382 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1383 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1384 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1386 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1387 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1388 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1392 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1394 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1395 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1396 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1397 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1398 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1399 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1400 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1401 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1402 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1403 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1404 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1405 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1406 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1407 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1408 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1409 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1410 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1411 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1413 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1414 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1416 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1419 dc424a06 2019-08-07 stsp function test_stage_patch_added {
1420 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1421 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1423 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1425 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1426 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1430 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1431 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1433 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1434 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1435 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1437 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1438 b353a198 2019-08-07 stsp echo "stage this addition? [y/n/q] y" >> $testroot/stdout.expected
1439 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1441 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1442 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1443 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1447 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1448 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1449 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1451 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1452 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1453 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1457 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1459 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1460 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1461 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1462 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1463 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1464 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1465 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1466 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1467 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1468 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
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
1474 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1477 dc424a06 2019-08-07 stsp function test_stage_patch_removed {
1478 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
1479 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1481 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1483 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1484 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1488 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
1490 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1491 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1492 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
1494 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
1496 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
1497 b353a198 2019-08-07 stsp echo "stage deletion? [y/n/q] y" >> $testroot/stdout.expected
1498 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1500 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1501 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1502 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1506 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1507 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
1508 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1510 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1511 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1512 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1516 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1518 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1519 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1520 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1521 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
1522 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1523 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1524 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
1525 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
1526 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
1527 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
1528 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1530 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1531 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1533 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1536 b353a198 2019-08-07 stsp function test_stage_patch_quit {
1537 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
1539 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1540 b353a198 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1541 b353a198 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1542 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1544 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1546 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1547 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1551 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1552 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1553 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1555 2db2652d 2019-08-07 stsp # stage first hunk and quit; and don't pass a path argument
1556 b353a198 2019-08-07 stsp printf "y\nq\n" > $testroot/patchscript
1557 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1558 2db2652d 2019-08-07 stsp > $testroot/stdout)
1560 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1561 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1562 b353a198 2019-08-07 stsp test_done "$testroot" "1"
1565 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1566 b353a198 2019-08-07 stsp -----------------------------------------------
1567 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
1574 b353a198 2019-08-07 stsp -----------------------------------------------
1576 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1577 b353a198 2019-08-07 stsp -----------------------------------------------
1578 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
1587 b353a198 2019-08-07 stsp -----------------------------------------------
1589 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
1591 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1593 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1594 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1595 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1599 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1600 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1601 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1603 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1604 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1605 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1609 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1611 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1612 b353a198 2019-08-07 stsp > $testroot/stdout.expected
1613 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1614 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1615 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1616 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1617 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1618 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1619 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1620 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1621 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1622 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
1623 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
1624 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
1625 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
1626 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
1627 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1628 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1629 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1631 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1632 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1634 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1638 fccbfb98 2019-08-03 stsp run_test test_stage_basic
1639 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
1640 a4f692bb 2019-08-04 stsp run_test test_stage_list
1641 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
1642 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
1643 d3e7c587 2019-08-03 stsp run_test test_double_stage
1644 c363b2c1 2019-08-03 stsp run_test test_stage_status
1645 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
1646 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
1647 24278f30 2019-08-03 stsp run_test test_stage_revert
1648 408b4ebc 2019-08-03 stsp run_test test_stage_diff
1649 b9622844 2019-08-03 stsp run_test test_stage_histedit
1650 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
1651 a76c42e6 2019-08-03 stsp run_test test_stage_update
1652 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
1653 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
1654 dc424a06 2019-08-07 stsp run_test test_stage_patch
1655 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
1656 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
1657 b353a198 2019-08-07 stsp run_test test_stage_patch_quit