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 a4f692bb 2019-08-04 stsp function test_stage_list {
48 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
50 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
52 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
53 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
57 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
58 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
59 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
60 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
62 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
63 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
64 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
65 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
67 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
68 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
69 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
70 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
71 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
72 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
73 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
74 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
75 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
76 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
77 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
79 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
80 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
81 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
85 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
86 a4f692bb 2019-08-04 stsp > $testroot/stdout)
88 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
89 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
91 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
92 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
93 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
97 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
99 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
100 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
101 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
102 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
104 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
105 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
107 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
111 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
112 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
113 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
115 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
117 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
118 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
122 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
123 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
125 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
127 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
129 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
130 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
131 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
132 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
134 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
136 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
138 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
139 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
140 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
144 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
145 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
147 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
148 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
149 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
153 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
154 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
155 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
157 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
159 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
160 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
161 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
164 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
166 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
167 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
169 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
172 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
173 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
174 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
176 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
178 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
179 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
183 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
184 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
186 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
188 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
189 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
190 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
192 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
193 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
194 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
198 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
199 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
200 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
202 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
204 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
205 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
206 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
209 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
211 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
212 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
214 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
218 d3e7c587 2019-08-03 stsp function test_double_stage {
219 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
221 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
223 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
224 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
227 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
228 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
229 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
230 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
231 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
233 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
234 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
235 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
237 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
238 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
239 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
243 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
245 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
246 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
247 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
250 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
251 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
253 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
254 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
255 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
259 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
260 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
261 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
263 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
264 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
265 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
269 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
270 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
272 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
273 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
274 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
275 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
277 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
278 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
279 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
283 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
284 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
285 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
287 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
288 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
290 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
291 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
293 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
296 c363b2c1 2019-08-03 stsp function test_stage_status {
297 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
299 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
301 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
302 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
306 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
307 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
308 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
309 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
310 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
311 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
312 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
313 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
315 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
316 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
317 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
318 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
319 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
320 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
321 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
323 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
324 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
326 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
327 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
332 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
333 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
335 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
336 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
337 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
338 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
339 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
340 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
342 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
343 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
345 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
346 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
347 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
351 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
352 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
353 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
354 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
355 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
357 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
358 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
359 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
363 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
364 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
365 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
366 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
367 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
369 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
370 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
372 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
376 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
377 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
379 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
381 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
382 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
386 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
387 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
388 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
389 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
391 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
393 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
394 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
395 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
396 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
397 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
398 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
399 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
401 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
402 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
403 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
406 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
408 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
409 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
410 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
415 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
416 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
417 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
419 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
420 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
422 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
423 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
425 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
428 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
429 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
431 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
433 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
434 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
438 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
439 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
440 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
441 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
443 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
445 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
446 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
448 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
449 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
450 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
453 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
454 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
456 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
457 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
458 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
461 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
462 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
464 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
465 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
466 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
470 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
471 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
472 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
473 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
475 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
476 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
477 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
480 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
482 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
483 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
484 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
489 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
490 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
491 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
493 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
494 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
496 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
497 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
499 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
502 24278f30 2019-08-03 stsp function test_stage_revert {
503 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
505 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
507 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
508 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
512 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
513 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
514 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
515 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
516 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
518 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
519 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
521 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
523 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
524 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
525 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
529 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
530 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
532 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
533 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
534 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
538 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
539 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
540 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
542 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
543 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
544 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
548 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
549 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
550 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
551 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
552 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
554 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
555 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
556 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
560 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
562 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
563 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
564 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
568 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
569 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
571 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
572 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
573 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
577 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
578 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
579 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
581 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
582 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
583 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
587 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
588 24278f30 2019-08-03 stsp 2> $testroot/stderr)
590 24278f30 2019-08-03 stsp if [ "$ret" == "0" ]; then
591 24278f30 2019-08-03 stsp echo "revert command succeeded unexpectedly" >&2
592 24278f30 2019-08-03 stsp test_done "$testroot" "1"
596 24278f30 2019-08-03 stsp echo "got: beta: file is staged" > $testroot/stderr.expected
597 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
599 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
600 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
601 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
605 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
607 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
608 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
609 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
613 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
614 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
616 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
617 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
618 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
622 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
623 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
624 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
626 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
627 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
628 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
632 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
633 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
634 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
635 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
636 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
638 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
639 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
640 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
644 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
646 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
647 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
648 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
652 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
653 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
655 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
656 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
657 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
661 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
662 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
663 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
665 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
666 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
667 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
671 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
672 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
673 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
674 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
675 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
677 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
678 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
680 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
683 408b4ebc 2019-08-03 stsp function test_stage_diff {
684 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
685 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
687 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
689 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
690 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
694 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
695 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
696 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
697 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
699 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
700 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
701 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
703 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
704 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
705 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
709 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
710 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
711 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
712 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
714 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
715 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
716 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
718 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
719 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
720 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
724 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
725 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
727 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
729 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
730 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
731 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
732 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
733 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
734 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
735 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
736 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
737 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
738 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
739 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
740 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
741 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
742 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
743 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
744 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
745 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
746 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
747 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
749 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
751 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
752 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
753 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
757 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
759 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
760 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
761 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
762 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
763 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
764 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
765 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
766 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
767 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
768 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
769 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
770 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
771 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
772 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
773 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
774 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
775 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
776 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
777 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
778 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
779 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
780 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
781 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
782 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
783 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
784 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
785 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
786 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
787 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
789 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
791 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
792 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
794 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
798 b9622844 2019-08-03 stsp function test_stage_histedit {
799 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
800 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
802 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
804 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
805 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
809 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
810 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
812 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
813 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
814 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
815 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
816 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
817 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
819 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
820 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
821 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
823 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
824 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
826 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
827 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
829 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
830 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
831 b9622844 2019-08-03 stsp test_done "$testroot" "1"
835 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
836 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
838 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
840 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
841 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
842 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
845 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
847 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
848 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
850 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
854 243d7cf1 2019-08-03 stsp function test_stage_rebase {
855 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
857 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
858 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
859 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
861 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
862 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
863 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
864 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
865 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
867 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
868 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
870 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
871 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
872 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
873 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
875 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
877 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
878 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
882 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
883 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
885 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
886 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
888 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
889 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
890 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
894 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
895 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
897 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
899 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
900 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
901 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
904 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
906 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
907 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
909 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
912 a76c42e6 2019-08-03 stsp function test_stage_update {
913 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
915 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
917 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
918 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
922 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
923 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
925 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
926 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
928 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
929 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
931 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
932 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
933 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
937 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
938 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
940 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
942 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
943 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
944 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
947 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
949 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
950 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
952 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
955 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
956 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
958 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
960 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
961 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
965 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
966 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
967 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
968 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
969 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
971 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
972 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
973 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
975 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
976 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
977 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
981 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
982 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
984 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
986 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
987 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
988 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
991 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
993 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
994 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
996 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
999 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1000 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1001 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1003 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1005 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1006 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1010 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1011 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1012 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1013 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1014 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1015 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1017 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1018 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1019 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1020 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1021 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1022 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1024 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1025 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1026 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1027 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1029 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1030 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1032 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1033 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1034 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1038 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1039 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1040 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1041 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1042 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1044 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1046 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1047 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1048 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1052 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1053 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1055 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1056 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1057 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1058 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1059 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1060 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1061 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1062 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1063 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1064 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1065 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1066 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1067 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1068 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1069 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1070 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1071 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1072 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1073 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1074 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1075 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1076 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1077 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1078 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1079 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1080 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1081 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1082 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1083 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1085 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1087 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1088 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1089 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1093 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1094 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1095 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1097 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1098 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1100 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1101 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1103 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1106 fccbfb98 2019-08-03 stsp run_test test_stage_basic
1107 a4f692bb 2019-08-04 stsp run_test test_stage_list
1108 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
1109 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
1110 d3e7c587 2019-08-03 stsp run_test test_double_stage
1111 c363b2c1 2019-08-03 stsp run_test test_stage_status
1112 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
1113 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
1114 24278f30 2019-08-03 stsp run_test test_stage_revert
1115 408b4ebc 2019-08-03 stsp run_test test_stage_diff
1116 b9622844 2019-08-03 stsp run_test test_stage_histedit
1117 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
1118 a76c42e6 2019-08-03 stsp run_test test_stage_update
1119 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
1120 5f8a88c6 2019-08-03 stsp run_test test_stage_commit