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 test_histedit_no_op() {
20 local testroot=`test_init histedit_no_op`
22 local orig_commit=`git_show_head $testroot/repo`
23 local orig_author_time=`git_show_author_time $testroot/repo`
25 echo "modified alpha on master" > $testroot/repo/alpha
26 (cd $testroot/repo && git rm -q beta)
27 echo "new file on master" > $testroot/repo/epsilon/new
28 (cd $testroot/repo && git add epsilon/new)
29 git_commit $testroot/repo -m "committing changes"
30 local old_commit1=`git_show_head $testroot/repo`
31 local old_author_time1=`git_show_author_time $testroot/repo`
33 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
34 git_commit $testroot/repo -m "committing to zeta on master"
35 local old_commit2=`git_show_head $testroot/repo`
36 local old_author_time2=`git_show_author_time $testroot/repo`
38 got diff -r $testroot/repo $orig_commit $old_commit2 \
39 > $testroot/diff.expected
41 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
43 if [ $ret -ne 0 ]; then
44 test_done "$testroot" "$ret"
48 echo "pick $old_commit1" > $testroot/histedit-script
49 echo "pick $old_commit2" >> $testroot/histedit-script
51 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
54 local new_commit1=`git_show_parent_commit $testroot/repo`
55 local new_commit2=`git_show_head $testroot/repo`
56 local new_author_time2=`git_show_author_time $testroot/repo`
58 local short_old_commit1=`trim_obj_id 28 $old_commit1`
59 local short_old_commit2=`trim_obj_id 28 $old_commit2`
60 local short_new_commit1=`trim_obj_id 28 $new_commit1`
61 local short_new_commit2=`trim_obj_id 28 $new_commit2`
63 echo "G alpha" > $testroot/stdout.expected
64 echo "D beta" >> $testroot/stdout.expected
65 echo "A epsilon/new" >> $testroot/stdout.expected
66 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
67 >> $testroot/stdout.expected
68 echo "G epsilon/zeta" >> $testroot/stdout.expected
69 echo -n "$short_old_commit2 -> $short_new_commit2: " \
70 >> $testroot/stdout.expected
71 echo "committing to zeta on master" >> $testroot/stdout.expected
72 echo "Switching work tree to refs/heads/master" \
73 >> $testroot/stdout.expected
75 cmp -s $testroot/stdout.expected $testroot/stdout
77 if [ $ret -ne 0 ]; then
78 diff -u $testroot/stdout.expected $testroot/stdout
79 test_done "$testroot" "$ret"
83 echo "modified alpha on master" > $testroot/content.expected
84 cat $testroot/wt/alpha > $testroot/content
85 cmp -s $testroot/content.expected $testroot/content
87 if [ $ret -ne 0 ]; then
88 diff -u $testroot/content.expected $testroot/content
89 test_done "$testroot" "$ret"
93 if [ -e $testroot/wt/beta ]; then
94 echo "removed file beta still exists on disk" >&2
95 test_done "$testroot" "1"
99 echo "new file on master" > $testroot/content.expected
100 cat $testroot/wt/epsilon/new > $testroot/content
101 cmp -s $testroot/content.expected $testroot/content
103 if [ $ret -ne 0 ]; then
104 diff -u $testroot/content.expected $testroot/content
105 test_done "$testroot" "$ret"
109 (cd $testroot/wt && got status > $testroot/stdout)
111 echo -n > $testroot/stdout.expected
112 cmp -s $testroot/stdout.expected $testroot/stdout
114 if [ $ret -ne 0 ]; then
115 diff -u $testroot/stdout.expected $testroot/stdout
116 test_done "$testroot" "$ret"
120 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
121 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
122 echo "commit $new_commit1" >> $testroot/stdout.expected
123 echo "commit $orig_commit" >> $testroot/stdout.expected
124 cmp -s $testroot/stdout.expected $testroot/stdout
126 if [ $ret -ne 0 ]; then
127 diff -u $testroot/stdout.expected $testroot/stdout
128 test_done "$testroot" "$ret"
132 got diff -r $testroot/repo $orig_commit $new_commit2 \
134 sed -i '' -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
135 cmp -s $testroot/diff.expected $testroot/diff
137 if [ $ret -ne 0 ]; then
138 diff -u $testroot/diff.expected $testroot/diff
139 test_done "$testroot" "$ret"
143 (cd $testroot/wt && got update > $testroot/stdout)
145 echo 'Already up-to-date' > $testroot/stdout.expected
146 cmp -s $testroot/stdout.expected $testroot/stdout
148 if [ $ret -ne 0 ]; then
149 diff -u $testroot/stdout.expected $testroot/stdout
150 test_done "$testroot" "$ret"
154 # We should have a backup of old commits
155 (cd $testroot/repo && got histedit -l > $testroot/stdout)
156 d_orig1=`date -u -d "@$old_author_time1" +"%G-%m-%d"`
158 local prev_LC_TIME="$LC_TIME"
160 d_orig2=`date -u -d "@$old_author_time2" +"%a %b %e %X %Y UTC"`
161 export LC_TIME="$prev_LC_TIME"
162 d_new2=`date -u -d "@$new_author_time2" +"%G-%m-%d"`
163 d_orig=`date -u -d "@$orig_author_time" +"%G-%m-%d"`
164 cat > $testroot/stdout.expected <<EOF
165 -----------------------------------------------
166 commit $old_commit2 (formerly master)
170 committing to zeta on master
172 has become commit $new_commit2 (master)
173 $d_new2 $GOT_AUTHOR_11 committing to zeta on master
176 local is_forked=true d_fork fork_commit fork_commit_msg
178 if [ "$old_commit1" = "$new_commit1" ]; then
179 if [ "$old_commit2" = "$new_commit2" ]; then
183 fork_commit=$new_commit1
184 fork_commit_msg="committing changes"
188 fork_commit=$orig_commit
189 fork_commit_msg="adding the test tree"
192 $is_forked && cat >> $testroot/stdout.expected <<EOF
193 history forked at $fork_commit
194 $d_fork $GOT_AUTHOR_11 $fork_commit_msg
197 cmp -s $testroot/stdout.expected $testroot/stdout
199 if [ $ret -ne 0 ]; then
200 diff -u $testroot/stdout.expected $testroot/stdout
201 test_done "$testroot" "$ret"
205 (cd $testroot/repo && got histedit -X master \
206 > $testroot/stdout 2> $testroot/stderr)
207 echo -n "Deleted refs/got/backup/histedit/master/$new_commit2: " \
208 > $testroot/stdout.expected
209 echo "$old_commit2" >> $testroot/stdout.expected
210 echo -n > $testroot/stderr.expected
211 cmp -s $testroot/stdout.expected $testroot/stdout
213 if [ $ret -ne 0 ]; then
214 diff -u $testroot/stdout.expected $testroot/stdout
215 test_done "$testroot" "$ret"
218 cmp -s $testroot/stderr.expected $testroot/stderr
220 if [ $ret -ne 0 ]; then
221 diff -u $testroot/stderr.expected $testroot/stderr
222 test_done "$testroot" "$ret"
226 (cd $testroot/repo && got histedit -l > $testroot/stdout)
227 echo -n > $testroot/stdout.expected
228 cmp -s $testroot/stdout.expected $testroot/stdout
230 if [ $ret -ne 0 ]; then
231 diff -u $testroot/stdout.expected $testroot/stdout
233 test_done "$testroot" "$ret"
236 test_histedit_swap() {
237 local testroot=`test_init histedit_swap`
239 local orig_commit=`git_show_head $testroot/repo`
241 echo "modified alpha on master" > $testroot/repo/alpha
242 (cd $testroot/repo && git rm -q beta)
243 echo "new file on master" > $testroot/repo/epsilon/new
244 (cd $testroot/repo && git add epsilon/new)
245 git_commit $testroot/repo -m "committing changes"
246 local old_commit1=`git_show_head $testroot/repo`
248 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
249 git_commit $testroot/repo -m "committing to zeta on master"
250 local old_commit2=`git_show_head $testroot/repo`
252 got diff -r $testroot/repo $orig_commit $old_commit2 \
253 > $testroot/diff.expected
255 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
257 if [ $ret -ne 0 ]; then
258 test_done "$testroot" "$ret"
262 echo "pick $old_commit2" > $testroot/histedit-script
263 echo "pick $old_commit1" >> $testroot/histedit-script
265 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
268 local new_commit2=`git_show_parent_commit $testroot/repo`
269 local new_commit1=`git_show_head $testroot/repo`
271 local short_old_commit1=`trim_obj_id 28 $old_commit1`
272 local short_old_commit2=`trim_obj_id 28 $old_commit2`
273 local short_new_commit1=`trim_obj_id 28 $new_commit1`
274 local short_new_commit2=`trim_obj_id 28 $new_commit2`
276 echo "G epsilon/zeta" > $testroot/stdout.expected
277 echo -n "$short_old_commit2 -> $short_new_commit2: " \
278 >> $testroot/stdout.expected
279 echo "committing to zeta on master" >> $testroot/stdout.expected
280 echo "G alpha" >> $testroot/stdout.expected
281 echo "D beta" >> $testroot/stdout.expected
282 echo "A epsilon/new" >> $testroot/stdout.expected
283 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
284 >> $testroot/stdout.expected
285 echo "Switching work tree to refs/heads/master" \
286 >> $testroot/stdout.expected
288 cmp -s $testroot/stdout.expected $testroot/stdout
290 if [ $ret -ne 0 ]; then
291 diff -u $testroot/stdout.expected $testroot/stdout
292 test_done "$testroot" "$ret"
296 echo "modified alpha on master" > $testroot/content.expected
297 cat $testroot/wt/alpha > $testroot/content
298 cmp -s $testroot/content.expected $testroot/content
300 if [ $ret -ne 0 ]; then
301 diff -u $testroot/content.expected $testroot/content
302 test_done "$testroot" "$ret"
306 if [ -e $testroot/wt/beta ]; then
307 echo "removed file beta still exists on disk" >&2
308 test_done "$testroot" "1"
312 echo "new file on master" > $testroot/content.expected
313 cat $testroot/wt/epsilon/new > $testroot/content
314 cmp -s $testroot/content.expected $testroot/content
316 if [ $ret -ne 0 ]; then
317 diff -u $testroot/content.expected $testroot/content
318 test_done "$testroot" "$ret"
322 (cd $testroot/wt && got status > $testroot/stdout)
324 echo -n > $testroot/stdout.expected
325 cmp -s $testroot/stdout.expected $testroot/stdout
327 if [ $ret -ne 0 ]; then
328 diff -u $testroot/stdout.expected $testroot/stdout
329 test_done "$testroot" "$ret"
333 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
334 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
335 echo "commit $new_commit2" >> $testroot/stdout.expected
336 echo "commit $orig_commit" >> $testroot/stdout.expected
337 cmp -s $testroot/stdout.expected $testroot/stdout
339 if [ $ret -ne 0 ]; then
340 diff -u $testroot/stdout.expected $testroot/stdout
341 test_done "$testroot" "$ret"
345 got diff -r $testroot/repo $orig_commit $new_commit1 \
347 sed -i '' -e "s/$old_commit2/$new_commit1/" $testroot/diff.expected
348 cmp -s $testroot/diff.expected $testroot/diff
350 if [ $ret -ne 0 ]; then
351 diff -u $testroot/diff.expected $testroot/diff
353 test_done "$testroot" "$ret"
356 test_histedit_drop() {
357 local testroot=`test_init histedit_drop`
358 local orig_commit=`git_show_head $testroot/repo`
360 echo "modified alpha on master" > $testroot/repo/alpha
361 (cd $testroot/repo && git rm -q beta)
362 echo "new file on master" > $testroot/repo/epsilon/new
363 (cd $testroot/repo && git add epsilon/new)
364 git_commit $testroot/repo -m "committing changes"
365 local old_commit1=`git_show_head $testroot/repo`
367 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
368 git_commit $testroot/repo -m "committing to zeta on master"
369 local old_commit2=`git_show_head $testroot/repo`
371 got diff -r $testroot/repo $old_commit1 $old_commit2 \
372 > $testroot/diff.expected
374 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
376 if [ $ret -ne 0 ]; then
377 test_done "$testroot" "$ret"
381 echo "drop $old_commit1" > $testroot/histedit-script
382 echo "pick $old_commit2" >> $testroot/histedit-script
384 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
387 local new_commit2=`git_show_head $testroot/repo`
389 local short_old_commit1=`trim_obj_id 28 $old_commit1`
390 local short_old_commit2=`trim_obj_id 28 $old_commit2`
391 local short_new_commit2=`trim_obj_id 28 $new_commit2`
393 echo "$short_old_commit1 -> drop commit: committing changes" \
394 > $testroot/stdout.expected
395 echo "G epsilon/zeta" >> $testroot/stdout.expected
396 echo -n "$short_old_commit2 -> $short_new_commit2: " \
397 >> $testroot/stdout.expected
398 echo "committing to zeta on master" >> $testroot/stdout.expected
399 echo "Switching work tree to refs/heads/master" \
400 >> $testroot/stdout.expected
402 cmp -s $testroot/stdout.expected $testroot/stdout
404 if [ $ret -ne 0 ]; then
405 diff -u $testroot/stdout.expected $testroot/stdout
406 test_done "$testroot" "$ret"
410 for f in alpha beta; do
411 echo "$f" > $testroot/content.expected
412 cat $testroot/wt/$f > $testroot/content
413 cmp -s $testroot/content.expected $testroot/content
415 if [ $ret -ne 0 ]; then
416 diff -u $testroot/content.expected $testroot/content
417 test_done "$testroot" "$ret"
422 if [ -e $testroot/wt/new ]; then
423 echo "file new exists on disk but should not" >&2
424 test_done "$testroot" "1"
428 (cd $testroot/wt && got status > $testroot/stdout)
430 echo -n > $testroot/stdout.expected
431 cmp -s $testroot/stdout.expected $testroot/stdout
433 if [ $ret -ne 0 ]; then
434 diff -u $testroot/stdout.expected $testroot/stdout
435 test_done "$testroot" "$ret"
439 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
440 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
441 echo "commit $orig_commit" >> $testroot/stdout.expected
442 cmp -s $testroot/stdout.expected $testroot/stdout
444 if [ $ret -ne 0 ]; then
445 diff -u $testroot/stdout.expected $testroot/stdout
446 test_done "$testroot" "$ret"
450 got diff -r $testroot/repo $orig_commit $new_commit2 \
452 sed -i '' -e "s/$old_commit1/$orig_commit/" $testroot/diff.expected
453 sed -i '' -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
454 cmp -s $testroot/diff.expected $testroot/diff
456 if [ $ret -ne 0 ]; then
457 diff -u $testroot/diff.expected $testroot/diff
459 test_done "$testroot" "$ret"
462 test_histedit_fold() {
463 local testroot=`test_init histedit_fold`
465 local orig_commit=`git_show_head $testroot/repo`
467 echo "modified alpha on master" > $testroot/repo/alpha
468 (cd $testroot/repo && git rm -q beta)
469 echo "new file on master" > $testroot/repo/epsilon/new
470 (cd $testroot/repo && git add epsilon/new)
471 git_commit $testroot/repo -m "committing changes"
472 local old_commit1=`git_show_head $testroot/repo`
474 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
475 git_commit $testroot/repo -m "committing to zeta on master"
476 local old_commit2=`git_show_head $testroot/repo`
478 echo "modified delta on master" > $testroot/repo/gamma/delta
479 git_commit $testroot/repo -m "committing to delta on master"
480 local old_commit3=`git_show_head $testroot/repo`
482 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
484 if [ $ret -ne 0 ]; then
485 test_done "$testroot" "$ret"
489 echo "fold $old_commit1" > $testroot/histedit-script
490 echo "drop $old_commit2" >> $testroot/histedit-script
491 echo "pick $old_commit3" >> $testroot/histedit-script
492 echo "mesg committing folded changes" >> $testroot/histedit-script
494 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
497 local new_commit1=`git_show_parent_commit $testroot/repo`
498 local new_commit2=`git_show_head $testroot/repo`
500 local short_old_commit1=`trim_obj_id 28 $old_commit1`
501 local short_old_commit2=`trim_obj_id 28 $old_commit2`
502 local short_old_commit3=`trim_obj_id 28 $old_commit3`
503 local short_new_commit1=`trim_obj_id 28 $new_commit1`
504 local short_new_commit2=`trim_obj_id 28 $new_commit2`
506 echo "G alpha" > $testroot/stdout.expected
507 echo "D beta" >> $testroot/stdout.expected
508 echo "A epsilon/new" >> $testroot/stdout.expected
509 echo "$short_old_commit1 -> fold commit: committing changes" \
510 >> $testroot/stdout.expected
511 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
512 echo "drop commit: committing to zeta on master" \
513 >> $testroot/stdout.expected
514 echo "G gamma/delta" >> $testroot/stdout.expected
515 echo -n "$short_old_commit3 -> $short_new_commit2: " \
516 >> $testroot/stdout.expected
517 echo "committing folded changes" >> $testroot/stdout.expected
518 echo "Switching work tree to refs/heads/master" \
519 >> $testroot/stdout.expected
521 cmp -s $testroot/stdout.expected $testroot/stdout
523 if [ $ret -ne 0 ]; then
524 diff -u $testroot/stdout.expected $testroot/stdout
525 test_done "$testroot" "$ret"
529 echo "modified alpha on master" > $testroot/content.expected
530 cat $testroot/wt/alpha > $testroot/content
531 cmp -s $testroot/content.expected $testroot/content
533 if [ $ret -ne 0 ]; then
534 diff -u $testroot/content.expected $testroot/content
535 test_done "$testroot" "$ret"
539 if [ -e $testroot/wt/beta ]; then
540 echo "removed file beta still exists on disk" >&2
541 test_done "$testroot" "1"
545 echo "new file on master" > $testroot/content.expected
546 cat $testroot/wt/epsilon/new > $testroot/content
547 cmp -s $testroot/content.expected $testroot/content
549 if [ $ret -ne 0 ]; then
550 diff -u $testroot/content.expected $testroot/content
551 test_done "$testroot" "$ret"
555 (cd $testroot/wt && got status > $testroot/stdout)
557 echo -n > $testroot/stdout.expected
558 cmp -s $testroot/stdout.expected $testroot/stdout
560 if [ $ret -ne 0 ]; then
561 diff -u $testroot/stdout.expected $testroot/stdout
562 test_done "$testroot" "$ret"
566 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
567 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
568 echo "commit $orig_commit" >> $testroot/stdout.expected
569 cmp -s $testroot/stdout.expected $testroot/stdout
571 if [ $ret -ne 0 ]; then
572 diff -u $testroot/stdout.expected $testroot/stdout
574 test_done "$testroot" "$ret"
577 test_histedit_edit() {
578 local testroot=`test_init histedit_edit`
580 local orig_commit=`git_show_head $testroot/repo`
582 echo "modified alpha on master" > $testroot/repo/alpha
583 (cd $testroot/repo && git rm -q beta)
584 echo "new file on master" > $testroot/repo/epsilon/new
585 (cd $testroot/repo && git add epsilon/new)
586 git_commit $testroot/repo -m "committing changes"
587 local old_commit1=`git_show_head $testroot/repo`
589 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
590 git_commit $testroot/repo -m "committing to zeta on master"
591 local old_commit2=`git_show_head $testroot/repo`
593 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
595 if [ $ret -ne 0 ]; then
596 test_done "$testroot" "$ret"
600 echo "edit $old_commit1" > $testroot/histedit-script
601 echo "mesg committing changes" >> $testroot/histedit-script
602 echo "pick $old_commit2" >> $testroot/histedit-script
604 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
607 local short_old_commit1=`trim_obj_id 28 $old_commit1`
608 local short_old_commit2=`trim_obj_id 28 $old_commit2`
610 echo "G alpha" > $testroot/stdout.expected
611 echo "D beta" >> $testroot/stdout.expected
612 echo "A epsilon/new" >> $testroot/stdout.expected
613 echo "Stopping histedit for amending commit $old_commit1" \
614 >> $testroot/stdout.expected
615 cmp -s $testroot/stdout.expected $testroot/stdout
617 if [ $ret -ne 0 ]; then
618 diff -u $testroot/stdout.expected $testroot/stdout
619 test_done "$testroot" "$ret"
623 echo "edited modified alpha on master" > $testroot/wt/alpha
625 # test interaction of 'got stage' and histedit -c
626 (cd $testroot/wt && got stage alpha > /dev/null)
627 (cd $testroot/wt && got histedit -c > $testroot/stdout \
630 if [ $ret -eq 0 ]; then
631 echo "histedit succeeded unexpectedly" >&2
632 test_done "$testroot" "1"
635 echo -n "got: work tree contains files with staged changes; " \
636 > $testroot/stderr.expected
637 echo "these changes must be committed or unstaged first" \
638 >> $testroot/stderr.expected
639 cmp -s $testroot/stderr.expected $testroot/stderr
641 if [ $ret -ne 0 ]; then
642 diff -u $testroot/stderr.expected $testroot/stderr
643 test_done "$testroot" "$ret"
647 (cd $testroot/wt && got unstage alpha > /dev/null)
648 (cd $testroot/wt && got histedit -c > $testroot/stdout)
650 local new_commit1=`git_show_parent_commit $testroot/repo`
651 local new_commit2=`git_show_head $testroot/repo`
653 local short_new_commit1=`trim_obj_id 28 $new_commit1`
654 local short_new_commit2=`trim_obj_id 28 $new_commit2`
656 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
657 > $testroot/stdout.expected
658 echo "G epsilon/zeta" >> $testroot/stdout.expected
659 echo -n "$short_old_commit2 -> $short_new_commit2: " \
660 >> $testroot/stdout.expected
661 echo "committing to zeta on master" >> $testroot/stdout.expected
662 echo "Switching work tree to refs/heads/master" \
663 >> $testroot/stdout.expected
665 cmp -s $testroot/stdout.expected $testroot/stdout
667 if [ $ret -ne 0 ]; then
668 diff -u $testroot/stdout.expected $testroot/stdout
669 test_done "$testroot" "$ret"
673 echo "edited modified alpha on master" > $testroot/content.expected
674 cat $testroot/wt/alpha > $testroot/content
675 cmp -s $testroot/content.expected $testroot/content
677 if [ $ret -ne 0 ]; then
678 diff -u $testroot/content.expected $testroot/content
679 test_done "$testroot" "$ret"
683 if [ -e $testroot/wt/beta ]; then
684 echo "removed file beta still exists on disk" >&2
685 test_done "$testroot" "1"
689 echo "new file on master" > $testroot/content.expected
690 cat $testroot/wt/epsilon/new > $testroot/content
691 cmp -s $testroot/content.expected $testroot/content
693 if [ $ret -ne 0 ]; then
694 diff -u $testroot/content.expected $testroot/content
695 test_done "$testroot" "$ret"
699 (cd $testroot/wt && got status > $testroot/stdout)
701 echo -n > $testroot/stdout.expected
702 cmp -s $testroot/stdout.expected $testroot/stdout
704 if [ $ret -ne 0 ]; then
705 diff -u $testroot/stdout.expected $testroot/stdout
706 test_done "$testroot" "$ret"
710 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
711 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
712 echo "commit $new_commit1" >> $testroot/stdout.expected
713 echo "commit $orig_commit" >> $testroot/stdout.expected
714 cmp -s $testroot/stdout.expected $testroot/stdout
716 if [ $ret -ne 0 ]; then
717 diff -u $testroot/stdout.expected $testroot/stdout
719 test_done "$testroot" "$ret"
722 test_histedit_fold_last_commit() {
723 local testroot=`test_init histedit_fold_last_commit`
725 local orig_commit=`git_show_head $testroot/repo`
727 echo "modified alpha on master" > $testroot/repo/alpha
728 (cd $testroot/repo && git rm -q beta)
729 echo "new file on master" > $testroot/repo/epsilon/new
730 (cd $testroot/repo && git add epsilon/new)
731 git_commit $testroot/repo -m "committing changes"
732 local old_commit1=`git_show_head $testroot/repo`
734 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
735 git_commit $testroot/repo -m "committing to zeta on master"
736 local old_commit2=`git_show_head $testroot/repo`
738 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
740 if [ $ret -ne 0 ]; then
741 test_done "$testroot" "$ret"
745 echo "pick $old_commit1" > $testroot/histedit-script
746 echo "fold $old_commit2" >> $testroot/histedit-script
748 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
749 > $testroot/stdout 2> $testroot/stderr)
752 if [ $ret -eq 0 ]; then
753 echo "histedit succeeded unexpectedly" >&2
754 test_done "$testroot" "1"
758 echo "got: last commit in histedit script cannot be folded" \
759 > $testroot/stderr.expected
761 cmp -s $testroot/stderr.expected $testroot/stderr
763 if [ $ret -ne 0 ]; then
764 diff -u $testroot/stderr.expected $testroot/stderr
766 test_done "$testroot" "$ret"
769 test_histedit_missing_commit() {
770 local testroot=`test_init histedit_missing_commit`
772 local orig_commit=`git_show_head $testroot/repo`
774 echo "modified alpha on master" > $testroot/repo/alpha
775 (cd $testroot/repo && git rm -q beta)
776 echo "new file on master" > $testroot/repo/epsilon/new
777 (cd $testroot/repo && git add epsilon/new)
778 git_commit $testroot/repo -m "committing changes"
779 local old_commit1=`git_show_head $testroot/repo`
781 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
782 git_commit $testroot/repo -m "committing to zeta on master"
783 local old_commit2=`git_show_head $testroot/repo`
785 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
787 if [ $ret -ne 0 ]; then
788 test_done "$testroot" "$ret"
792 echo "pick $old_commit1" > $testroot/histedit-script
793 echo "mesg committing changes" >> $testroot/histedit-script
795 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
796 > $testroot/stdout 2> $testroot/stderr)
799 if [ $ret -eq 0 ]; then
800 echo "histedit succeeded unexpectedly" >&2
801 test_done "$testroot" "1"
805 echo "got: commit $old_commit2 missing from histedit script" \
806 > $testroot/stderr.expected
808 cmp -s $testroot/stderr.expected $testroot/stderr
810 if [ $ret -ne 0 ]; then
811 diff -u $testroot/stderr.expected $testroot/stderr
813 test_done "$testroot" "$ret"
816 test_histedit_abort() {
817 local testroot=`test_init histedit_abort`
819 local orig_commit=`git_show_head $testroot/repo`
821 echo "modified alpha on master" > $testroot/repo/alpha
822 (cd $testroot/repo && git rm -q beta)
823 echo "new file on master" > $testroot/repo/epsilon/new
824 (cd $testroot/repo && git add epsilon/new)
825 git_commit $testroot/repo -m "committing changes"
826 local old_commit1=`git_show_head $testroot/repo`
828 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
829 git_commit $testroot/repo -m "committing to zeta on master"
830 local old_commit2=`git_show_head $testroot/repo`
832 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
834 if [ $ret -ne 0 ]; then
835 test_done "$testroot" "$ret"
839 # unrelated unversioned file in work tree
840 touch $testroot/wt/unversioned-file
842 echo "edit $old_commit1" > $testroot/histedit-script
843 echo "mesg committing changes" >> $testroot/histedit-script
844 echo "pick $old_commit2" >> $testroot/histedit-script
846 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
849 local short_old_commit1=`trim_obj_id 28 $old_commit1`
850 local short_old_commit2=`trim_obj_id 28 $old_commit2`
852 echo "G alpha" > $testroot/stdout.expected
853 echo "D beta" >> $testroot/stdout.expected
854 echo "A epsilon/new" >> $testroot/stdout.expected
855 echo "Stopping histedit for amending commit $old_commit1" \
856 >> $testroot/stdout.expected
857 cmp -s $testroot/stdout.expected $testroot/stdout
859 if [ $ret -ne 0 ]; then
860 diff -u $testroot/stdout.expected $testroot/stdout
861 test_done "$testroot" "$ret"
865 echo "edited modified alpha on master" > $testroot/wt/alpha
867 (cd $testroot/wt && got histedit -a > $testroot/stdout)
869 local new_commit1=`git_show_parent_commit $testroot/repo`
870 local new_commit2=`git_show_head $testroot/repo`
872 echo "Switching work tree to refs/heads/master" \
873 > $testroot/stdout.expected
874 echo "R alpha" >> $testroot/stdout.expected
875 echo "R beta" >> $testroot/stdout.expected
876 echo "R epsilon/new" >> $testroot/stdout.expected
877 echo "Histedit of refs/heads/master aborted" \
878 >> $testroot/stdout.expected
880 cmp -s $testroot/stdout.expected $testroot/stdout
882 if [ $ret -ne 0 ]; then
883 diff -u $testroot/stdout.expected $testroot/stdout
884 test_done "$testroot" "$ret"
888 for f in alpha beta; do
889 echo "$f" > $testroot/content.expected
890 cat $testroot/wt/$f > $testroot/content
891 cmp -s $testroot/content.expected $testroot/content
893 if [ $ret -ne 0 ]; then
894 diff -u $testroot/content.expected $testroot/content
895 test_done "$testroot" "$ret"
900 echo "new file on master" > $testroot/content.expected
901 cat $testroot/wt/epsilon/new > $testroot/content
902 cmp -s $testroot/content.expected $testroot/content
904 if [ $ret -ne 0 ]; then
905 diff -u $testroot/content.expected $testroot/content
906 test_done "$testroot" "$ret"
910 (cd $testroot/wt && got status > $testroot/stdout)
912 echo "? epsilon/new" > $testroot/stdout.expected
913 echo "? unversioned-file" >> $testroot/stdout.expected
914 cmp -s $testroot/stdout.expected $testroot/stdout
916 if [ $ret -ne 0 ]; then
917 diff -u $testroot/stdout.expected $testroot/stdout
918 test_done "$testroot" "$ret"
922 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
923 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
924 echo "commit $new_commit1" >> $testroot/stdout.expected
925 echo "commit $orig_commit" >> $testroot/stdout.expected
926 cmp -s $testroot/stdout.expected $testroot/stdout
928 if [ $ret -ne 0 ]; then
929 diff -u $testroot/stdout.expected $testroot/stdout
931 test_done "$testroot" "$ret"
934 test_histedit_path_prefix_drop() {
935 local testroot=`test_init histedit_path_prefix_drop`
936 local orig_commit=`git_show_head $testroot/repo`
938 echo "modified zeta" > $testroot/repo/epsilon/zeta
939 git_commit $testroot/repo -m "changing zeta"
940 local old_commit1=`git_show_head $testroot/repo`
942 got checkout -c $orig_commit -p gamma $testroot/repo \
943 $testroot/wt > /dev/null
945 if [ $ret -ne 0 ]; then
946 test_done "$testroot" "$ret"
950 echo "drop $old_commit1" > $testroot/histedit-script
952 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
953 > $testroot/stdout 2> $testroot/stderr)
956 if [ $ret -eq 0 ]; then
957 echo "histedit succeeded unexpectedly" >&2
958 test_done "$testroot" "1"
962 echo -n "got: cannot edit branch history which contains changes " \
963 > $testroot/stderr.expected
964 echo "outside of this work tree's path prefix" \
965 >> $testroot/stderr.expected
967 cmp -s $testroot/stderr.expected $testroot/stderr
969 if [ $ret -ne 0 ]; then
970 diff -u $testroot/stderr.expected $testroot/stderr
971 test_done "$testroot" "$ret"
976 got checkout -c $orig_commit -p epsilon $testroot/repo \
977 $testroot/wt > /dev/null
979 if [ $ret -ne 0 ]; then
980 test_done "$testroot" "$ret"
983 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
986 local short_old_commit1=`trim_obj_id 28 $old_commit1`
987 local short_old_commit2=`trim_obj_id 28 $old_commit2`
989 echo "$short_old_commit1 -> drop commit: changing zeta" \
990 > $testroot/stdout.expected
991 echo "Switching work tree to refs/heads/master" \
992 >> $testroot/stdout.expected
994 cmp -s $testroot/stdout.expected $testroot/stdout
996 if [ $ret -ne 0 ]; then
997 diff -u $testroot/stdout.expected $testroot/stdout
998 test_done "$testroot" "$ret"
1002 echo "zeta" > $testroot/content.expected
1003 cat $testroot/wt/zeta > $testroot/content
1004 cmp -s $testroot/content.expected $testroot/content
1006 if [ $ret -ne 0 ]; then
1007 diff -u $testroot/content.expected $testroot/content
1008 test_done "$testroot" "$ret"
1013 (cd $testroot/wt && got status > $testroot/stdout)
1015 echo -n > $testroot/stdout.expected
1016 cmp -s $testroot/stdout.expected $testroot/stdout
1018 if [ $ret -ne 0 ]; then
1019 diff -u $testroot/stdout.expected $testroot/stdout
1020 test_done "$testroot" "$ret"
1024 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1025 echo "commit $orig_commit (master)" > $testroot/stdout.expected
1026 cmp -s $testroot/stdout.expected $testroot/stdout
1028 if [ $ret -ne 0 ]; then
1029 diff -u $testroot/stdout.expected $testroot/stdout
1031 test_done "$testroot" "$ret"
1034 test_histedit_path_prefix_edit() {
1035 local testroot=`test_init histedit_path_prefix_edit`
1036 local orig_commit=`git_show_head $testroot/repo`
1038 echo "modified zeta" > $testroot/repo/epsilon/zeta
1039 git_commit $testroot/repo -m "changing zeta"
1040 local old_commit1=`git_show_head $testroot/repo`
1042 got diff -r $testroot/repo $orig_commit $old_commit1 \
1043 > $testroot/diff.expected
1045 got checkout -c $orig_commit -p gamma $testroot/repo \
1046 $testroot/wt > /dev/null
1048 if [ $ret -ne 0 ]; then
1049 test_done "$testroot" "$ret"
1053 echo "edit $old_commit1" > $testroot/histedit-script
1054 echo "mesg modified zeta" >> $testroot/histedit-script
1056 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1057 > $testroot/stdout 2> $testroot/stderr)
1060 if [ $ret -eq 0 ]; then
1061 echo "histedit succeeded unexpectedly" >&2
1062 test_done "$testroot" "1"
1066 echo -n "got: cannot edit branch history which contains changes " \
1067 > $testroot/stderr.expected
1068 echo "outside of this work tree's path prefix" \
1069 >> $testroot/stderr.expected
1071 cmp -s $testroot/stderr.expected $testroot/stderr
1073 if [ $ret -ne 0 ]; then
1074 diff -u $testroot/stderr.expected $testroot/stderr
1075 test_done "$testroot" "$ret"
1080 got checkout -c $orig_commit -p epsilon $testroot/repo \
1081 $testroot/wt > /dev/null
1083 if [ $ret -ne 0 ]; then
1084 test_done "$testroot" "$ret"
1087 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1090 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1092 echo "G zeta" > $testroot/stdout.expected
1093 echo "Stopping histedit for amending commit $old_commit1" \
1094 >> $testroot/stdout.expected
1095 cmp -s $testroot/stdout.expected $testroot/stdout
1097 if [ $ret -ne 0 ]; then
1098 diff -u $testroot/stdout.expected $testroot/stdout
1099 test_done "$testroot" "$ret"
1103 echo "modified zeta" > $testroot/content.expected
1104 cat $testroot/wt/zeta > $testroot/content
1105 cmp -s $testroot/content.expected $testroot/content
1107 if [ $ret -ne 0 ]; then
1108 diff -u $testroot/content.expected $testroot/content
1109 test_done "$testroot" "$ret"
1113 (cd $testroot/wt && got status > $testroot/stdout)
1115 echo "M zeta"> $testroot/stdout.expected
1116 cmp -s $testroot/stdout.expected $testroot/stdout
1118 if [ $ret -ne 0 ]; then
1119 diff -u $testroot/stdout.expected $testroot/stdout
1120 test_done "$testroot" "$ret"
1124 (cd $testroot/wt && got histedit -c > $testroot/stdout)
1126 local new_commit1=`git_show_head $testroot/repo`
1127 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1129 echo -n "$short_old_commit1 -> $short_new_commit1: " \
1130 > $testroot/stdout.expected
1131 echo "modified zeta" >> $testroot/stdout.expected
1132 echo "Switching work tree to refs/heads/master" \
1133 >> $testroot/stdout.expected
1135 cmp -s $testroot/stdout.expected $testroot/stdout
1137 if [ $ret -ne 0 ]; then
1138 diff -u $testroot/stdout.expected $testroot/stdout
1139 test_done "$testroot" "$ret"
1143 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1144 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1145 echo "commit $orig_commit" >> $testroot/stdout.expected
1146 cmp -s $testroot/stdout.expected $testroot/stdout
1148 if [ $ret -ne 0 ]; then
1149 diff -u $testroot/stdout.expected $testroot/stdout
1150 test_done "$testroot" "$ret"
1154 got diff -r $testroot/repo $orig_commit $new_commit1 \
1156 sed -i '' -e "s/$old_commit1/$new_commit1/" $testroot/diff.expected
1157 cmp -s $testroot/diff.expected $testroot/diff
1159 if [ $ret -ne 0 ]; then
1160 diff -u $testroot/diff.expected $testroot/diff
1162 test_done "$testroot" "$ret"
1165 test_histedit_outside_refs_heads() {
1166 local testroot=`test_init histedit_outside_refs_heads`
1167 local commit1=`git_show_head $testroot/repo`
1169 got checkout $testroot/repo $testroot/wt > /dev/null
1171 if [ $ret -ne 0 ]; then
1172 echo "got checkout failed unexpectedly"
1173 test_done "$testroot" "$ret"
1177 echo "modified alpha" > $testroot/wt/alpha
1179 (cd $testroot/wt && got commit -m 'change alpha' \
1180 > $testroot/stdout 2> $testroot/stderr)
1182 if [ $ret -ne 0 ]; then
1183 echo "got commit failed unexpectedly" >&2
1184 test_done "$testroot" "1"
1187 local commit2=`git_show_head $testroot/repo`
1189 got ref -r $testroot/repo -c master refs/remotes/origin/master
1191 if [ $ret -ne 0 ]; then
1192 echo "got ref failed unexpectedly" >&2
1193 test_done "$testroot" "1"
1197 (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1199 if [ $ret -ne 0 ]; then
1200 echo "got update failed unexpectedly"
1201 test_done "$testroot" "$ret"
1205 echo "edit $commit2" > $testroot/histedit-script
1206 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1207 2> $testroot/stderr)
1209 echo -n "got: will not edit commit history of a branch outside the " \
1210 > $testroot/stderr.expected
1211 echo '"refs/heads/" reference namespace' \
1212 >> $testroot/stderr.expected
1213 cmp -s $testroot/stderr.expected $testroot/stderr
1215 if [ $ret -ne 0 ]; then
1216 diff -u $testroot/stderr.expected $testroot/stderr
1218 test_done "$testroot" "$ret"
1221 test_histedit_fold_last_commit_swap() {
1222 local testroot=`test_init histedit_fold_last_commit_swap`
1224 local orig_commit=`git_show_head $testroot/repo`
1226 echo "modified alpha on master" > $testroot/repo/alpha
1227 (cd $testroot/repo && git rm -q beta)
1228 echo "new file on master" > $testroot/repo/epsilon/new
1229 (cd $testroot/repo && git add epsilon/new)
1230 git_commit $testroot/repo -m "committing changes"
1231 local old_commit1=`git_show_head $testroot/repo`
1233 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1234 git_commit $testroot/repo -m "committing to zeta on master"
1235 local old_commit2=`git_show_head $testroot/repo`
1237 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1239 if [ $ret -ne 0 ]; then
1240 test_done "$testroot" "$ret"
1244 # fold commit2 into commit1 (requires swapping commits)
1245 echo "fold $old_commit2" > $testroot/histedit-script
1246 echo "pick $old_commit1" >> $testroot/histedit-script
1247 echo "mesg committing folded changes" >> $testroot/histedit-script
1249 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1250 > $testroot/stdout 2> $testroot/stderr)
1253 if [ $ret -ne 0 ]; then
1254 echo "histedit failed unexpectedly" >&2
1255 test_done "$testroot" "$ret"
1259 local new_commit=`git_show_head $testroot/repo`
1261 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1262 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1263 local short_new_commit=`trim_obj_id 28 $new_commit`
1265 echo "G epsilon/zeta" >> $testroot/stdout.expected
1266 echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1267 >> $testroot/stdout.expected
1268 echo "on master" >> $testroot/stdout.expected
1269 echo "G alpha" >> $testroot/stdout.expected
1270 echo "D beta" >> $testroot/stdout.expected
1271 echo "A epsilon/new" >> $testroot/stdout.expected
1272 echo -n "$short_old_commit1 -> $short_new_commit: " \
1273 >> $testroot/stdout.expected
1274 echo "committing folded changes" >> $testroot/stdout.expected
1275 echo "Switching work tree to refs/heads/master" \
1276 >> $testroot/stdout.expected
1278 cmp -s $testroot/stdout.expected $testroot/stdout
1280 if [ $ret -ne 0 ]; then
1281 diff -u $testroot/stdout.expected $testroot/stdout
1283 test_done "$testroot" "$ret"
1286 test_histedit_split_commit() {
1287 local testroot=`test_init histedit_split_commit`
1289 local orig_commit=`git_show_head $testroot/repo`
1291 echo "modified alpha on master" > $testroot/repo/alpha
1292 (cd $testroot/repo && git rm -q beta)
1293 echo "new file on master" > $testroot/repo/epsilon/new
1294 (cd $testroot/repo && git add epsilon/new)
1295 git_commit $testroot/repo -m "committing changes 1"
1296 local old_commit1=`git_show_head $testroot/repo`
1297 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1299 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1300 git_commit $testroot/repo -m "committing changes 2"
1301 local old_commit2=`git_show_head $testroot/repo`
1302 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1304 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1306 if [ $ret -ne 0 ]; then
1307 test_done "$testroot" "$ret"
1311 # split commit1 into commitA and commitB and commitC
1312 echo "e $old_commit1" > $testroot/histedit-script
1313 echo "p $old_commit2" >> $testroot/histedit-script
1315 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1316 > $testroot/stdout 2> $testroot/stderr)
1318 if [ $ret -ne 0 ]; then
1319 echo "histedit failed unexpectedly:" >&2
1320 cat $testroot/stderr >&2
1321 test_done "$testroot" "$ret"
1325 echo "G alpha" > $testroot/stdout.expected
1326 echo "D beta" >> $testroot/stdout.expected
1327 echo "A epsilon/new" >> $testroot/stdout.expected
1328 echo "Stopping histedit for amending commit $old_commit1" \
1329 >> $testroot/stdout.expected
1331 cmp -s $testroot/stdout.expected $testroot/stdout
1333 if [ $ret -ne 0 ]; then
1334 diff -u $testroot/stdout.expected $testroot/stdout
1335 test_done "$testroot" "$ret"
1339 (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1341 if [ $ret -ne 0 ]; then
1342 echo "commit failed unexpectedly" >&2
1343 test_done "$testroot" "$ret"
1347 (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1349 if [ $ret -ne 0 ]; then
1350 echo "commit failed unexpectedly" >&2
1351 test_done "$testroot" "$ret"
1355 (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1357 if [ $ret -ne 0 ]; then
1358 echo "commit failed unexpectedly" >&2
1359 test_done "$testroot" "$ret"
1363 (cd $testroot/wt && got histedit -c \
1364 > $testroot/stdout 2> $testroot/stderr)
1366 if [ $ret -ne 0 ]; then
1367 echo "histedit failed unexpectedly:" >&2
1368 cat $testroot/stderr >&2
1369 test_done "$testroot" "$ret"
1372 local new_commit2=`git_show_head $testroot/repo`
1373 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1375 echo "$short_old_commit1 -> no-op change: committing changes 1" \
1376 > $testroot/stdout.expected
1377 echo "G epsilon/zeta" >> $testroot/stdout.expected
1378 echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1379 >> $testroot/stdout.expected
1380 echo "Switching work tree to refs/heads/master" \
1381 >> $testroot/stdout.expected
1383 cmp -s $testroot/stdout.expected $testroot/stdout
1385 if [ $ret -ne 0 ]; then
1386 diff -u $testroot/stdout.expected $testroot/stdout
1388 test_done "$testroot" "$ret"
1392 test_histedit_duplicate_commit_in_script() {
1393 local testroot=`test_init histedit_duplicate_commit_in_script`
1395 local orig_commit=`git_show_head $testroot/repo`
1397 echo "modified alpha on master" > $testroot/repo/alpha
1398 (cd $testroot/repo && git rm -q beta)
1399 echo "new file on master" > $testroot/repo/epsilon/new
1400 (cd $testroot/repo && git add epsilon/new)
1401 git_commit $testroot/repo -m "committing changes 1"
1402 local old_commit1=`git_show_head $testroot/repo`
1404 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1405 git_commit $testroot/repo -m "committing changes 2"
1406 local old_commit2=`git_show_head $testroot/repo`
1408 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1410 if [ $ret -ne 0 ]; then
1411 test_done "$testroot" "$ret"
1415 # This histedit script lists commit1 more than once
1416 echo "p $old_commit1" > $testroot/histedit-script
1417 echo "p $old_commit1" >> $testroot/histedit-script
1418 echo "p $old_commit2" >> $testroot/histedit-script
1420 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1421 > $testroot/stdout 2> $testroot/stderr)
1423 if [ $ret -eq 0 ]; then
1424 echo "histedit succeeded unexpectedly:" >&2
1425 cat $testroot/stdout >&2
1426 test_done "$testroot" "$ret"
1430 echo -n "got: commit $old_commit1 is listed more than once " \
1431 > $testroot/stderr.expected
1432 echo "in histedit script" >> $testroot/stderr.expected
1434 cmp -s $testroot/stderr.expected $testroot/stderr
1436 if [ $ret -ne 0 ]; then
1437 diff -u $testroot/stderr.expected $testroot/stderr
1439 test_done "$testroot" "$ret"
1443 # if a previous commit introduces a new file, and it is folded into a commit
1444 # that deletes the same file, the file still exists after the histedit
1445 test_histedit_fold_add_delete() {
1446 local testroot=`test_init histedit_fold_add_delete`
1448 local orig_commit=`git_show_head $testroot/repo`
1450 echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1451 (cd $testroot/repo && git add epsilon/psi)
1452 git_commit $testroot/repo -m "committing changes"
1453 local old_commit1=`git_show_head $testroot/repo`
1455 echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1456 git_commit $testroot/repo -m "editing psi"
1457 local old_commit2=`git_show_head $testroot/repo`
1459 (cd $testroot/repo && git rm -q epsilon/psi)
1460 git_commit $testroot/repo -m "removing psi"
1461 local old_commit3=`git_show_head $testroot/repo`
1463 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1465 if [ $ret -ne 0 ]; then
1466 test_done "$testroot" "$ret"
1470 echo "fold $old_commit1" > $testroot/histedit-script
1471 echo "fold $old_commit2" >> $testroot/histedit-script
1472 echo "pick $old_commit3" >> $testroot/histedit-script
1473 echo "mesg folded changes" >> $testroot/histedit-script
1475 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1478 local new_commit1=`git_show_head $testroot/repo`
1480 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1481 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1482 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1483 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1485 echo "A epsilon/psi" >> $testroot/stdout.expected
1486 echo "$short_old_commit1 -> fold commit: committing changes" \
1487 >> $testroot/stdout.expected
1488 echo "G epsilon/psi" >> $testroot/stdout.expected
1489 echo "$short_old_commit2 -> fold commit: editing psi" \
1490 >> $testroot/stdout.expected
1491 echo "D epsilon/psi" >> $testroot/stdout.expected
1492 echo "$short_old_commit3 -> no-op change: folded changes" \
1493 >> $testroot/stdout.expected
1494 echo "Switching work tree to refs/heads/master" \
1495 >> $testroot/stdout.expected
1497 cmp -s $testroot/stdout.expected $testroot/stdout
1499 if [ $ret -ne 0 ]; then
1500 diff -u $testroot/stdout.expected $testroot/stdout
1501 test_done "$testroot" "$ret"
1505 if [ -e $testroot/wt/epsilon/psi ]; then
1506 echo "removed file psi still exists on disk" >&2
1507 test_done "$testroot" "1"
1511 (cd $testroot/wt && got status > $testroot/stdout)
1513 echo -n > $testroot/stdout.expected
1514 cmp -s $testroot/stdout.expected $testroot/stdout
1516 if [ $ret -ne 0 ]; then
1517 diff -u $testroot/stdout.expected $testroot/stdout
1518 test_done "$testroot" "$ret"
1522 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1523 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1524 cmp -s $testroot/stdout.expected $testroot/stdout
1526 if [ $ret -ne 0 ]; then
1527 diff -u $testroot/stdout.expected $testroot/stdout
1528 test_done "$testroot" "$ret"
1532 got tree -r $testroot/repo epsilon > $testroot/stdout
1533 echo "zeta" > $testroot/stdout.expected
1534 cmp -s $testroot/stdout.expected $testroot/stdout
1536 if [ $ret -ne 0 ]; then
1537 diff -u $testroot/stdout.expected $testroot/stdout
1539 test_done "$testroot" "$ret"
1542 test_histedit_fold_only() {
1543 local testroot=`test_init histedit_fold_only`
1545 local orig_commit=`git_show_head $testroot/repo`
1547 echo "modified alpha on master" > $testroot/repo/alpha
1548 (cd $testroot/repo && git rm -q beta)
1549 echo "new file on master" > $testroot/repo/epsilon/new
1550 (cd $testroot/repo && git add epsilon/new)
1551 git_commit $testroot/repo -m "committing changes"
1552 local old_commit1=`git_show_head $testroot/repo`
1554 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1555 git_commit $testroot/repo -m "committing to zeta on master"
1556 local old_commit2=`git_show_head $testroot/repo`
1558 echo "modified delta on master" > $testroot/repo/gamma/delta
1559 git_commit $testroot/repo -m "committing to delta on master"
1560 local old_commit3=`git_show_head $testroot/repo`
1562 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1564 if [ $ret -ne 0 ]; then
1565 test_done "$testroot" "$ret"
1569 cat > $testroot/editor.sh <<EOF
1572 [ "\$OSTYPE" = "linux-gnu" ] && SOPTS="-i"
1573 sed "\$SOPTS" -e 's/.*/committing folded changes/' "\$1"
1575 chmod +x $testroot/editor.sh
1577 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1578 VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1580 local new_commit1=`git_show_head $testroot/repo`
1582 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1583 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1584 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1585 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1586 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1588 echo "G alpha" > $testroot/stdout.expected
1589 echo "D beta" >> $testroot/stdout.expected
1590 echo "A epsilon/new" >> $testroot/stdout.expected
1591 echo "$short_old_commit1 -> fold commit: committing changes" \
1592 >> $testroot/stdout.expected
1593 echo "G epsilon/zeta" >> $testroot/stdout.expected
1594 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1595 echo "fold commit: committing to zeta on master" \
1596 >> $testroot/stdout.expected
1597 echo "G gamma/delta" >> $testroot/stdout.expected
1598 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1599 >> $testroot/stdout.expected
1600 echo "committing folded changes" >> $testroot/stdout.expected
1601 echo "Switching work tree to refs/heads/master" \
1602 >> $testroot/stdout.expected
1604 cmp -s $testroot/stdout.expected $testroot/stdout
1606 if [ $ret -ne 0 ]; then
1607 diff -u $testroot/stdout.expected $testroot/stdout
1608 test_done "$testroot" "$ret"
1612 echo "modified alpha on master" > $testroot/content.expected
1613 cat $testroot/wt/alpha > $testroot/content
1614 cmp -s $testroot/content.expected $testroot/content
1616 if [ $ret -ne 0 ]; then
1617 diff -u $testroot/content.expected $testroot/content
1618 test_done "$testroot" "$ret"
1622 if [ -e $testroot/wt/beta ]; then
1623 echo "removed file beta still exists on disk" >&2
1624 test_done "$testroot" "1"
1628 echo "new file on master" > $testroot/content.expected
1629 cat $testroot/wt/epsilon/new > $testroot/content
1630 cmp -s $testroot/content.expected $testroot/content
1632 if [ $ret -ne 0 ]; then
1633 diff -u $testroot/content.expected $testroot/content
1634 test_done "$testroot" "$ret"
1638 (cd $testroot/wt && got status > $testroot/stdout)
1640 echo -n > $testroot/stdout.expected
1641 cmp -s $testroot/stdout.expected $testroot/stdout
1643 if [ $ret -ne 0 ]; then
1644 diff -u $testroot/stdout.expected $testroot/stdout
1645 test_done "$testroot" "$ret"
1649 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1650 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1651 echo "commit $orig_commit" >> $testroot/stdout.expected
1652 cmp -s $testroot/stdout.expected $testroot/stdout
1654 if [ $ret -ne 0 ]; then
1655 diff -u $testroot/stdout.expected $testroot/stdout
1657 test_done "$testroot" "$ret"
1660 test_histedit_fold_only_empty_logmsg() {
1661 local testroot=`test_init histedit_fold_only_empty_logmsg`
1663 local orig_commit=`git_show_head $testroot/repo`
1665 echo "modified alpha on master" > $testroot/repo/alpha
1666 (cd $testroot/repo && git rm -q beta)
1667 echo "new file on master" > $testroot/repo/epsilon/new
1668 (cd $testroot/repo && git add epsilon/new)
1669 git_commit $testroot/repo -m "committing changes"
1670 local old_commit1=`git_show_head $testroot/repo`
1672 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1673 git_commit $testroot/repo -m "committing to zeta on master"
1674 local old_commit2=`git_show_head $testroot/repo`
1676 echo "modified delta on master" > $testroot/repo/gamma/delta
1677 git_commit $testroot/repo -m "committing to delta on master"
1678 local old_commit3=`git_show_head $testroot/repo`
1680 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1682 if [ $ret -ne 0 ]; then
1683 test_done "$testroot" "$ret"
1687 cat > $testroot/editor.sh <<EOF
1690 [ "\$OSTYPE" = "linux-gnu" ] && SOPTS="-i"
1691 sed "\$SOPTS" -e 'd' "\$1"
1693 chmod +x $testroot/editor.sh
1695 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1696 VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1698 local new_commit1=`git_show_head $testroot/repo`
1700 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1701 local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1702 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1703 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1704 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1705 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1707 echo "G alpha" > $testroot/stdout.expected
1708 echo "D beta" >> $testroot/stdout.expected
1709 echo "A epsilon/new" >> $testroot/stdout.expected
1710 echo "$short_old_commit1 -> fold commit: committing changes" \
1711 >> $testroot/stdout.expected
1712 echo "G epsilon/zeta" >> $testroot/stdout.expected
1713 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1714 echo "fold commit: committing to zeta on master" \
1715 >> $testroot/stdout.expected
1716 echo "G gamma/delta" >> $testroot/stdout.expected
1717 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1718 >> $testroot/stdout.expected
1719 echo "# log message of folded commit $very_short_old_commit1" \
1720 >> $testroot/stdout.expected
1721 echo "Switching work tree to refs/heads/master" \
1722 >> $testroot/stdout.expected
1724 cmp -s $testroot/stdout.expected $testroot/stdout
1726 if [ $ret -ne 0 ]; then
1727 diff -u $testroot/stdout.expected $testroot/stdout
1728 test_done "$testroot" "$ret"
1732 echo "modified alpha on master" > $testroot/content.expected
1733 cat $testroot/wt/alpha > $testroot/content
1734 cmp -s $testroot/content.expected $testroot/content
1736 if [ $ret -ne 0 ]; then
1737 diff -u $testroot/content.expected $testroot/content
1738 test_done "$testroot" "$ret"
1742 if [ -e $testroot/wt/beta ]; then
1743 echo "removed file beta still exists on disk" >&2
1744 test_done "$testroot" "1"
1748 echo "new file on master" > $testroot/content.expected
1749 cat $testroot/wt/epsilon/new > $testroot/content
1750 cmp -s $testroot/content.expected $testroot/content
1752 if [ $ret -ne 0 ]; then
1753 diff -u $testroot/content.expected $testroot/content
1754 test_done "$testroot" "$ret"
1758 (cd $testroot/wt && got status > $testroot/stdout)
1760 echo -n > $testroot/stdout.expected
1761 cmp -s $testroot/stdout.expected $testroot/stdout
1763 if [ $ret -ne 0 ]; then
1764 diff -u $testroot/stdout.expected $testroot/stdout
1765 test_done "$testroot" "$ret"
1769 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1770 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1771 echo "commit $orig_commit" >> $testroot/stdout.expected
1772 cmp -s $testroot/stdout.expected $testroot/stdout
1774 if [ $ret -ne 0 ]; then
1775 diff -u $testroot/stdout.expected $testroot/stdout
1777 test_done "$testroot" "$ret"
1780 test_histedit_edit_only() {
1781 local testroot=`test_init histedit_edit_only`
1783 local orig_commit=`git_show_head $testroot/repo`
1785 echo "modified alpha on master" > $testroot/repo/alpha
1786 (cd $testroot/repo && git rm -q beta)
1787 echo "new file on master" > $testroot/repo/epsilon/new
1788 (cd $testroot/repo && git add epsilon/new)
1789 git_commit $testroot/repo -m "committing changes"
1790 local old_commit1=`git_show_head $testroot/repo`
1792 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1793 git_commit $testroot/repo -m "committing to zeta on master"
1794 local old_commit2=`git_show_head $testroot/repo`
1796 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1798 if [ $ret -ne 0 ]; then
1799 test_done "$testroot" "$ret"
1803 (cd $testroot/wt && got histedit -e > $testroot/stdout)
1805 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1806 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1808 echo "G alpha" > $testroot/stdout.expected
1809 echo "D beta" >> $testroot/stdout.expected
1810 echo "A epsilon/new" >> $testroot/stdout.expected
1811 echo "Stopping histedit for amending commit $old_commit1" \
1812 >> $testroot/stdout.expected
1813 cmp -s $testroot/stdout.expected $testroot/stdout
1815 if [ $ret -ne 0 ]; then
1816 diff -u $testroot/stdout.expected $testroot/stdout
1817 test_done "$testroot" "$ret"
1821 echo "edited modified alpha on master" > $testroot/wt/alpha
1823 cat > $testroot/editor.sh <<EOF
1825 sed -i 's/.*/committing edited changes 1/' "\$1"
1827 chmod +x $testroot/editor.sh
1829 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1830 VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
1832 local new_commit1=$(cd $testroot/wt && got info | \
1833 grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1834 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1836 echo -n "$short_old_commit1 -> $short_new_commit1: " \
1837 > $testroot/stdout.expected
1838 echo "committing edited changes 1" >> $testroot/stdout.expected
1839 echo "G epsilon/zeta" >> $testroot/stdout.expected
1840 echo "Stopping histedit for amending commit $old_commit2" \
1841 >> $testroot/stdout.expected
1842 cmp -s $testroot/stdout.expected $testroot/stdout
1844 if [ $ret -ne 0 ]; then
1845 diff -u $testroot/stdout.expected $testroot/stdout
1846 test_done "$testroot" "$ret"
1850 echo "edited zeta on master" > $testroot/wt/epsilon/zeta
1852 cat > $testroot/editor.sh <<EOF
1854 sed -i 's/.*/committing edited changes 2/' "\$1"
1856 chmod +x $testroot/editor.sh
1858 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1859 VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
1861 local new_commit2=`git_show_head $testroot/repo`
1862 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1864 echo -n "$short_old_commit2 -> $short_new_commit2: " \
1865 > $testroot/stdout.expected
1866 echo "committing edited changes 2" >> $testroot/stdout.expected
1867 echo "Switching work tree to refs/heads/master" \
1868 >> $testroot/stdout.expected
1870 cmp -s $testroot/stdout.expected $testroot/stdout
1872 if [ $ret -ne 0 ]; then
1873 diff -u $testroot/stdout.expected $testroot/stdout
1874 test_done "$testroot" "$ret"
1878 echo "edited modified alpha on master" > $testroot/content.expected
1879 cat $testroot/wt/alpha > $testroot/content
1880 cmp -s $testroot/content.expected $testroot/content
1882 if [ $ret -ne 0 ]; then
1883 diff -u $testroot/content.expected $testroot/content
1884 test_done "$testroot" "$ret"
1888 if [ -e $testroot/wt/beta ]; then
1889 echo "removed file beta still exists on disk" >&2
1890 test_done "$testroot" "1"
1894 echo "new file on master" > $testroot/content.expected
1895 cat $testroot/wt/epsilon/new > $testroot/content
1896 cmp -s $testroot/content.expected $testroot/content
1898 if [ $ret -ne 0 ]; then
1899 diff -u $testroot/content.expected $testroot/content
1900 test_done "$testroot" "$ret"
1904 (cd $testroot/wt && got status > $testroot/stdout)
1906 echo -n > $testroot/stdout.expected
1907 cmp -s $testroot/stdout.expected $testroot/stdout
1909 if [ $ret -ne 0 ]; then
1910 diff -u $testroot/stdout.expected $testroot/stdout
1911 test_done "$testroot" "$ret"
1915 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1916 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
1917 echo "commit $new_commit1" >> $testroot/stdout.expected
1918 echo "commit $orig_commit" >> $testroot/stdout.expected
1919 cmp -s $testroot/stdout.expected $testroot/stdout
1921 if [ $ret -ne 0 ]; then
1922 diff -u $testroot/stdout.expected $testroot/stdout
1924 test_done "$testroot" "$ret"
1927 test_histedit_prepend_line() {
1928 local testroot=`test_init histedit_prepend_line`
1929 local orig_commit=`git_show_head $testroot/repo`
1931 got checkout $testroot/repo $testroot/wt > /dev/null
1933 ed "$testroot/wt/alpha" <<EOF >/dev/null 2>&1
1940 cp $testroot/wt/alpha $testroot/content.expected
1942 (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
1945 if [ "$?" != 0 ]; then
1946 echo "got commit failed unexpectedly" >&2
1947 test_done "$testroot" "$ret"
1951 local top_commit=`git_show_head $testroot/repo`
1952 echo "pick $top_commit" > "$testroot/histedit-script"
1954 (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
1956 if [ "$?" != 0 ]; then
1957 echo "got update failed unexpectedly" >&2
1958 test_done "$testroot" "$ret"
1962 (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
1965 if [ "$?" != 0 ]; then
1966 echo "got histedit failed unexpectedly" >&2
1967 test_done "$testroot" "$ret"
1971 cp $testroot/wt/alpha $testroot/content
1972 cmp -s $testroot/content.expected $testroot/content
1974 if [ $ret -ne 0 ]; then
1975 diff -u $testroot/content.expected $testroot/content
1976 test_done "$testroot" "$ret"
1980 test_done "$testroot" $ret
1983 test_histedit_mesg_invalid() {
1984 local testroot=`test_init mesg_invalid`
1986 local orig_commit=`git_show_head $testroot/repo`
1988 echo "modified alpha on master" > $testroot/repo/alpha
1989 (cd $testroot/repo && git rm -q beta)
1990 echo "new file on master" > $testroot/repo/epsilon/new
1991 (cd $testroot/repo && git add epsilon/new)
1992 git_commit $testroot/repo -m 'committing changes'
1993 local old_commit1=`git_show_head $testroot/repo`
1995 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1996 git_commit $testroot/repo -m 'committing to zeto on master'
1997 local old_commit2=`git_show_head $testroot/repo`
1999 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2001 if [ $ret -ne 0 ]; then
2002 test_done "$testroot" $ret
2006 # try with a leading mesg
2008 echo "mesg something something" > $testroot/histedit-script
2009 echo "pick $old_commit1" >> $testroot/histedit-script
2010 echo "pick $old_commit2" >> $testroot/histedit-script
2012 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2013 > $testroot/stdout 2> $testroot/stderr)
2015 if [ $ret -eq 0 ]; then
2016 echo "histedit succeeded unexpectedly" >&2
2017 test_done "$testroot" 1
2021 echo "got: bad histedit command" > $testroot/stderr.expected
2022 cmp -s $testroot/stderr.expected $testroot/stderr
2024 if [ $ret -ne 0 ]; then
2025 diff -u $testroot/stderr.expected $testroot/stderr
2026 test_done "$testroot" $ret
2030 # try again with mesg -> mesg
2032 echo "pick $old_commit1" > $testroot/histedit-script
2033 echo "mesg something something" >> $testroot/histedit-script
2034 echo "mesg something something else" >> $testroot/histedit-script
2035 echo "pick $old_commit2" >> $testroot/histedit-script
2037 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2038 > $testroot/stdout 2> $testroot/stderr)
2040 if [ $ret -eq 0 ]; then
2041 echo "histedit succeeded unexpectedly" >&2
2042 test_done "$testroot" 1
2046 echo "got: bad histedit command" > $testroot/stderr.expected
2047 cmp -s $testroot/stderr.expected $testroot/stderr
2049 if [ $ret -ne 0 ]; then
2050 diff -u $testroot/stderr.expected $testroot/stderr
2051 test_done "$testroot" $ret
2055 # try again with drop -> mesg
2057 echo "drop $old_commit1" > $testroot/histedit-script
2058 echo "mesg something something" >> $testroot/histedit-script
2059 echo "pick $old_commit2" >> $testroot/histedit-script
2061 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2062 > $testroot/stdout 2> $testroot/stderr)
2064 if [ $ret -eq 0 ]; then
2065 echo "histedit succeeded unexpectedly" >&2
2066 test_done "$testroot" 1
2070 echo "got: bad histedit command" > $testroot/stderr.expected
2071 cmp -s $testroot/stderr.expected $testroot/stderr
2073 if [ $ret -ne 0 ]; then
2074 diff -u $testroot/stderr.expected $testroot/stderr
2075 test_done "$testroot" $ret
2079 # try again with fold -> mesg
2081 echo "fold $old_commit1" > $testroot/histedit-script
2082 echo "mesg something something" >> $testroot/histedit-script
2083 echo "pick $old_commit2" >> $testroot/histedit-script
2085 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2086 > $testroot/stdout 2> $testroot/stderr)
2088 if [ $ret -eq 0 ]; then
2089 echo "histedit succeeded unexpectedly" >&2
2090 test_done "$testroot" 1
2094 echo "got: bad histedit command" > $testroot/stderr.expected
2095 cmp -s $testroot/stderr.expected $testroot/stderr
2097 if [ $ret -ne 0 ]; then
2098 diff -u $testroot/stderr.expected $testroot/stderr
2100 test_done "$testroot" $ret
2104 run_test test_histedit_no_op
2105 run_test test_histedit_swap
2106 run_test test_histedit_drop
2107 run_test test_histedit_fold
2108 run_test test_histedit_edit
2109 run_test test_histedit_fold_last_commit
2110 run_test test_histedit_missing_commit
2111 run_test test_histedit_abort
2112 run_test test_histedit_path_prefix_drop
2113 run_test test_histedit_path_prefix_edit
2114 run_test test_histedit_outside_refs_heads
2115 run_test test_histedit_fold_last_commit_swap
2116 run_test test_histedit_split_commit
2117 run_test test_histedit_duplicate_commit_in_script
2118 run_test test_histedit_fold_add_delete
2119 run_test test_histedit_fold_only
2120 run_test test_histedit_fold_only_empty_logmsg
2121 run_test test_histedit_edit_only
2122 run_test test_histedit_prepend_line
2123 run_test test_histedit_mesg_invalid