3 fccbfb98 2019-08-03 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 fccbfb98 2019-08-03 stsp # Permission to use, copy, modify, and distribute this software for any
6 fccbfb98 2019-08-03 stsp # purpose with or without fee is hereby granted, provided that the above
7 fccbfb98 2019-08-03 stsp # copyright notice and this permission notice appear in all copies.
9 fccbfb98 2019-08-03 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 fccbfb98 2019-08-03 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 fccbfb98 2019-08-03 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 fccbfb98 2019-08-03 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 fccbfb98 2019-08-03 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 fccbfb98 2019-08-03 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 fccbfb98 2019-08-03 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 fccbfb98 2019-08-03 stsp . ./common.sh
19 fccbfb98 2019-08-03 stsp function test_stage_basic {
20 fccbfb98 2019-08-03 stsp local testroot=`test_init stage_basic`
22 fccbfb98 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
25 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
29 fccbfb98 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
30 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
31 fccbfb98 2019-08-03 stsp echo "new file" > $testroot/wt/foo
32 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
34 88d0e355 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
35 88d0e355 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
36 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
37 ec9d9b2f 2019-08-08 stsp (cd $testroot/wt && got stage > $testroot/stdout)
39 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
41 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
42 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
44 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
47 31b20a6e 2019-08-06 stsp function test_stage_no_changes {
48 31b20a6e 2019-08-06 stsp local testroot=`test_init stage_no_changes`
50 31b20a6e 2019-08-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
52 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
53 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
57 31b20a6e 2019-08-06 stsp (cd $testroot/wt && got stage alpha beta > $testroot/stdout \
58 31b20a6e 2019-08-06 stsp 2> $testroot/stderr)
60 31b20a6e 2019-08-06 stsp if [ "$ret" == "0" ]; then
61 31b20a6e 2019-08-06 stsp echo "got stage command succeeded unexpectedly" >&2
62 31b20a6e 2019-08-06 stsp test_done "$testroot" "1"
66 2db2652d 2019-08-07 stsp echo "got: no changes to stage" > $testroot/stderr.expected
68 31b20a6e 2019-08-06 stsp cmp -s $testroot/stderr.expected $testroot/stderr
70 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
71 31b20a6e 2019-08-06 stsp diff -u $testroot/stderr.expected $testroot/stderr
72 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
76 31b20a6e 2019-08-06 stsp echo -n > $testroot/stdout.expected
77 31b20a6e 2019-08-06 stsp cmp -s $testroot/stdout.expected $testroot/stdout
79 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
80 31b20a6e 2019-08-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
82 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
85 8b13ce36 2019-08-08 stsp function test_stage_unversioned {
86 8b13ce36 2019-08-08 stsp local testroot=`test_init stage_unversioned`
88 8b13ce36 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
90 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
91 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
95 8b13ce36 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
96 8b13ce36 2019-08-08 stsp touch $testroot/wt/unversioned-file
98 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
99 8b13ce36 2019-08-08 stsp echo "M alpha" > $testroot/stdout.expected
100 8b13ce36 2019-08-08 stsp echo "? unversioned-file" >> $testroot/stdout.expected
101 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
103 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
104 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
105 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
109 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage > $testroot/stdout)
111 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
112 8b13ce36 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
113 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
117 8b13ce36 2019-08-08 stsp echo " M alpha" > $testroot/stdout.expected
118 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
120 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
121 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
122 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
126 8b13ce36 2019-08-08 stsp echo "modified file again" > $testroot/wt/alpha
128 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage unversioned-file > $testroot/stdout \
129 8b13ce36 2019-08-08 stsp 2> $testroot/stderr)
131 8b13ce36 2019-08-08 stsp if [ "$ret" == "0" ]; then
132 8b13ce36 2019-08-08 stsp echo "got stage command succeed unexpectedly" >&2
133 8b13ce36 2019-08-08 stsp test_done "$testroot" "1"
137 8b13ce36 2019-08-08 stsp echo "got: no changes to stage" > $testroot/stderr.expected
138 8b13ce36 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
140 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
141 8b13ce36 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
143 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
147 8564cb21 2019-08-08 stsp function test_stage_nonexistent {
148 8564cb21 2019-08-08 stsp local testroot=`test_init stage_nonexistent`
150 8564cb21 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
152 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
153 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
157 8564cb21 2019-08-08 stsp (cd $testroot/wt && got stage nonexistent-file \
158 8564cb21 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
159 2a06fe5f 2019-08-24 stsp echo "got: nonexistent-file: No such file or directory" \
160 2a06fe5f 2019-08-24 stsp > $testroot/stderr.expected
161 8564cb21 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
163 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
164 8564cb21 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
166 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
169 a4f692bb 2019-08-04 stsp function test_stage_list {
170 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
172 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
174 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
175 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
179 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
180 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
181 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
182 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
184 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
185 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
186 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
187 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
189 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
190 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
191 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
192 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
193 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
194 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
195 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
196 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
197 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
198 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
199 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
201 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
202 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
203 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
207 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
208 a4f692bb 2019-08-04 stsp > $testroot/stdout)
210 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
211 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
213 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
214 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
215 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
219 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
221 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
222 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
223 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
224 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
226 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
227 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
229 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
233 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
234 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
235 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
237 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
239 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
240 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
244 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
245 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
247 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
249 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
251 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
252 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
253 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
254 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
256 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
258 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
260 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
261 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
262 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
266 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
267 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
269 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
270 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
271 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
275 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
276 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
277 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
279 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
281 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
282 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
283 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
286 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
288 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
289 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
291 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
294 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
295 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
296 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
298 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
300 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
301 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
305 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
306 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
308 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
310 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
311 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
312 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
314 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
315 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
316 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
320 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
321 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
322 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
324 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
326 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
327 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
331 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
333 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
334 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
336 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
340 d3e7c587 2019-08-03 stsp function test_double_stage {
341 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
343 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
345 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
346 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
349 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
350 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
351 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
352 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
353 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
355 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
356 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
357 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
359 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
360 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
361 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
365 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
367 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
368 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
369 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
372 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
373 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
375 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
376 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
377 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
381 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
382 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
383 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
385 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
386 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
387 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
391 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
392 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
394 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
395 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
396 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
397 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
399 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
400 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
401 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
405 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
406 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
407 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
409 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
410 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
412 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
413 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
415 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
418 c363b2c1 2019-08-03 stsp function test_stage_status {
419 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
421 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
423 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
424 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
428 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
429 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
430 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
431 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
432 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
433 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
434 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
435 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
437 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
438 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
439 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
440 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
441 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
442 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
443 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
445 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
446 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
448 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
449 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
450 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
454 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
455 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
457 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
458 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
459 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
460 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
461 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
462 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
464 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
465 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
467 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
468 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
469 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
473 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
474 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
475 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
476 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
477 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
479 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
480 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
481 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
485 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
486 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
487 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
488 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
489 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
491 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
492 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
494 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
498 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
499 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
501 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
503 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
504 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
508 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
509 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
510 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
511 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
513 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
515 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
516 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
517 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
518 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
519 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
520 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
521 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
523 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
524 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
525 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
528 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
530 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
531 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
532 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
537 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
538 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
539 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
541 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
542 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
544 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
545 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
547 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
550 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
551 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
553 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
555 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
556 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
560 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
561 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
562 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
563 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
565 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
567 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
568 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
570 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
571 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
572 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
575 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
576 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
578 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
579 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
580 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
583 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
584 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
586 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
587 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
588 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
592 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
593 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
594 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
595 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
597 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
598 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
599 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
602 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
604 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
605 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
606 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
611 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
612 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
613 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
615 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
616 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
618 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
619 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
621 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
624 24278f30 2019-08-03 stsp function test_stage_revert {
625 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
627 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
629 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
630 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
634 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
635 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
636 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
637 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
638 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
640 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
641 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
643 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $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 alpha" > $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 "modified alpha" > $testroot/content.expected
661 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $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 'MA 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 alpha > $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 "modified alpha" > $testroot/content.expected
700 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $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 (cd $testroot/wt && got revert beta > $testroot/stdout \
710 24278f30 2019-08-03 stsp 2> $testroot/stderr)
712 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
713 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
714 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
718 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stdout.expected
719 d3bcc3d1 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
721 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
722 d3bcc3d1 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
723 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
727 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
728 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
730 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
731 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
732 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
736 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
738 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
739 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
740 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
744 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
745 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
747 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
748 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
749 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
753 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
754 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
755 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
757 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
758 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
759 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
763 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
764 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
765 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
766 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
767 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
769 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
770 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
771 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
775 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
777 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
778 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
779 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
783 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
784 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
786 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
787 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
788 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
792 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
793 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
794 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
796 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
797 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
798 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
802 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
803 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
804 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
805 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
806 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
808 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
809 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
810 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
814 0f6d7415 2019-08-08 stsp echo "modified file again" >> $testroot/wt/alpha
815 0f6d7415 2019-08-08 stsp echo "modified added file again" >> $testroot/wt/foo
817 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout \
818 0f6d7415 2019-08-08 stsp 2> $testroot/stderr)
820 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
821 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
822 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
826 0f6d7415 2019-08-08 stsp echo "R alpha" > $testroot/stdout.expected
827 d3bcc3d1 2019-08-08 stsp echo "R foo" >> $testroot/stdout.expected
828 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
830 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
831 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
832 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
836 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
837 0f6d7415 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
839 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
840 0f6d7415 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
841 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
845 0f6d7415 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
846 0f6d7415 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
847 d3bcc3d1 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
848 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
849 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
851 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
852 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
854 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
857 408b4ebc 2019-08-03 stsp function test_stage_diff {
858 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
859 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
861 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
863 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
864 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
868 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
869 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
870 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
871 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
873 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
874 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
875 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
877 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
878 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
879 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
883 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
884 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
885 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
886 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
888 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
889 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
890 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
892 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
893 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
894 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
898 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
899 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
901 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
903 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
904 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
905 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
906 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
907 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
908 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
909 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
910 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
911 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
912 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
913 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
914 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
915 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
916 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
917 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
918 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
919 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
920 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
921 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
922 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
923 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
925 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
927 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
928 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
929 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
933 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
935 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
936 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
937 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
938 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
939 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
940 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
941 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
942 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
943 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
944 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
945 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
946 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
947 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
948 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
949 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
950 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
951 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
952 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
953 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
954 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
955 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
956 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
957 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
958 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
959 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
960 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
961 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
962 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
963 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
965 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
967 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
968 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
970 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
974 b9622844 2019-08-03 stsp function test_stage_histedit {
975 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
976 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
978 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
980 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
981 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
985 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
986 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
988 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
989 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
990 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
991 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
992 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
993 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
995 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
996 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
997 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
999 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
1000 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1002 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1003 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1005 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
1006 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
1007 b9622844 2019-08-03 stsp test_done "$testroot" "1"
1011 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
1012 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1014 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1016 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1017 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1018 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1021 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1023 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1024 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1026 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1030 243d7cf1 2019-08-03 stsp function test_stage_rebase {
1031 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
1033 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1034 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1035 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1037 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1038 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1039 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1040 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1041 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1043 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1044 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
1046 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
1047 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1048 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1049 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
1051 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1053 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1054 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1058 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1059 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1061 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
1062 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1064 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
1065 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
1066 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
1070 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
1071 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1073 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1075 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1076 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1077 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1080 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1082 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1083 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1085 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1088 a76c42e6 2019-08-03 stsp function test_stage_update {
1089 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1091 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1093 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1094 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1098 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1099 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1101 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1102 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1104 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1105 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1107 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
1108 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1109 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1113 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1114 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1116 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1118 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1119 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1120 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1123 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1125 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1126 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1128 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1131 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
1132 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1134 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1136 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1137 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1141 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1142 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1143 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1144 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1145 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1147 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1148 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1149 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1151 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
1152 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1153 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1157 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1158 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1160 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1162 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1163 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1164 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1167 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1169 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1170 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1172 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1175 0f1cfa7f 2019-08-08 stsp function test_stage_commit_out_of_date {
1176 0f1cfa7f 2019-08-08 stsp local testroot=`test_init stage_commit_out_of_date`
1178 0f1cfa7f 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1180 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1181 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1185 0f1cfa7f 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
1186 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
1187 0f1cfa7f 2019-08-08 stsp echo "new file" > $testroot/wt/foo
1188 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
1189 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1191 0f1cfa7f 2019-08-08 stsp echo "changed file" > $testroot/repo/alpha
1192 0f1cfa7f 2019-08-08 stsp git_commit $testroot/repo -m "changed alpha in repo"
1194 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1195 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1197 0f1cfa7f 2019-08-08 stsp if [ "$ret" == "0" ]; then
1198 0f1cfa7f 2019-08-08 stsp echo "got commit command succeeded unexpectedly" >&2
1199 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "1"
1203 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1204 0f1cfa7f 2019-08-08 stsp echo -n "got: work tree must be updated before these changes " \
1205 0f1cfa7f 2019-08-08 stsp > $testroot/stderr.expected
1206 0f1cfa7f 2019-08-08 stsp echo "can be committed" >> $testroot/stderr.expected
1208 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1210 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1211 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1212 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1215 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1217 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1218 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1219 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1223 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout \
1224 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1225 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1226 0f1cfa7f 2019-08-08 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1228 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1230 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1231 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1232 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1235 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1237 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1238 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1239 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1243 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got unstage > /dev/null)
1244 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
1246 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1247 0f1cfa7f 2019-08-08 stsp echo "got update command failed unexpectedly" >&2
1248 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1252 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1253 0f1cfa7f 2019-08-08 stsp echo "C alpha" > $testroot/stdout.expected
1254 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1255 0f1cfa7f 2019-08-08 stsp echo "A foo" >> $testroot/stdout.expected
1256 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1258 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1259 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1260 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1264 0f1cfa7f 2019-08-08 stsp # resolve conflict
1265 0f1cfa7f 2019-08-08 stsp echo "resolved file" > $testroot/wt/alpha
1267 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
1269 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1271 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1272 0f1cfa7f 2019-08-08 stsp echo "got commit command failed unexpectedly" >&2
1273 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1277 0f1cfa7f 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1278 0f1cfa7f 2019-08-08 stsp echo "A foo" > $testroot/stdout.expected
1279 0f1cfa7f 2019-08-08 stsp echo "M alpha" >> $testroot/stdout.expected
1280 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1281 0f1cfa7f 2019-08-08 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1282 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1284 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1285 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1287 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1291 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1292 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1293 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1295 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1297 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1298 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1302 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1303 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1304 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1305 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1306 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1307 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1309 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1310 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1311 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1312 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1313 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1314 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1316 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1317 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1318 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1319 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1321 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1322 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1324 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1325 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1326 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1330 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1331 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1332 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1333 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1334 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1336 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1338 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1339 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1340 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1344 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1345 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1347 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1348 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1349 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1350 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1351 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1352 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1353 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1354 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1355 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1356 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1357 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1358 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1359 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1360 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1361 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1362 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1363 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1364 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1365 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1366 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1367 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1368 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1369 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1370 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1371 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1372 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1373 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1374 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1375 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1377 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1379 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1380 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1381 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1385 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1386 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1387 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1389 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1390 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1392 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1393 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1395 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1398 dc424a06 2019-08-07 stsp function test_stage_patch {
1399 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1401 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1402 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1403 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1404 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1406 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1408 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1409 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1413 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1414 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1415 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1417 dc424a06 2019-08-07 stsp # don't stage any hunks
1418 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1419 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1420 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1422 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1423 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1424 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1427 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1428 dc424a06 2019-08-07 stsp -----------------------------------------------
1429 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1436 dc424a06 2019-08-07 stsp -----------------------------------------------
1437 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1438 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1439 dc424a06 2019-08-07 stsp -----------------------------------------------
1440 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1449 dc424a06 2019-08-07 stsp -----------------------------------------------
1450 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1451 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1452 dc424a06 2019-08-07 stsp -----------------------------------------------
1453 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1459 dc424a06 2019-08-07 stsp -----------------------------------------------
1460 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1461 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1463 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1465 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1466 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1467 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1471 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1472 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1473 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1475 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1476 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1477 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1481 dc424a06 2019-08-07 stsp # stage middle hunk
1482 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1483 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1484 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1486 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1487 dc424a06 2019-08-07 stsp -----------------------------------------------
1488 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1495 dc424a06 2019-08-07 stsp -----------------------------------------------
1496 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1497 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1498 dc424a06 2019-08-07 stsp -----------------------------------------------
1499 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1508 dc424a06 2019-08-07 stsp -----------------------------------------------
1509 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1510 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1511 dc424a06 2019-08-07 stsp -----------------------------------------------
1512 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1518 dc424a06 2019-08-07 stsp -----------------------------------------------
1519 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1520 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1522 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1524 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1525 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1526 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1530 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1531 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1532 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1534 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1535 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1536 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1540 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1542 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1543 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1544 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1545 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1546 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1547 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1548 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1549 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1550 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1551 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1552 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1553 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1554 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1555 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1556 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1557 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1558 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1559 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1560 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1561 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1562 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1564 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1565 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1566 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1570 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1572 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1573 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1574 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1577 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1578 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1579 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1581 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1582 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1583 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1587 dc424a06 2019-08-07 stsp # stage last hunk
1588 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1589 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1590 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1592 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1593 dc424a06 2019-08-07 stsp -----------------------------------------------
1594 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1601 dc424a06 2019-08-07 stsp -----------------------------------------------
1602 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1603 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1604 dc424a06 2019-08-07 stsp -----------------------------------------------
1605 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1614 dc424a06 2019-08-07 stsp -----------------------------------------------
1615 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1616 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1617 dc424a06 2019-08-07 stsp -----------------------------------------------
1618 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1624 dc424a06 2019-08-07 stsp -----------------------------------------------
1625 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1626 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1628 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1630 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1631 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1632 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1636 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1637 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1638 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1640 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1641 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1642 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1646 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1648 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1649 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1650 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1651 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1652 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1653 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1654 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1655 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1656 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1657 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1658 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1659 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1660 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1661 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1662 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1663 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1664 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1665 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1667 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1668 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1670 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1673 af5a81b2 2019-08-08 stsp function test_stage_patch_twice {
1674 af5a81b2 2019-08-08 stsp local testroot=`test_init stage_patch_twice`
1676 af5a81b2 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1677 af5a81b2 2019-08-08 stsp (cd $testroot/repo && git add numbers)
1678 af5a81b2 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
1679 af5a81b2 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1681 af5a81b2 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1683 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1684 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1688 af5a81b2 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1689 af5a81b2 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1690 af5a81b2 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1692 af5a81b2 2019-08-08 stsp # stage middle hunk
1693 af5a81b2 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
1694 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1695 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1697 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1698 af5a81b2 2019-08-08 stsp -----------------------------------------------
1699 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1706 af5a81b2 2019-08-08 stsp -----------------------------------------------
1707 af5a81b2 2019-08-08 stsp M numbers (change 1 of 3)
1708 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1709 af5a81b2 2019-08-08 stsp -----------------------------------------------
1710 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1719 af5a81b2 2019-08-08 stsp -----------------------------------------------
1720 af5a81b2 2019-08-08 stsp M numbers (change 2 of 3)
1721 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1722 af5a81b2 2019-08-08 stsp -----------------------------------------------
1723 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1729 af5a81b2 2019-08-08 stsp -----------------------------------------------
1730 af5a81b2 2019-08-08 stsp M numbers (change 3 of 3)
1731 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1733 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1735 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1736 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1737 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1741 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1742 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1743 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1745 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1746 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1747 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1751 af5a81b2 2019-08-08 stsp # stage last hunk
1752 af5a81b2 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
1753 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1754 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1756 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1757 af5a81b2 2019-08-08 stsp -----------------------------------------------
1758 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@ b
1765 af5a81b2 2019-08-08 stsp -----------------------------------------------
1766 af5a81b2 2019-08-08 stsp M numbers (change 1 of 2)
1767 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1768 af5a81b2 2019-08-08 stsp -----------------------------------------------
1769 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@ b
1775 af5a81b2 2019-08-08 stsp -----------------------------------------------
1776 af5a81b2 2019-08-08 stsp M numbers (change 2 of 2)
1777 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1779 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1781 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1782 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1783 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1787 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1788 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1789 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1791 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1792 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1793 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1797 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1799 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1800 af5a81b2 2019-08-08 stsp > $testroot/stdout.expected
1801 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1802 af5a81b2 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
1803 af5a81b2 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1804 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1805 af5a81b2 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1806 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1807 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1808 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1809 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1810 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1811 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1820 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1827 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1829 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1830 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1831 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1835 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1837 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
1838 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1839 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
1840 af5a81b2 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
1841 af5a81b2 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
1842 af5a81b2 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
1843 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1844 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1845 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1846 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1854 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1856 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1857 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1859 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1862 dc424a06 2019-08-07 stsp function test_stage_patch_added {
1863 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1864 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1866 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1868 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1869 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1873 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1874 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1876 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1877 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1878 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1880 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1881 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1882 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1884 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1885 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1886 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1890 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1891 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1892 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1894 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1895 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1896 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1900 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1902 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1903 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1904 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1905 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1906 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1907 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1908 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1909 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1910 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1911 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1912 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1914 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1915 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1917 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1920 e70a841e 2019-08-08 stsp function test_stage_patch_added_twice {
1921 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_added_twice`
1922 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1924 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1926 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1927 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1931 e70a841e 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
1932 e70a841e 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1934 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1935 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1936 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout)
1938 e70a841e 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
1939 e70a841e 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1940 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1942 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1943 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1944 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1948 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1949 e70a841e 2019-08-08 stsp echo " A epsilon/new" > $testroot/stdout.expected
1950 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1952 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1953 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1954 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1958 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1959 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout 2> $testroot/stderr)
1961 e70a841e 2019-08-08 stsp if [ "$ret" == "0" ]; then
1962 e70a841e 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
1963 e70a841e 2019-08-08 stsp test_done "$testroot" "1"
1967 e70a841e 2019-08-08 stsp echo "got: epsilon/new: no changes to stage" > $testroot/stderr.expected
1968 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1970 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1971 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1972 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1976 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
1977 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1979 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1980 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1982 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1985 dc424a06 2019-08-07 stsp function test_stage_patch_removed {
1986 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
1987 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1989 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1991 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1992 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1996 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
1998 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1999 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2000 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
2002 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
2004 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
2005 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2006 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2008 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2009 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2010 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2014 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2015 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
2016 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2018 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2019 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2020 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2024 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2026 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2027 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
2028 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2029 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
2030 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
2031 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2032 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
2033 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
2034 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
2035 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
2036 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2038 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2039 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2041 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2044 e70a841e 2019-08-08 stsp function test_stage_patch_removed_twice {
2045 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_removed_twice`
2046 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2048 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2050 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2051 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2055 e70a841e 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
2057 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2058 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2059 e70a841e 2019-08-08 stsp beta > $testroot/stdout)
2061 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2063 e70a841e 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
2064 e70a841e 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2065 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2067 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2068 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2069 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2073 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2074 e70a841e 2019-08-08 stsp echo " D beta" > $testroot/stdout.expected
2075 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2077 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2078 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2079 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2083 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p beta \
2084 e70a841e 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2086 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2087 e70a841e 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
2088 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2092 e70a841e 2019-08-08 stsp echo -n > $testroot/stderr.expected
2093 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2095 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2096 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2097 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2101 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2102 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2104 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2105 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2107 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2110 b353a198 2019-08-07 stsp function test_stage_patch_quit {
2111 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
2113 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
2114 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2115 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2116 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2117 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2119 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2121 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2122 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2126 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2127 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2128 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2129 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
2131 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
2132 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
2133 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
2134 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2135 2db2652d 2019-08-07 stsp > $testroot/stdout)
2137 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2138 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
2139 b353a198 2019-08-07 stsp test_done "$testroot" "1"
2142 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
2143 b353a198 2019-08-07 stsp -----------------------------------------------
2144 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
2151 b353a198 2019-08-07 stsp -----------------------------------------------
2152 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
2153 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
2154 b353a198 2019-08-07 stsp -----------------------------------------------
2155 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
2164 b353a198 2019-08-07 stsp -----------------------------------------------
2165 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
2166 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
2168 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
2170 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2172 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2173 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2174 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2178 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2179 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
2180 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
2181 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2183 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2184 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2185 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2189 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2191 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2192 b353a198 2019-08-07 stsp > $testroot/stdout.expected
2193 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2194 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
2195 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
2196 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2197 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2198 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
2199 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2200 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
2201 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
2202 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
2203 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
2204 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
2205 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
2206 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
2207 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
2208 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
2209 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2211 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2212 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2214 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2218 eba70f38 2019-08-08 stsp function test_stage_patch_incomplete_script {
2219 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
2221 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
2222 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2223 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2224 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2225 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2227 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2229 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2230 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2234 eba70f38 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2235 eba70f38 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2236 eba70f38 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2238 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
2239 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2240 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2241 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2243 eba70f38 2019-08-08 stsp if [ "$ret" == "0" ]; then
2244 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2245 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
2248 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
2249 eba70f38 2019-08-08 stsp -----------------------------------------------
2250 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
2257 eba70f38 2019-08-08 stsp -----------------------------------------------
2258 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
2259 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
2260 eba70f38 2019-08-08 stsp -----------------------------------------------
2261 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
2270 eba70f38 2019-08-08 stsp -----------------------------------------------
2271 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
2273 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
2274 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
2275 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2277 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2278 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2279 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2283 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2285 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2286 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2287 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2291 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2292 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
2293 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2295 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2296 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2297 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2301 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2302 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
2303 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2305 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2306 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2308 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2312 fccbfb98 2019-08-03 stsp run_test test_stage_basic
2313 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
2314 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
2315 8564cb21 2019-08-08 stsp run_test test_stage_nonexistent
2316 a4f692bb 2019-08-04 stsp run_test test_stage_list
2317 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
2318 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
2319 d3e7c587 2019-08-03 stsp run_test test_double_stage
2320 c363b2c1 2019-08-03 stsp run_test test_stage_status
2321 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
2322 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
2323 24278f30 2019-08-03 stsp run_test test_stage_revert
2324 408b4ebc 2019-08-03 stsp run_test test_stage_diff
2325 b9622844 2019-08-03 stsp run_test test_stage_histedit
2326 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
2327 a76c42e6 2019-08-03 stsp run_test test_stage_update
2328 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
2329 0f1cfa7f 2019-08-08 stsp run_test test_stage_commit_out_of_date
2330 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
2331 dc424a06 2019-08-07 stsp run_test test_stage_patch
2332 af5a81b2 2019-08-08 stsp run_test test_stage_patch_twice
2333 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
2334 e70a841e 2019-08-08 stsp run_test test_stage_patch_added_twice
2335 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
2336 e70a841e 2019-08-08 stsp run_test test_stage_patch_removed_twice
2337 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
2338 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script