3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 function test_histedit_no_op {
20 local testroot=`test_init histedit_no_op`
22 local orig_commit=`git_show_head $testroot/repo`
24 echo "modified alpha on master" > $testroot/repo/alpha
25 (cd $testroot/repo && git rm -q beta)
26 echo "new file on master" > $testroot/repo/epsilon/new
27 (cd $testroot/repo && git add epsilon/new)
28 git_commit $testroot/repo -m "committing changes"
29 local old_commit1=`git_show_head $testroot/repo`
31 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
32 git_commit $testroot/repo -m "committing to zeta on master"
33 local old_commit2=`git_show_head $testroot/repo`
35 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
37 if [ "$ret" != "0" ]; then
38 test_done "$testroot" "$ret"
42 echo "pick $old_commit1" > $testroot/histedit-script
43 echo "pick $old_commit2" >> $testroot/histedit-script
45 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
48 local new_commit1=`git_show_parent_commit $testroot/repo`
49 local new_commit2=`git_show_head $testroot/repo`
51 local short_old_commit1=`trim_obj_id 28 $old_commit1`
52 local short_old_commit2=`trim_obj_id 28 $old_commit2`
53 local short_new_commit1=`trim_obj_id 28 $new_commit1`
54 local short_new_commit2=`trim_obj_id 28 $new_commit2`
56 echo "G alpha" > $testroot/stdout.expected
57 echo "D beta" >> $testroot/stdout.expected
58 echo "A epsilon/new" >> $testroot/stdout.expected
59 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
60 >> $testroot/stdout.expected
61 echo "G epsilon/zeta" >> $testroot/stdout.expected
62 echo -n "$short_old_commit2 -> $short_new_commit2: " \
63 >> $testroot/stdout.expected
64 echo "committing to zeta on master" >> $testroot/stdout.expected
65 echo "Switching work tree to refs/heads/master" \
66 >> $testroot/stdout.expected
68 cmp -s $testroot/stdout.expected $testroot/stdout
70 if [ "$ret" != "0" ]; then
71 diff -u $testroot/stdout.expected $testroot/stdout
72 test_done "$testroot" "$ret"
76 echo "modified alpha on master" > $testroot/content.expected
77 cat $testroot/wt/alpha > $testroot/content
78 cmp -s $testroot/content.expected $testroot/content
80 if [ "$ret" != "0" ]; then
81 diff -u $testroot/content.expected $testroot/content
82 test_done "$testroot" "$ret"
86 if [ -e $testroot/wt/beta ]; then
87 echo "removed file beta still exists on disk" >&2
88 test_done "$testroot" "1"
92 echo "new file on master" > $testroot/content.expected
93 cat $testroot/wt/epsilon/new > $testroot/content
94 cmp -s $testroot/content.expected $testroot/content
96 if [ "$ret" != "0" ]; then
97 diff -u $testroot/content.expected $testroot/content
98 test_done "$testroot" "$ret"
102 (cd $testroot/wt && got status > $testroot/stdout)
104 echo -n > $testroot/stdout.expected
105 cmp -s $testroot/stdout.expected $testroot/stdout
107 if [ "$ret" != "0" ]; then
108 diff -u $testroot/stdout.expected $testroot/stdout
109 test_done "$testroot" "$ret"
113 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
114 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
115 echo "commit $new_commit1" >> $testroot/stdout.expected
116 echo "commit $orig_commit" >> $testroot/stdout.expected
117 cmp -s $testroot/stdout.expected $testroot/stdout
119 if [ "$ret" != "0" ]; then
120 diff -u $testroot/stdout.expected $testroot/stdout
122 test_done "$testroot" "$ret"
125 function test_histedit_swap {
126 local testroot=`test_init histedit_swap`
128 local orig_commit=`git_show_head $testroot/repo`
130 echo "modified alpha on master" > $testroot/repo/alpha
131 (cd $testroot/repo && git rm -q beta)
132 echo "new file on master" > $testroot/repo/epsilon/new
133 (cd $testroot/repo && git add epsilon/new)
134 git_commit $testroot/repo -m "committing changes"
135 local old_commit1=`git_show_head $testroot/repo`
137 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
138 git_commit $testroot/repo -m "committing to zeta on master"
139 local old_commit2=`git_show_head $testroot/repo`
141 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
143 if [ "$ret" != "0" ]; then
144 test_done "$testroot" "$ret"
148 echo "pick $old_commit2" > $testroot/histedit-script
149 echo "pick $old_commit1" >> $testroot/histedit-script
151 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
154 local new_commit2=`git_show_parent_commit $testroot/repo`
155 local new_commit1=`git_show_head $testroot/repo`
157 local short_old_commit1=`trim_obj_id 28 $old_commit1`
158 local short_old_commit2=`trim_obj_id 28 $old_commit2`
159 local short_new_commit1=`trim_obj_id 28 $new_commit1`
160 local short_new_commit2=`trim_obj_id 28 $new_commit2`
162 echo "G epsilon/zeta" > $testroot/stdout.expected
163 echo -n "$short_old_commit2 -> $short_new_commit2: " \
164 >> $testroot/stdout.expected
165 echo "committing to zeta on master" >> $testroot/stdout.expected
166 echo "G alpha" >> $testroot/stdout.expected
167 echo "D beta" >> $testroot/stdout.expected
168 echo "A epsilon/new" >> $testroot/stdout.expected
169 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
170 >> $testroot/stdout.expected
171 echo "Switching work tree to refs/heads/master" \
172 >> $testroot/stdout.expected
174 cmp -s $testroot/stdout.expected $testroot/stdout
176 if [ "$ret" != "0" ]; then
177 diff -u $testroot/stdout.expected $testroot/stdout
178 test_done "$testroot" "$ret"
182 echo "modified alpha on master" > $testroot/content.expected
183 cat $testroot/wt/alpha > $testroot/content
184 cmp -s $testroot/content.expected $testroot/content
186 if [ "$ret" != "0" ]; then
187 diff -u $testroot/content.expected $testroot/content
188 test_done "$testroot" "$ret"
192 if [ -e $testroot/wt/beta ]; then
193 echo "removed file beta still exists on disk" >&2
194 test_done "$testroot" "1"
198 echo "new file on master" > $testroot/content.expected
199 cat $testroot/wt/epsilon/new > $testroot/content
200 cmp -s $testroot/content.expected $testroot/content
202 if [ "$ret" != "0" ]; then
203 diff -u $testroot/content.expected $testroot/content
204 test_done "$testroot" "$ret"
208 (cd $testroot/wt && got status > $testroot/stdout)
210 echo -n > $testroot/stdout.expected
211 cmp -s $testroot/stdout.expected $testroot/stdout
213 if [ "$ret" != "0" ]; then
214 diff -u $testroot/stdout.expected $testroot/stdout
215 test_done "$testroot" "$ret"
219 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
220 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
221 echo "commit $new_commit2" >> $testroot/stdout.expected
222 echo "commit $orig_commit" >> $testroot/stdout.expected
223 cmp -s $testroot/stdout.expected $testroot/stdout
225 if [ "$ret" != "0" ]; then
226 diff -u $testroot/stdout.expected $testroot/stdout
228 test_done "$testroot" "$ret"
231 function test_histedit_drop {
232 local testroot=`test_init histedit_drop`
234 local orig_commit=`git_show_head $testroot/repo`
236 echo "modified alpha on master" > $testroot/repo/alpha
237 (cd $testroot/repo && git rm -q beta)
238 echo "new file on master" > $testroot/repo/epsilon/new
239 (cd $testroot/repo && git add epsilon/new)
240 git_commit $testroot/repo -m "committing changes"
241 local old_commit1=`git_show_head $testroot/repo`
243 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
244 git_commit $testroot/repo -m "committing to zeta on master"
245 local old_commit2=`git_show_head $testroot/repo`
247 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
249 if [ "$ret" != "0" ]; then
250 test_done "$testroot" "$ret"
254 echo "drop $old_commit1" > $testroot/histedit-script
255 echo "pick $old_commit2" >> $testroot/histedit-script
257 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
260 local new_commit1=`git_show_parent_commit $testroot/repo`
261 local new_commit2=`git_show_head $testroot/repo`
263 local short_old_commit1=`trim_obj_id 28 $old_commit1`
264 local short_old_commit2=`trim_obj_id 28 $old_commit2`
265 local short_new_commit1=`trim_obj_id 28 $new_commit1`
266 local short_new_commit2=`trim_obj_id 28 $new_commit2`
268 echo "$short_old_commit1 -> drop commit: committing changes" \
269 > $testroot/stdout.expected
270 echo "G epsilon/zeta" >> $testroot/stdout.expected
271 echo -n "$short_old_commit2 -> $short_new_commit2: " \
272 >> $testroot/stdout.expected
273 echo "committing to zeta on master" >> $testroot/stdout.expected
274 echo "Switching work tree to refs/heads/master" \
275 >> $testroot/stdout.expected
277 cmp -s $testroot/stdout.expected $testroot/stdout
279 if [ "$ret" != "0" ]; then
280 diff -u $testroot/stdout.expected $testroot/stdout
281 test_done "$testroot" "$ret"
285 for f in alpha beta; do
286 echo "$f" > $testroot/content.expected
287 cat $testroot/wt/$f > $testroot/content
288 cmp -s $testroot/content.expected $testroot/content
290 if [ "$ret" != "0" ]; then
291 diff -u $testroot/content.expected $testroot/content
292 test_done "$testroot" "$ret"
297 if [ -e $testroot/wt/new ]; then
298 echo "file new exists on disk but should not" >&2
299 test_done "$testroot" "1"
303 (cd $testroot/wt && got status > $testroot/stdout)
305 echo -n > $testroot/stdout.expected
306 cmp -s $testroot/stdout.expected $testroot/stdout
308 if [ "$ret" != "0" ]; then
309 diff -u $testroot/stdout.expected $testroot/stdout
310 test_done "$testroot" "$ret"
314 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
315 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
316 echo "commit $orig_commit" >> $testroot/stdout.expected
317 cmp -s $testroot/stdout.expected $testroot/stdout
319 if [ "$ret" != "0" ]; then
320 diff -u $testroot/stdout.expected $testroot/stdout
322 test_done "$testroot" "$ret"
325 function test_histedit_fold {
326 local testroot=`test_init histedit_fold`
328 local orig_commit=`git_show_head $testroot/repo`
330 echo "modified alpha on master" > $testroot/repo/alpha
331 (cd $testroot/repo && git rm -q beta)
332 echo "new file on master" > $testroot/repo/epsilon/new
333 (cd $testroot/repo && git add epsilon/new)
334 git_commit $testroot/repo -m "committing changes"
335 local old_commit1=`git_show_head $testroot/repo`
337 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
338 git_commit $testroot/repo -m "committing to zeta on master"
339 local old_commit2=`git_show_head $testroot/repo`
341 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
343 if [ "$ret" != "0" ]; then
344 test_done "$testroot" "$ret"
348 echo "fold $old_commit1" > $testroot/histedit-script
349 echo "pick $old_commit2" >> $testroot/histedit-script
350 echo "mesg committing folded changes" >> $testroot/histedit-script
352 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
355 local new_commit1=`git_show_parent_commit $testroot/repo`
356 local new_commit2=`git_show_head $testroot/repo`
358 local short_old_commit1=`trim_obj_id 28 $old_commit1`
359 local short_old_commit2=`trim_obj_id 28 $old_commit2`
360 local short_new_commit1=`trim_obj_id 28 $new_commit1`
361 local short_new_commit2=`trim_obj_id 28 $new_commit2`
363 echo "G alpha" > $testroot/stdout.expected
364 echo "D beta" >> $testroot/stdout.expected
365 echo "A epsilon/new" >> $testroot/stdout.expected
366 echo "$short_old_commit1 -> fold commit: committing changes" \
367 >> $testroot/stdout.expected
368 echo "G epsilon/zeta" >> $testroot/stdout.expected
369 echo -n "$short_old_commit2 -> $short_new_commit2: " \
370 >> $testroot/stdout.expected
371 echo "committing folded changes" >> $testroot/stdout.expected
372 echo "Switching work tree to refs/heads/master" \
373 >> $testroot/stdout.expected
375 cmp -s $testroot/stdout.expected $testroot/stdout
377 if [ "$ret" != "0" ]; then
378 diff -u $testroot/stdout.expected $testroot/stdout
379 test_done "$testroot" "$ret"
383 echo "modified alpha on master" > $testroot/content.expected
384 cat $testroot/wt/alpha > $testroot/content
385 cmp -s $testroot/content.expected $testroot/content
387 if [ "$ret" != "0" ]; then
388 diff -u $testroot/content.expected $testroot/content
389 test_done "$testroot" "$ret"
393 if [ -e $testroot/wt/beta ]; then
394 echo "removed file beta still exists on disk" >&2
395 test_done "$testroot" "1"
399 echo "new file on master" > $testroot/content.expected
400 cat $testroot/wt/epsilon/new > $testroot/content
401 cmp -s $testroot/content.expected $testroot/content
403 if [ "$ret" != "0" ]; then
404 diff -u $testroot/content.expected $testroot/content
405 test_done "$testroot" "$ret"
409 (cd $testroot/wt && got status > $testroot/stdout)
411 echo -n > $testroot/stdout.expected
412 cmp -s $testroot/stdout.expected $testroot/stdout
414 if [ "$ret" != "0" ]; then
415 diff -u $testroot/stdout.expected $testroot/stdout
416 test_done "$testroot" "$ret"
420 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
421 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
422 echo "commit $orig_commit" >> $testroot/stdout.expected
423 cmp -s $testroot/stdout.expected $testroot/stdout
425 if [ "$ret" != "0" ]; then
426 diff -u $testroot/stdout.expected $testroot/stdout
428 test_done "$testroot" "$ret"
431 function test_histedit_edit {
432 local testroot=`test_init histedit_edit`
434 local orig_commit=`git_show_head $testroot/repo`
436 echo "modified alpha on master" > $testroot/repo/alpha
437 (cd $testroot/repo && git rm -q beta)
438 echo "new file on master" > $testroot/repo/epsilon/new
439 (cd $testroot/repo && git add epsilon/new)
440 git_commit $testroot/repo -m "committing changes"
441 local old_commit1=`git_show_head $testroot/repo`
443 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
444 git_commit $testroot/repo -m "committing to zeta on master"
445 local old_commit2=`git_show_head $testroot/repo`
447 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
449 if [ "$ret" != "0" ]; then
450 test_done "$testroot" "$ret"
454 echo "edit $old_commit1" > $testroot/histedit-script
455 echo "mesg committing changes" >> $testroot/histedit-script
456 echo "pick $old_commit2" >> $testroot/histedit-script
458 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
461 local short_old_commit1=`trim_obj_id 28 $old_commit1`
462 local short_old_commit2=`trim_obj_id 28 $old_commit2`
464 echo "G alpha" > $testroot/stdout.expected
465 echo "D beta" >> $testroot/stdout.expected
466 echo "A epsilon/new" >> $testroot/stdout.expected
467 echo "Stopping histedit for amending commit $old_commit1" \
468 >> $testroot/stdout.expected
469 cmp -s $testroot/stdout.expected $testroot/stdout
471 if [ "$ret" != "0" ]; then
472 diff -u $testroot/stdout.expected $testroot/stdout
473 test_done "$testroot" "$ret"
477 echo "edited modified alpha on master" > $testroot/wt/alpha
479 (cd $testroot/wt && got histedit -c > $testroot/stdout)
481 local new_commit1=`git_show_parent_commit $testroot/repo`
482 local new_commit2=`git_show_head $testroot/repo`
484 local short_new_commit1=`trim_obj_id 28 $new_commit1`
485 local short_new_commit2=`trim_obj_id 28 $new_commit2`
487 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
488 > $testroot/stdout.expected
489 echo "G epsilon/zeta" >> $testroot/stdout.expected
490 echo -n "$short_old_commit2 -> $short_new_commit2: " \
491 >> $testroot/stdout.expected
492 echo "committing to zeta on master" >> $testroot/stdout.expected
493 echo "Switching work tree to refs/heads/master" \
494 >> $testroot/stdout.expected
496 cmp -s $testroot/stdout.expected $testroot/stdout
498 if [ "$ret" != "0" ]; then
499 diff -u $testroot/stdout.expected $testroot/stdout
500 test_done "$testroot" "$ret"
504 echo "edited modified alpha on master" > $testroot/content.expected
505 cat $testroot/wt/alpha > $testroot/content
506 cmp -s $testroot/content.expected $testroot/content
508 if [ "$ret" != "0" ]; then
509 diff -u $testroot/content.expected $testroot/content
510 test_done "$testroot" "$ret"
514 if [ -e $testroot/wt/beta ]; then
515 echo "removed file beta still exists on disk" >&2
516 test_done "$testroot" "1"
520 echo "new file on master" > $testroot/content.expected
521 cat $testroot/wt/epsilon/new > $testroot/content
522 cmp -s $testroot/content.expected $testroot/content
524 if [ "$ret" != "0" ]; then
525 diff -u $testroot/content.expected $testroot/content
526 test_done "$testroot" "$ret"
530 (cd $testroot/wt && got status > $testroot/stdout)
532 echo -n > $testroot/stdout.expected
533 cmp -s $testroot/stdout.expected $testroot/stdout
535 if [ "$ret" != "0" ]; then
536 diff -u $testroot/stdout.expected $testroot/stdout
537 test_done "$testroot" "$ret"
541 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
542 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
543 echo "commit $new_commit1" >> $testroot/stdout.expected
544 echo "commit $orig_commit" >> $testroot/stdout.expected
545 cmp -s $testroot/stdout.expected $testroot/stdout
547 if [ "$ret" != "0" ]; then
548 diff -u $testroot/stdout.expected $testroot/stdout
550 test_done "$testroot" "$ret"
553 function test_histedit_fold_last_commit {
554 local testroot=`test_init histedit_fold_last_commit`
556 local orig_commit=`git_show_head $testroot/repo`
558 echo "modified alpha on master" > $testroot/repo/alpha
559 (cd $testroot/repo && git rm -q beta)
560 echo "new file on master" > $testroot/repo/epsilon/new
561 (cd $testroot/repo && git add epsilon/new)
562 git_commit $testroot/repo -m "committing changes"
563 local old_commit1=`git_show_head $testroot/repo`
565 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
566 git_commit $testroot/repo -m "committing to zeta on master"
567 local old_commit2=`git_show_head $testroot/repo`
569 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
571 if [ "$ret" != "0" ]; then
572 test_done "$testroot" "$ret"
576 echo "pick $old_commit1" > $testroot/histedit-script
577 echo "fold $old_commit2" >> $testroot/histedit-script
578 echo "mesg committing folded changes" >> $testroot/histedit-script
580 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
581 > $testroot/stdout 2> $testroot/stderr)
584 if [ "$ret" == "0" ]; then
585 echo "histedit succeeded unexpectedly" >&2
586 test_done "$testroot" "1"
590 echo "got: last commit in histedit script cannot be folded" \
591 > $testroot/stderr.expected
593 cmp -s $testroot/stderr.expected $testroot/stderr
595 if [ "$ret" != "0" ]; then
596 diff -u $testroot/stderr.expected $testroot/stderr
598 test_done "$testroot" "$ret"
601 function test_histedit_missing_commit {
602 local testroot=`test_init histedit_missing_commit`
604 local orig_commit=`git_show_head $testroot/repo`
606 echo "modified alpha on master" > $testroot/repo/alpha
607 (cd $testroot/repo && git rm -q beta)
608 echo "new file on master" > $testroot/repo/epsilon/new
609 (cd $testroot/repo && git add epsilon/new)
610 git_commit $testroot/repo -m "committing changes"
611 local old_commit1=`git_show_head $testroot/repo`
613 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
614 git_commit $testroot/repo -m "committing to zeta on master"
615 local old_commit2=`git_show_head $testroot/repo`
617 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
619 if [ "$ret" != "0" ]; then
620 test_done "$testroot" "$ret"
624 echo "pick $old_commit1" > $testroot/histedit-script
625 echo "mesg committing changes" >> $testroot/histedit-script
627 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
628 > $testroot/stdout 2> $testroot/stderr)
631 if [ "$ret" == "0" ]; then
632 echo "histedit succeeded unexpectedly" >&2
633 test_done "$testroot" "1"
637 echo "got: commit $old_commit2 missing from histedit script" \
638 > $testroot/stderr.expected
640 cmp -s $testroot/stderr.expected $testroot/stderr
642 if [ "$ret" != "0" ]; then
643 diff -u $testroot/stderr.expected $testroot/stderr
645 test_done "$testroot" "$ret"
648 function test_histedit_abort {
649 local testroot=`test_init histedit_abort`
651 local orig_commit=`git_show_head $testroot/repo`
653 echo "modified alpha on master" > $testroot/repo/alpha
654 (cd $testroot/repo && git rm -q beta)
655 echo "new file on master" > $testroot/repo/epsilon/new
656 (cd $testroot/repo && git add epsilon/new)
657 git_commit $testroot/repo -m "committing changes"
658 local old_commit1=`git_show_head $testroot/repo`
660 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
661 git_commit $testroot/repo -m "committing to zeta on master"
662 local old_commit2=`git_show_head $testroot/repo`
664 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
666 if [ "$ret" != "0" ]; then
667 test_done "$testroot" "$ret"
671 echo "edit $old_commit1" > $testroot/histedit-script
672 echo "mesg committing changes" >> $testroot/histedit-script
673 echo "pick $old_commit2" >> $testroot/histedit-script
675 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
678 local short_old_commit1=`trim_obj_id 28 $old_commit1`
679 local short_old_commit2=`trim_obj_id 28 $old_commit2`
681 echo "G alpha" > $testroot/stdout.expected
682 echo "D beta" >> $testroot/stdout.expected
683 echo "A epsilon/new" >> $testroot/stdout.expected
684 echo "Stopping histedit for amending commit $old_commit1" \
685 >> $testroot/stdout.expected
686 cmp -s $testroot/stdout.expected $testroot/stdout
688 if [ "$ret" != "0" ]; then
689 diff -u $testroot/stdout.expected $testroot/stdout
690 test_done "$testroot" "$ret"
694 echo "edited modified alpha on master" > $testroot/wt/alpha
696 (cd $testroot/wt && got histedit -a > $testroot/stdout)
698 local new_commit1=`git_show_parent_commit $testroot/repo`
699 local new_commit2=`git_show_head $testroot/repo`
701 local short_new_commit1=`trim_obj_id 28 $new_commit1`
702 local short_new_commit2=`trim_obj_id 28 $new_commit2`
704 echo "Switching work tree to refs/heads/master" \
705 > $testroot/stdout.expected
706 echo "R alpha" >> $testroot/stdout.expected
707 echo "R beta" >> $testroot/stdout.expected
708 echo "R epsilon/new" >> $testroot/stdout.expected
709 echo "Histedit of refs/heads/master aborted" \
710 >> $testroot/stdout.expected
712 cmp -s $testroot/stdout.expected $testroot/stdout
714 if [ "$ret" != "0" ]; then
715 diff -u $testroot/stdout.expected $testroot/stdout
716 test_done "$testroot" "$ret"
720 for f in alpha beta; do
721 echo "$f" > $testroot/content.expected
722 cat $testroot/wt/$f > $testroot/content
723 cmp -s $testroot/content.expected $testroot/content
725 if [ "$ret" != "0" ]; then
726 diff -u $testroot/content.expected $testroot/content
727 test_done "$testroot" "$ret"
732 echo "new file on master" > $testroot/content.expected
733 cat $testroot/wt/epsilon/new > $testroot/content
734 cmp -s $testroot/content.expected $testroot/content
736 if [ "$ret" != "0" ]; then
737 diff -u $testroot/content.expected $testroot/content
738 test_done "$testroot" "$ret"
742 (cd $testroot/wt && got status > $testroot/stdout)
744 echo "? epsilon/new" > $testroot/stdout.expected
745 cmp -s $testroot/stdout.expected $testroot/stdout
747 if [ "$ret" != "0" ]; then
748 diff -u $testroot/stdout.expected $testroot/stdout
749 test_done "$testroot" "$ret"
753 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
754 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
755 echo "commit $new_commit1" >> $testroot/stdout.expected
756 echo "commit $orig_commit" >> $testroot/stdout.expected
757 cmp -s $testroot/stdout.expected $testroot/stdout
759 if [ "$ret" != "0" ]; then
760 diff -u $testroot/stdout.expected $testroot/stdout
762 test_done "$testroot" "$ret"
765 run_test test_histedit_no_op
766 run_test test_histedit_swap
767 run_test test_histedit_drop
768 run_test test_histedit_fold
769 run_test test_histedit_edit
770 run_test test_histedit_fold_last_commit
771 run_test test_histedit_missing_commit
772 run_test test_histedit_abort