3 a129376b 2019-03-28 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 a129376b 2019-03-28 stsp # Permission to use, copy, modify, and distribute this software for any
6 a129376b 2019-03-28 stsp # purpose with or without fee is hereby granted, provided that the above
7 a129376b 2019-03-28 stsp # copyright notice and this permission notice appear in all copies.
9 a129376b 2019-03-28 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 a129376b 2019-03-28 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 a129376b 2019-03-28 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 a129376b 2019-03-28 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 a129376b 2019-03-28 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 a129376b 2019-03-28 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 a129376b 2019-03-28 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 a129376b 2019-03-28 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_revert_basic() {
20 a129376b 2019-03-28 stsp local testroot=`test_init revert_basic`
22 a129376b 2019-03-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
29 5e54fb30 2019-05-31 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
31 5e54fb30 2019-05-31 stsp echo 'R epsilon/zeta' > $testroot/stdout.expected
33 5e54fb30 2019-05-31 stsp (cd $testroot/wt && got revert epsilon/zeta > $testroot/stdout)
35 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
37 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
38 a129376b 2019-03-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
39 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
43 5e54fb30 2019-05-31 stsp echo "zeta" > $testroot/content.expected
44 5e54fb30 2019-05-31 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
46 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
48 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
49 a129376b 2019-03-28 stsp diff -u $testroot/content.expected $testroot/content
51 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
55 f6cae3ed 2020-09-13 naddy test_revert_rm() {
56 a129376b 2019-03-28 stsp local testroot=`test_init revert_rm`
58 a129376b 2019-03-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
60 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
61 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
65 a129376b 2019-03-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
67 a129376b 2019-03-28 stsp echo 'R beta' > $testroot/stdout.expected
69 a129376b 2019-03-28 stsp (cd $testroot/wt && got revert beta > $testroot/stdout)
71 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
73 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
74 a129376b 2019-03-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
75 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
79 a129376b 2019-03-28 stsp echo "beta" > $testroot/content.expected
80 a129376b 2019-03-28 stsp cat $testroot/wt/beta > $testroot/content
82 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
84 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
85 a129376b 2019-03-28 stsp diff -u $testroot/content.expected $testroot/content
87 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
90 f6cae3ed 2020-09-13 naddy test_revert_add() {
91 a129376b 2019-03-28 stsp local testroot=`test_init revert_add`
93 a129376b 2019-03-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
95 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
96 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
100 a129376b 2019-03-28 stsp echo "new file" > $testroot/wt/new
101 a129376b 2019-03-28 stsp (cd $testroot/wt && got add new >/dev/null)
103 a129376b 2019-03-28 stsp echo 'R new' > $testroot/stdout.expected
105 a129376b 2019-03-28 stsp (cd $testroot/wt && got revert new > $testroot/stdout)
107 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
109 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
110 a129376b 2019-03-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
111 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
115 a129376b 2019-03-28 stsp echo "new file" > $testroot/content.expected
116 a129376b 2019-03-28 stsp cat $testroot/wt/new > $testroot/content
118 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
120 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
121 a129376b 2019-03-28 stsp diff -u $testroot/content.expected $testroot/content
122 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
126 a129376b 2019-03-28 stsp echo '? new' > $testroot/stdout.expected
128 a129376b 2019-03-28 stsp (cd $testroot/wt && got status > $testroot/stdout)
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
132 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
133 a129376b 2019-03-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
135 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
138 f6cae3ed 2020-09-13 naddy test_revert_multiple() {
139 e20a8b6f 2019-06-04 stsp local testroot=`test_init revert_multiple`
141 e20a8b6f 2019-06-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
144 e20a8b6f 2019-06-04 stsp test_done "$testroot" "$ret"
148 e20a8b6f 2019-06-04 stsp echo "modified alpha" > $testroot/wt/alpha
149 e20a8b6f 2019-06-04 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
151 e20a8b6f 2019-06-04 stsp echo 'R alpha' > $testroot/stdout.expected
152 e20a8b6f 2019-06-04 stsp echo 'R epsilon/zeta' >> $testroot/stdout.expected
154 e20a8b6f 2019-06-04 stsp (cd $testroot/wt && got revert alpha epsilon/zeta > $testroot/stdout)
156 e20a8b6f 2019-06-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
158 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
159 e20a8b6f 2019-06-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
160 e20a8b6f 2019-06-04 stsp test_done "$testroot" "$ret"
164 e20a8b6f 2019-06-04 stsp echo "alpha" > $testroot/content.expected
165 e20a8b6f 2019-06-04 stsp cat $testroot/wt/alpha > $testroot/content
167 e20a8b6f 2019-06-04 stsp cmp -s $testroot/content.expected $testroot/content
169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
170 e20a8b6f 2019-06-04 stsp diff -u $testroot/content.expected $testroot/content
171 e20a8b6f 2019-06-04 stsp test_done "$testroot" "$ret"
175 e20a8b6f 2019-06-04 stsp echo "zeta" > $testroot/content.expected
176 e20a8b6f 2019-06-04 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
178 e20a8b6f 2019-06-04 stsp cmp -s $testroot/content.expected $testroot/content
180 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
181 e20a8b6f 2019-06-04 stsp diff -u $testroot/content.expected $testroot/content
183 e20a8b6f 2019-06-04 stsp test_done "$testroot" "$ret"
186 f6cae3ed 2020-09-13 naddy test_revert_file_in_new_subdir() {
187 a9fa2909 2019-07-27 stsp local testroot=`test_init revert_file_in_new_subdir`
189 a9fa2909 2019-07-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
191 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
192 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
197 a9fa2909 2019-07-27 stsp mkdir -p $testroot/wt/newdir
198 a9fa2909 2019-07-27 stsp echo new > $testroot/wt/newdir/new
199 a9fa2909 2019-07-27 stsp (cd $testroot/wt && got add newdir/new > /dev/null)
201 a9fa2909 2019-07-27 stsp (cd $testroot/wt && got revert newdir/new > $testroot/stdout)
203 a9fa2909 2019-07-27 stsp echo "R newdir/new" > $testroot/stdout.expected
204 a9fa2909 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
206 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
207 a9fa2909 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
208 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
212 a9fa2909 2019-07-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
214 a9fa2909 2019-07-27 stsp echo "? newdir/new" > $testroot/stdout.expected
215 a9fa2909 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
217 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
218 a9fa2909 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
220 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
224 f6cae3ed 2020-09-13 naddy test_revert_no_arguments() {
225 1f1abb7e 2019-08-08 stsp local testroot=`test_init revert_no_arguments`
227 1f1abb7e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
229 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
230 1f1abb7e 2019-08-08 stsp test_done "$testroot" "$ret"
234 1f1abb7e 2019-08-08 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
236 1f1abb7e 2019-08-08 stsp (cd $testroot/wt && got revert > $testroot/stdout 2> $testroot/stderr)
238 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
239 1f1abb7e 2019-08-08 stsp echo "revert command succeeded unexpectedly" >&2
240 1f1abb7e 2019-08-08 stsp test_done "$testroot" "1"
244 1f1abb7e 2019-08-08 stsp echo -n > $testroot/stdout.expected
245 1f1abb7e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
247 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
248 1f1abb7e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
249 1f1abb7e 2019-08-08 stsp test_done "$testroot" "$ret"
253 c912cbbf 2022-08-16 stsp echo "usage: got revert [-pR] [-F response-script] path ..." \
254 33aa809d 2019-08-08 stsp > $testroot/stderr.expected
255 1f1abb7e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
257 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
258 1f1abb7e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
260 1f1abb7e 2019-08-08 stsp test_done "$testroot" "$ret"
263 f6cae3ed 2020-09-13 naddy test_revert_directory() {
264 0f6d7415 2019-08-08 stsp local testroot=`test_init revert_directory`
266 0f6d7415 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
268 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
269 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
273 0f6d7415 2019-08-08 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
275 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert . > $testroot/stdout 2> $testroot/stderr)
277 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
278 0f6d7415 2019-08-08 stsp echo "got revert command succeeded unexpectedly" >&2
279 0f6d7415 2019-08-08 stsp test_done "$testroot" "1"
282 0f6d7415 2019-08-08 stsp echo "got: reverting directories requires -R option" \
283 0f6d7415 2019-08-08 stsp > $testroot/stderr.expected
284 0f6d7415 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
286 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
287 0f6d7415 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
288 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
292 0f6d7415 2019-08-08 stsp echo -n > $testroot/stdout.expected
293 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
295 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
296 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
297 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
301 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout)
303 0f6d7415 2019-08-08 stsp echo 'R epsilon/zeta' > $testroot/stdout.expected
304 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
306 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
307 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
308 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
312 0f6d7415 2019-08-08 stsp echo "zeta" > $testroot/content.expected
313 0f6d7415 2019-08-08 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
315 0f6d7415 2019-08-08 stsp cmp -s $testroot/content.expected $testroot/content
317 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
318 0f6d7415 2019-08-08 stsp diff -u $testroot/content.expected $testroot/content
320 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
323 f6cae3ed 2020-09-13 naddy test_revert_directory_unknown() {
324 3d69ad8d 2019-08-17 semarie local testroot=`test_init revert_directory_unknown`
326 3d69ad8d 2019-08-17 semarie got checkout $testroot/repo $testroot/wt > /dev/null
328 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
329 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
330 3d69ad8d 2019-08-17 semarie return 1
333 3d69ad8d 2019-08-17 semarie echo "modified alpha" > $testroot/wt/alpha
334 3d69ad8d 2019-08-17 semarie echo "new untracked file" > $testroot/wt/epsilon/new_file
335 6a5eff7c 2019-11-23 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
337 3d69ad8d 2019-08-17 semarie (cd $testroot/wt && got revert -R . > $testroot/stdout)
339 3d69ad8d 2019-08-17 semarie echo 'R alpha' > $testroot/stdout.expected
340 3d69ad8d 2019-08-17 semarie echo 'R epsilon/zeta' >> $testroot/stdout.expected
341 3d69ad8d 2019-08-17 semarie cmp -s $testroot/stdout.expected $testroot/stdout
343 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
344 3d69ad8d 2019-08-17 semarie diff -u $testroot/stdout.expected $testroot/stdout
345 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
346 3d69ad8d 2019-08-17 semarie return 1
349 3d69ad8d 2019-08-17 semarie echo "new untracked file" > $testroot/content.expected
350 3d69ad8d 2019-08-17 semarie cat $testroot/wt/epsilon/new_file > $testroot/content
352 3d69ad8d 2019-08-17 semarie cmp -s $testroot/content.expected $testroot/content
354 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
355 3d69ad8d 2019-08-17 semarie diff -u $testroot/content.expected $testroot/content
356 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
357 3d69ad8d 2019-08-17 semarie return 1
360 3d69ad8d 2019-08-17 semarie echo "zeta" > $testroot/content.expected
361 3d69ad8d 2019-08-17 semarie cat $testroot/wt/epsilon/zeta > $testroot/content
363 3d69ad8d 2019-08-17 semarie cmp -s $testroot/content.expected $testroot/content
365 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
366 3d69ad8d 2019-08-17 semarie diff -u $testroot/content.expected $testroot/content
369 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
372 f6cae3ed 2020-09-13 naddy test_revert_patch() {
373 33aa809d 2019-08-08 stsp local testroot=`test_init revert_patch`
375 33aa809d 2019-08-08 stsp jot 16 > $testroot/repo/numbers
376 33aa809d 2019-08-08 stsp (cd $testroot/repo && git add numbers)
377 33aa809d 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
378 33aa809d 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
380 33aa809d 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
382 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
383 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
387 33aa809d 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
388 33aa809d 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
389 33aa809d 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
391 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/numbers.diff)
393 33aa809d 2019-08-08 stsp # don't revert any hunks
394 33aa809d 2019-08-08 stsp printf "n\nn\nn\n" > $testroot/patchscript
395 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
396 33aa809d 2019-08-08 stsp numbers > $testroot/stdout)
398 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
399 33aa809d 2019-08-08 stsp echo "got revert command failed unexpectedly" >&2
400 33aa809d 2019-08-08 stsp test_done "$testroot" "1"
403 33aa809d 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
404 33aa809d 2019-08-08 stsp -----------------------------------------------
405 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
412 33aa809d 2019-08-08 stsp -----------------------------------------------
413 33aa809d 2019-08-08 stsp M numbers (change 1 of 3)
414 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
415 33aa809d 2019-08-08 stsp -----------------------------------------------
416 33aa809d 2019-08-08 stsp @@ -4,7 +4,7 @@
425 33aa809d 2019-08-08 stsp -----------------------------------------------
426 33aa809d 2019-08-08 stsp M numbers (change 2 of 3)
427 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
428 33aa809d 2019-08-08 stsp -----------------------------------------------
429 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
435 33aa809d 2019-08-08 stsp -----------------------------------------------
436 33aa809d 2019-08-08 stsp M numbers (change 3 of 3)
437 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
439 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
441 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
442 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
443 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
447 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
448 33aa809d 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
449 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
451 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
452 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
453 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
457 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
458 33aa809d 2019-08-08 stsp cmp -s $testroot/numbers.diff $testroot/stdout
460 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
461 33aa809d 2019-08-08 stsp diff -u $testroot/numbers.diff $testroot/stdout
462 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
466 ce2b05c7 2019-08-10 stsp # revert first hunk
467 ce2b05c7 2019-08-10 stsp printf "y\nn\nn\n" > $testroot/patchscript
468 ce2b05c7 2019-08-10 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
469 ce2b05c7 2019-08-10 stsp numbers > $testroot/stdout)
471 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
472 ce2b05c7 2019-08-10 stsp echo "got revert command failed unexpectedly" >&2
473 ce2b05c7 2019-08-10 stsp test_done "$testroot" "1"
476 ce2b05c7 2019-08-10 stsp cat > $testroot/stdout.expected <<EOF
477 ce2b05c7 2019-08-10 stsp -----------------------------------------------
478 ce2b05c7 2019-08-10 stsp @@ -1,5 +1,5 @@
485 ce2b05c7 2019-08-10 stsp -----------------------------------------------
486 ce2b05c7 2019-08-10 stsp M numbers (change 1 of 3)
487 ce2b05c7 2019-08-10 stsp revert this change? [y/n/q] y
488 ce2b05c7 2019-08-10 stsp -----------------------------------------------
489 ce2b05c7 2019-08-10 stsp @@ -4,7 +4,7 @@
498 ce2b05c7 2019-08-10 stsp -----------------------------------------------
499 ce2b05c7 2019-08-10 stsp M numbers (change 2 of 3)
500 ce2b05c7 2019-08-10 stsp revert this change? [y/n/q] n
501 ce2b05c7 2019-08-10 stsp -----------------------------------------------
502 ce2b05c7 2019-08-10 stsp @@ -13,4 +13,4 @@
508 ce2b05c7 2019-08-10 stsp -----------------------------------------------
509 ce2b05c7 2019-08-10 stsp M numbers (change 3 of 3)
510 ce2b05c7 2019-08-10 stsp revert this change? [y/n/q] n
512 ce2b05c7 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
514 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
515 ce2b05c7 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
516 ce2b05c7 2019-08-10 stsp test_done "$testroot" "$ret"
520 ce2b05c7 2019-08-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
521 ce2b05c7 2019-08-10 stsp echo "M numbers" > $testroot/stdout.expected
522 ce2b05c7 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
524 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
525 ce2b05c7 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
526 ce2b05c7 2019-08-10 stsp test_done "$testroot" "$ret"
530 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
531 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
532 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
533 ce2b05c7 2019-08-10 stsp echo -n 'blob - ' >> $testroot/stdout.expected
534 ce2b05c7 2019-08-10 stsp got tree -r $testroot/repo -i -c $commit_id \
535 ce2b05c7 2019-08-10 stsp | grep 'numbers$' | cut -d' ' -f 1 \
536 ce2b05c7 2019-08-10 stsp >> $testroot/stdout.expected
537 ce2b05c7 2019-08-10 stsp echo 'file + numbers' >> $testroot/stdout.expected
538 ce2b05c7 2019-08-10 stsp cat >> $testroot/stdout.expected <<EOF
539 ce2b05c7 2019-08-10 stsp --- numbers
540 ce2b05c7 2019-08-10 stsp +++ numbers
541 ce2b05c7 2019-08-10 stsp @@ -4,7 +4,7 @@
550 ce2b05c7 2019-08-10 stsp @@ -13,4 +13,4 @@
557 ce2b05c7 2019-08-10 stsp (cd $testroot/wt && got diff > $testroot/stdout)
558 ce2b05c7 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
560 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
561 ce2b05c7 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
562 ce2b05c7 2019-08-10 stsp test_done "$testroot" "$ret"
566 ce2b05c7 2019-08-10 stsp # put first hunk back
567 ce2b05c7 2019-08-10 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
569 33aa809d 2019-08-08 stsp # revert middle hunk
570 33aa809d 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
571 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
572 33aa809d 2019-08-08 stsp numbers > $testroot/stdout)
574 33aa809d 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
575 33aa809d 2019-08-08 stsp -----------------------------------------------
576 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
583 33aa809d 2019-08-08 stsp -----------------------------------------------
584 33aa809d 2019-08-08 stsp M numbers (change 1 of 3)
585 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
586 33aa809d 2019-08-08 stsp -----------------------------------------------
587 33aa809d 2019-08-08 stsp @@ -4,7 +4,7 @@
596 33aa809d 2019-08-08 stsp -----------------------------------------------
597 33aa809d 2019-08-08 stsp M numbers (change 2 of 3)
598 33aa809d 2019-08-08 stsp revert this change? [y/n/q] y
599 33aa809d 2019-08-08 stsp -----------------------------------------------
600 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
606 33aa809d 2019-08-08 stsp -----------------------------------------------
607 33aa809d 2019-08-08 stsp M numbers (change 3 of 3)
608 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
610 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
612 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
613 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
614 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
618 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
619 33aa809d 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
620 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
622 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
623 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
624 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
628 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
630 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
631 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
632 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
633 33aa809d 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
634 33aa809d 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
635 33aa809d 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
636 33aa809d 2019-08-08 stsp >> $testroot/stdout.expected
637 33aa809d 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
638 33aa809d 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
639 33aa809d 2019-08-08 stsp --- numbers
640 33aa809d 2019-08-08 stsp +++ numbers
641 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
648 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
655 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
657 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
658 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
659 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
663 33aa809d 2019-08-08 stsp # revert last hunk
664 33aa809d 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
665 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
666 33aa809d 2019-08-08 stsp numbers > $testroot/stdout)
667 33aa809d 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
668 33aa809d 2019-08-08 stsp -----------------------------------------------
669 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
676 33aa809d 2019-08-08 stsp -----------------------------------------------
677 33aa809d 2019-08-08 stsp M numbers (change 1 of 2)
678 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
679 33aa809d 2019-08-08 stsp -----------------------------------------------
680 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
686 33aa809d 2019-08-08 stsp -----------------------------------------------
687 33aa809d 2019-08-08 stsp M numbers (change 2 of 2)
688 33aa809d 2019-08-08 stsp revert this change? [y/n/q] y
690 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
692 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
693 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
694 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
698 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
700 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
701 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
702 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
703 33aa809d 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
704 33aa809d 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
705 33aa809d 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
706 33aa809d 2019-08-08 stsp >> $testroot/stdout.expected
707 33aa809d 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
708 33aa809d 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
709 33aa809d 2019-08-08 stsp --- numbers
710 33aa809d 2019-08-08 stsp +++ numbers
711 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
719 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
721 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
722 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
724 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
727 f6cae3ed 2020-09-13 naddy test_revert_patch_added() {
728 33aa809d 2019-08-08 stsp local testroot=`test_init revert_patch_added`
729 33aa809d 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
731 33aa809d 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
733 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
734 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
738 33aa809d 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
739 33aa809d 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
741 33aa809d 2019-08-08 stsp printf "n\n" > $testroot/patchscript
742 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
743 33aa809d 2019-08-08 stsp epsilon/new > $testroot/stdout)
745 33aa809d 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
746 33aa809d 2019-08-08 stsp echo "revert this addition? [y/n] n" >> $testroot/stdout.expected
747 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
749 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
750 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
751 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
755 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
756 33aa809d 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
757 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
759 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
760 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
761 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
765 33aa809d 2019-08-08 stsp printf "y\n" > $testroot/patchscript
766 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
767 33aa809d 2019-08-08 stsp epsilon/new > $testroot/stdout)
769 33aa809d 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
770 33aa809d 2019-08-08 stsp echo "revert this addition? [y/n] y" >> $testroot/stdout.expected
771 33aa809d 2019-08-08 stsp echo "R epsilon/new" >> $testroot/stdout.expected
772 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
774 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
775 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
776 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
780 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
781 33aa809d 2019-08-08 stsp echo "? epsilon/new" > $testroot/stdout.expected
782 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
784 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
785 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
787 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
790 f6cae3ed 2020-09-13 naddy test_revert_patch_removed() {
791 33aa809d 2019-08-08 stsp local testroot=`test_init revert_patch_removed`
792 33aa809d 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
794 33aa809d 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
796 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
797 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
801 33aa809d 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
803 33aa809d 2019-08-08 stsp printf "n\n" > $testroot/patchscript
804 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
805 33aa809d 2019-08-08 stsp beta > $testroot/stdout)
806 33aa809d 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
807 33aa809d 2019-08-08 stsp echo "revert this deletion? [y/n] n" >> $testroot/stdout.expected
808 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
810 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
811 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
812 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
816 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
817 33aa809d 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
818 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
820 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
821 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
822 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
826 33aa809d 2019-08-08 stsp printf "y\n" > $testroot/patchscript
827 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
828 33aa809d 2019-08-08 stsp beta > $testroot/stdout)
830 33aa809d 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
831 33aa809d 2019-08-08 stsp echo "revert this deletion? [y/n] y" >> $testroot/stdout.expected
832 33aa809d 2019-08-08 stsp echo "R beta" >> $testroot/stdout.expected
833 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
835 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
836 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
837 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
841 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
842 33aa809d 2019-08-08 stsp echo -n > $testroot/stdout.expected
843 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
845 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
846 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
848 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
851 f6cae3ed 2020-09-13 naddy test_revert_patch_one_change() {
852 f1e81a05 2019-08-10 stsp local testroot=`test_init revert_patch_one_change`
854 f1e81a05 2019-08-10 stsp jot 16 > $testroot/repo/numbers
855 f1e81a05 2019-08-10 stsp (cd $testroot/repo && git add numbers)
856 f1e81a05 2019-08-10 stsp git_commit $testroot/repo -m "added numbers file"
857 f1e81a05 2019-08-10 stsp local commit_id=`git_show_head $testroot/repo`
859 f1e81a05 2019-08-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
861 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
862 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
866 6c6b73bb 2019-08-10 stsp # Ensure file size is changed. Avoids race condition causing test
867 6c6b73bb 2019-08-10 stsp # failures where 'got revert' does not see changes to revert if
868 6c6b73bb 2019-08-10 stsp # timestamps and size in stat info remain unchanged.
869 6c6b73bb 2019-08-10 stsp sed -i -e 's/^2$/aa/' $testroot/wt/numbers
871 f1e81a05 2019-08-10 stsp # revert change with -p
872 f1e81a05 2019-08-10 stsp printf "y\n" > $testroot/patchscript
873 f1e81a05 2019-08-10 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
874 f1e81a05 2019-08-10 stsp numbers > $testroot/stdout)
876 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
877 f1e81a05 2019-08-10 stsp echo "got revert command failed unexpectedly" >&2
878 f1e81a05 2019-08-10 stsp test_done "$testroot" "1"
881 f1e81a05 2019-08-10 stsp cat > $testroot/stdout.expected <<EOF
882 f1e81a05 2019-08-10 stsp -----------------------------------------------
883 f1e81a05 2019-08-10 stsp @@ -1,5 +1,5 @@
890 f1e81a05 2019-08-10 stsp -----------------------------------------------
891 f1e81a05 2019-08-10 stsp M numbers (change 1 of 1)
892 f1e81a05 2019-08-10 stsp revert this change? [y/n/q] y
895 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
896 6c6b73bb 2019-08-10 stsp echo "got revert command failed unexpectedly" >&2
897 6c6b73bb 2019-08-10 stsp test_done "$testroot" "1"
901 f1e81a05 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
903 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
904 f1e81a05 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
905 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
909 f1e81a05 2019-08-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
910 f1e81a05 2019-08-10 stsp echo -n > $testroot/stdout.expected
911 f1e81a05 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
913 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
914 f1e81a05 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
915 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
919 f1e81a05 2019-08-10 stsp (cd $testroot/wt && got diff > $testroot/stdout)
920 f1e81a05 2019-08-10 stsp echo -n > $testroot/stdout.expected
921 f1e81a05 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
923 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
924 f1e81a05 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
926 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
929 f6cae3ed 2020-09-13 naddy test_revert_added_subtree() {
930 a46b9f33 2020-01-28 stsp local testroot=`test_init revert_added_subtree`
932 a46b9f33 2020-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
934 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
935 a46b9f33 2020-01-28 stsp test_done "$testroot" "$ret"
939 a46b9f33 2020-01-28 stsp mkdir -p $testroot/wt/epsilon/foo/bar/baz
940 a46b9f33 2020-01-28 stsp mkdir -p $testroot/wt/epsilon/foo/bar/bax
941 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/a.o
942 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/a.o
943 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
944 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
945 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
946 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
947 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
948 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
949 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
950 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
951 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
952 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
953 a46b9f33 2020-01-28 stsp (cd $testroot/wt && got add -R epsilon >/dev/null)
955 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/a.o" > $testroot/stdout.expected
956 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/b.d" >> $testroot/stdout.expected
957 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/b.o" >> $testroot/stdout.expected
958 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
959 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
960 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
961 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
962 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
963 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
964 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
965 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
967 a46b9f33 2020-01-28 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout)
969 a46b9f33 2020-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
971 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
972 a46b9f33 2020-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
973 a46b9f33 2020-01-28 stsp test_done "$testroot" "$ret"
977 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/a.o" > $testroot/stdout.expected
978 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/b.d" >> $testroot/stdout.expected
979 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/b.o" >> $testroot/stdout.expected
980 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
981 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
982 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
983 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
984 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
985 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
986 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
987 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
989 a46b9f33 2020-01-28 stsp (cd $testroot/wt && got status > $testroot/stdout)
991 a46b9f33 2020-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
993 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
994 a46b9f33 2020-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
996 a46b9f33 2020-01-28 stsp test_done "$testroot" "$ret"
999 f6cae3ed 2020-09-13 naddy test_revert_deleted_subtree() {
1000 15341bfd 2020-03-05 tracey local testroot=`test_init revert_deleted_subtree`
1002 15341bfd 2020-03-05 tracey got checkout $testroot/repo $testroot/wt > /dev/null
1004 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1005 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
1006 15341bfd 2020-03-05 tracey return 1
1009 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/baz
1010 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/bax
1011 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
1012 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
1013 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
1014 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
1015 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
1016 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
1017 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
1018 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
1019 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
1020 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
1021 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
1022 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
1023 15341bfd 2020-03-05 tracey (cd $testroot/wt && got add -R epsilon >/dev/null)
1024 15341bfd 2020-03-05 tracey (cd $testroot/wt && got commit -m "add subtree" >/dev/null)
1026 15341bfd 2020-03-05 tracey # now delete and revert the entire subtree
1027 15341bfd 2020-03-05 tracey (cd $testroot/wt && got rm -R epsilon/foo >/dev/null)
1029 15341bfd 2020-03-05 tracey echo "R epsilon/foo/a.o" > $testroot/stdout.expected
1030 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/b.d" >> $testroot/stdout.expected
1031 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/b.o" >> $testroot/stdout.expected
1032 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
1033 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
1034 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
1035 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
1036 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
1037 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
1038 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
1039 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
1041 15341bfd 2020-03-05 tracey (cd $testroot/wt && got revert -R . > $testroot/stdout)
1043 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
1045 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1046 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
1047 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
1048 15341bfd 2020-03-05 tracey return 1
1051 15341bfd 2020-03-05 tracey echo -n > $testroot/stdout.expected
1052 15341bfd 2020-03-05 tracey (cd $testroot/wt && got status > $testroot/stdout)
1054 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
1056 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1057 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
1059 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
1062 f6cae3ed 2020-09-13 naddy test_revert_symlink() {
1063 4901ccfc 2020-07-23 stsp local testroot=`test_init revert_symlink`
1065 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1066 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1067 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1068 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1069 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1070 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1071 4901ccfc 2020-07-23 stsp (cd $testroot/repo && git add .)
1072 4901ccfc 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1073 4901ccfc 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
1075 4901ccfc 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1077 4901ccfc 2020-07-23 stsp # symlink to file A now points to file B
1078 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1079 4901ccfc 2020-07-23 stsp # symlink to a directory A now points to file B
1080 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sfh beta epsilon.link)
1081 4901ccfc 2020-07-23 stsp # "bad" symlink now contains a different target path
1082 4901ccfc 2020-07-23 stsp echo "foo" > $testroot/wt/passwd.link
1083 4901ccfc 2020-07-23 stsp # relative symlink to directory A now points to relative directory B
1084 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
1085 4901ccfc 2020-07-23 stsp # an unversioned symlink
1086 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1087 4901ccfc 2020-07-23 stsp # symlink to file A now points to non-existent file B
1088 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1089 4901ccfc 2020-07-23 stsp # removed symlink
1090 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
1091 4901ccfc 2020-07-23 stsp # added symlink
1092 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
1093 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1095 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got revert alpha.link epsilon.link \
1096 4901ccfc 2020-07-23 stsp passwd.link epsilon/beta.link dotgotfoo.link \
1097 4901ccfc 2020-07-23 stsp nonexistent.link zeta.link new.link > $testroot/stdout)
1099 4901ccfc 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1100 4901ccfc 2020-07-23 stsp R alpha.link
1101 4901ccfc 2020-07-23 stsp R epsilon/beta.link
1102 10a623df 2021-10-11 stsp R epsilon.link
1103 4901ccfc 2020-07-23 stsp R new.link
1104 10a623df 2021-10-11 stsp R nonexistent.link
1105 10a623df 2021-10-11 stsp R passwd.link
1106 10a623df 2021-10-11 stsp R zeta.link
1108 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1110 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1111 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1112 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1116 4901ccfc 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1117 4901ccfc 2020-07-23 stsp echo "alpha.link is not a symlink"
1118 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1122 4901ccfc 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1123 4901ccfc 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1124 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1126 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1127 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1128 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1132 4901ccfc 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1133 4901ccfc 2020-07-23 stsp echo "epsilon.link is not a symlink"
1134 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1138 4901ccfc 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1139 4901ccfc 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1140 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1142 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1143 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1144 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1148 4901ccfc 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1149 4901ccfc 2020-07-23 stsp echo "passwd.link should not be a symlink" >&2
1150 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1154 4901ccfc 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1155 4901ccfc 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1157 4901ccfc 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1159 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1160 4901ccfc 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1161 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1165 4901ccfc 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1166 4901ccfc 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1167 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1170 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1171 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1175 4901ccfc 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1176 4901ccfc 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1177 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1179 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1180 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1181 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1185 4901ccfc 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1186 4901ccfc 2020-07-23 stsp echo "dotgotfoo.link is not a symlink " >&2
1187 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1190 4901ccfc 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1191 4901ccfc 2020-07-23 stsp echo ".got/foo" > $testroot/stdout.expected
1192 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1194 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1195 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1196 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1200 4901ccfc 2020-07-23 stsp if [ ! -h $testroot/wt/zeta.link ]; then
1201 4901ccfc 2020-07-23 stsp echo -n "zeta.link is not a symlink" >&2
1202 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1206 4901ccfc 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
1207 4901ccfc 2020-07-23 stsp echo "epsilon/zeta" > $testroot/stdout.expected
1208 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1210 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1211 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1212 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1216 4901ccfc 2020-07-23 stsp if [ ! -h $testroot/wt/new.link ]; then
1217 4901ccfc 2020-07-23 stsp echo -n "new.link is not a symlink" >&2
1218 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1222 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1223 4901ccfc 2020-07-23 stsp echo "? dotgotfoo.link" > $testroot/stdout.expected
1224 4901ccfc 2020-07-23 stsp echo "? new.link" >> $testroot/stdout.expected
1225 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1227 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1228 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1231 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1234 f6cae3ed 2020-09-13 naddy test_revert_patch_symlink() {
1235 369fd7e5 2020-07-23 stsp local testroot=`test_init revert_patch_symlink`
1237 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1238 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1239 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1240 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1241 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1242 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1243 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta2.link)
1244 369fd7e5 2020-07-23 stsp (cd $testroot/repo && git add .)
1245 369fd7e5 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1246 369fd7e5 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
1248 369fd7e5 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1250 369fd7e5 2020-07-23 stsp # symlink to file A now points to file B
1251 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1252 369fd7e5 2020-07-23 stsp # symlink to a directory A now points to file B
1253 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sfh beta epsilon.link)
1254 369fd7e5 2020-07-23 stsp # "bad" symlink now contains a different target path
1255 369fd7e5 2020-07-23 stsp echo "foo" > $testroot/wt/passwd.link
1256 369fd7e5 2020-07-23 stsp # relative symlink to directory A now points to relative directory B
1257 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
1258 369fd7e5 2020-07-23 stsp # an unversioned symlink
1259 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1260 369fd7e5 2020-07-23 stsp # symlink to file A now points to non-existent file B
1261 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1262 369fd7e5 2020-07-23 stsp # removed symlink
1263 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
1264 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got rm zeta2.link > /dev/null)
1265 369fd7e5 2020-07-23 stsp # added symlink
1266 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
1267 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1268 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf beta zeta3.link)
1269 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got add zeta3.link > /dev/null)
1271 369fd7e5 2020-07-23 stsp printf "y\nn\ny\nn\ny\ny\nn\ny\ny\n" > $testroot/patchscript
1272 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p -R . \
1273 369fd7e5 2020-07-23 stsp > $testroot/stdout)
1275 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1276 369fd7e5 2020-07-23 stsp echo "got revert command failed unexpectedly" >&2
1277 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1280 369fd7e5 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1281 369fd7e5 2020-07-23 stsp -----------------------------------------------
1282 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1284 369fd7e5 2020-07-23 stsp \ No newline at end of file
1285 369fd7e5 2020-07-23 stsp +gamma/delta
1286 369fd7e5 2020-07-23 stsp \ No newline at end of file
1287 369fd7e5 2020-07-23 stsp -----------------------------------------------
1288 369fd7e5 2020-07-23 stsp M alpha.link (change 1 of 1)
1289 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1290 369fd7e5 2020-07-23 stsp R alpha.link
1291 369fd7e5 2020-07-23 stsp -----------------------------------------------
1292 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1294 369fd7e5 2020-07-23 stsp \ No newline at end of file
1296 369fd7e5 2020-07-23 stsp \ No newline at end of file
1297 369fd7e5 2020-07-23 stsp -----------------------------------------------
1298 369fd7e5 2020-07-23 stsp M epsilon/beta.link (change 1 of 1)
1299 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] n
1300 369fd7e5 2020-07-23 stsp -----------------------------------------------
1301 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1303 369fd7e5 2020-07-23 stsp \ No newline at end of file
1305 369fd7e5 2020-07-23 stsp \ No newline at end of file
1306 369fd7e5 2020-07-23 stsp -----------------------------------------------
1307 369fd7e5 2020-07-23 stsp M epsilon.link (change 1 of 1)
1308 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1309 369fd7e5 2020-07-23 stsp R epsilon.link
1310 369fd7e5 2020-07-23 stsp A new.link
1311 369fd7e5 2020-07-23 stsp revert this addition? [y/n] n
1312 369fd7e5 2020-07-23 stsp -----------------------------------------------
1313 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1314 369fd7e5 2020-07-23 stsp -nonexistent
1315 369fd7e5 2020-07-23 stsp \ No newline at end of file
1316 369fd7e5 2020-07-23 stsp +nonexistent2
1317 369fd7e5 2020-07-23 stsp \ No newline at end of file
1318 369fd7e5 2020-07-23 stsp -----------------------------------------------
1319 369fd7e5 2020-07-23 stsp M nonexistent.link (change 1 of 1)
1320 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1321 369fd7e5 2020-07-23 stsp R nonexistent.link
1322 369fd7e5 2020-07-23 stsp -----------------------------------------------
1323 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1324 369fd7e5 2020-07-23 stsp -/etc/passwd
1325 369fd7e5 2020-07-23 stsp \ No newline at end of file
1327 369fd7e5 2020-07-23 stsp -----------------------------------------------
1328 369fd7e5 2020-07-23 stsp M passwd.link (change 1 of 1)
1329 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1330 369fd7e5 2020-07-23 stsp R passwd.link
1331 369fd7e5 2020-07-23 stsp D zeta.link
1332 369fd7e5 2020-07-23 stsp revert this deletion? [y/n] n
1333 369fd7e5 2020-07-23 stsp D zeta2.link
1334 369fd7e5 2020-07-23 stsp revert this deletion? [y/n] y
1335 369fd7e5 2020-07-23 stsp R zeta2.link
1336 369fd7e5 2020-07-23 stsp A zeta3.link
1337 369fd7e5 2020-07-23 stsp revert this addition? [y/n] y
1338 369fd7e5 2020-07-23 stsp R zeta3.link
1340 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1342 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1343 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1344 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1348 369fd7e5 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1349 369fd7e5 2020-07-23 stsp echo "alpha.link is not a symlink"
1350 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1354 369fd7e5 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1355 369fd7e5 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1356 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1358 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1359 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1360 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1364 369fd7e5 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1365 369fd7e5 2020-07-23 stsp echo "epsilon.link is not a symlink"
1366 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1370 369fd7e5 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1371 369fd7e5 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1372 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1374 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1375 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1376 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1380 369fd7e5 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1381 369fd7e5 2020-07-23 stsp echo "passwd.link should not be a symlink" >&2
1382 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1386 369fd7e5 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1387 369fd7e5 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1389 369fd7e5 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1391 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1392 369fd7e5 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1393 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1397 369fd7e5 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1398 369fd7e5 2020-07-23 stsp echo "../gamma" > $testroot/stdout.expected
1399 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1401 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1402 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1403 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1407 369fd7e5 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1408 369fd7e5 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1409 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1411 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1412 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1413 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1417 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1418 369fd7e5 2020-07-23 stsp echo "dotgotfoo.link is not a symlink " >&2
1419 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1422 369fd7e5 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1423 369fd7e5 2020-07-23 stsp echo ".got/foo" > $testroot/stdout.expected
1424 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1426 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1427 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1428 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1433 369fd7e5 2020-07-23 stsp if [ -e $testroot/wt/zeta.link ]; then
1434 369fd7e5 2020-07-23 stsp echo -n "zeta.link should not exist on disk" >&2
1435 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1439 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/zeta2.link ]; then
1440 369fd7e5 2020-07-23 stsp echo -n "zeta2.link is not a symlink" >&2
1441 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1445 369fd7e5 2020-07-23 stsp readlink $testroot/wt/zeta2.link > $testroot/stdout
1446 369fd7e5 2020-07-23 stsp echo "epsilon/zeta" > $testroot/stdout.expected
1447 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1449 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1450 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1451 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1455 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/zeta3.link ]; then
1456 369fd7e5 2020-07-23 stsp echo -n "zeta3.link is not a symlink" >&2
1457 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1461 cf0e59fe 2020-07-23 stsp readlink $testroot/wt/zeta3.link > $testroot/stdout
1462 cf0e59fe 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
1463 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1465 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1466 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1467 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1471 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/new.link ]; then
1472 369fd7e5 2020-07-23 stsp echo -n "new.link is not a symlink" >&2
1473 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1477 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1478 369fd7e5 2020-07-23 stsp echo "? dotgotfoo.link" > $testroot/stdout.expected
1479 369fd7e5 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1480 369fd7e5 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1481 369fd7e5 2020-07-23 stsp echo "D zeta.link" >> $testroot/stdout.expected
1482 369fd7e5 2020-07-23 stsp echo "? zeta3.link" >> $testroot/stdout.expected
1483 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1485 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1486 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1489 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1492 b2b3fce1 2022-10-29 op test_revert_umask() {
1493 b2b3fce1 2022-10-29 op local testroot=`test_init revert_umask`
1495 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1496 b2b3fce1 2022-10-29 op echo "edit alpha" > $testroot/wt/alpha
1498 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1499 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got revert alpha) \
1502 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1503 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1507 b2b3fce1 2022-10-29 op if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
1508 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after revert" >&2
1509 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1510 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1513 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1516 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1517 a129376b 2019-03-28 stsp run_test test_revert_basic
1518 a129376b 2019-03-28 stsp run_test test_revert_rm
1519 a129376b 2019-03-28 stsp run_test test_revert_add
1520 e20a8b6f 2019-06-04 stsp run_test test_revert_multiple
1521 a9fa2909 2019-07-27 stsp run_test test_revert_file_in_new_subdir
1522 1f1abb7e 2019-08-08 stsp run_test test_revert_no_arguments
1523 0f6d7415 2019-08-08 stsp run_test test_revert_directory
1524 3d69ad8d 2019-08-17 semarie run_test test_revert_directory_unknown
1525 33aa809d 2019-08-08 stsp run_test test_revert_patch
1526 33aa809d 2019-08-08 stsp run_test test_revert_patch_added
1527 33aa809d 2019-08-08 stsp run_test test_revert_patch_removed
1528 f1e81a05 2019-08-10 stsp run_test test_revert_patch_one_change
1529 a46b9f33 2020-01-28 stsp run_test test_revert_added_subtree
1530 15341bfd 2020-03-05 tracey run_test test_revert_deleted_subtree
1531 4901ccfc 2020-07-23 stsp run_test test_revert_symlink
1532 369fd7e5 2020-07-23 stsp run_test test_revert_patch_symlink
1533 b2b3fce1 2022-10-29 op run_test test_revert_umask