Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 #
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.
8 #
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.
17 . ./common.sh
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 git -C $testroot/repo rm -q beta
27 echo "new file on master" > $testroot/repo/epsilon/new
28 git -C $testroot/repo 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
42 ret=$?
43 if [ $ret -ne 0 ]; then
44 test_done "$testroot" "$ret"
45 return 1
46 fi
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 \
52 > $testroot/stdout)
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
76 ret=$?
77 if [ $ret -ne 0 ]; then
78 diff -u $testroot/stdout.expected $testroot/stdout
79 test_done "$testroot" "$ret"
80 return 1
81 fi
83 echo "modified alpha on master" > $testroot/content.expected
84 cat $testroot/wt/alpha > $testroot/content
85 cmp -s $testroot/content.expected $testroot/content
86 ret=$?
87 if [ $ret -ne 0 ]; then
88 diff -u $testroot/content.expected $testroot/content
89 test_done "$testroot" "$ret"
90 return 1
91 fi
93 if [ -e $testroot/wt/beta ]; then
94 echo "removed file beta still exists on disk" >&2
95 test_done "$testroot" "1"
96 return 1
97 fi
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
102 ret=$?
103 if [ $ret -ne 0 ]; then
104 diff -u $testroot/content.expected $testroot/content
105 test_done "$testroot" "$ret"
106 return 1
107 fi
109 (cd $testroot/wt && got status > $testroot/stdout)
111 echo -n > $testroot/stdout.expected
112 cmp -s $testroot/stdout.expected $testroot/stdout
113 ret=$?
114 if [ $ret -ne 0 ]; then
115 diff -u $testroot/stdout.expected $testroot/stdout
116 test_done "$testroot" "$ret"
117 return 1
118 fi
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
125 ret=$?
126 if [ $ret -ne 0 ]; then
127 diff -u $testroot/stdout.expected $testroot/stdout
128 test_done "$testroot" "$ret"
129 return 1
130 fi
132 got diff -r $testroot/repo $orig_commit $new_commit2 \
133 > $testroot/diff
134 ed -s $testroot/diff.expected <<-EOF
135 ,s/$old_commit2/$new_commit2/
137 EOF
138 cmp -s $testroot/diff.expected $testroot/diff
139 ret=$?
140 if [ $ret -ne 0 ]; then
141 diff -u $testroot/diff.expected $testroot/diff
142 test_done "$testroot" "$ret"
143 return 1
144 fi
146 (cd $testroot/wt && got update > $testroot/stdout)
148 echo 'Already up-to-date' > $testroot/stdout.expected
149 cmp -s $testroot/stdout.expected $testroot/stdout
150 ret=$?
151 if [ $ret -ne 0 ]; then
152 diff -u $testroot/stdout.expected $testroot/stdout
153 test_done "$testroot" "$ret"
154 return 1
155 fi
157 # We should have a backup of old commits
158 (cd $testroot/repo && got histedit -l > $testroot/stdout)
159 d_orig1=`date -u -r $old_author_time1 +"%F"`
160 d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"`
161 d_new2=`date -u -r $new_author_time2 +"%F"`
162 d_orig=`date -u -r $orig_author_time +"%F"`
163 cat > $testroot/stdout.expected <<EOF
164 -----------------------------------------------
165 commit $old_commit2 (formerly master)
166 from: $GOT_AUTHOR
167 date: $d_orig2
169 committing to zeta on master
171 has become commit $new_commit2 (master)
172 $d_new2 $GOT_AUTHOR_11 committing to zeta on master
173 EOF
175 local is_forked=true d_fork fork_commit fork_commit_msg
177 if [ "$old_commit1" = "$new_commit1" ]; then
178 if [ "$old_commit2" = "$new_commit2" ]; then
179 is_forked=false
180 else
181 d_fork=$d_orig1
182 fork_commit=$new_commit1
183 fork_commit_msg="committing changes"
184 fi
185 else
186 d_fork=$d_orig
187 fork_commit=$orig_commit
188 fork_commit_msg="adding the test tree"
189 fi
191 $is_forked && cat >> $testroot/stdout.expected <<EOF
192 history forked at $fork_commit
193 $d_fork $GOT_AUTHOR_11 $fork_commit_msg
194 EOF
196 cmp -s $testroot/stdout.expected $testroot/stdout
197 ret=$?
198 if [ $ret -ne 0 ]; then
199 diff -u $testroot/stdout.expected $testroot/stdout
200 test_done "$testroot" "$ret"
201 return 1
202 fi
204 (cd $testroot/repo && got histedit -X master \
205 > $testroot/stdout 2> $testroot/stderr)
206 echo -n "Deleted refs/got/backup/histedit/master/$new_commit2: " \
207 > $testroot/stdout.expected
208 echo "$old_commit2" >> $testroot/stdout.expected
209 echo -n > $testroot/stderr.expected
210 cmp -s $testroot/stdout.expected $testroot/stdout
211 ret=$?
212 if [ $ret -ne 0 ]; then
213 diff -u $testroot/stdout.expected $testroot/stdout
214 test_done "$testroot" "$ret"
215 return 1
216 fi
217 cmp -s $testroot/stderr.expected $testroot/stderr
218 ret=$?
219 if [ $ret -ne 0 ]; then
220 diff -u $testroot/stderr.expected $testroot/stderr
221 test_done "$testroot" "$ret"
222 return 1
223 fi
225 (cd $testroot/repo && got histedit -l > $testroot/stdout)
226 echo -n > $testroot/stdout.expected
227 cmp -s $testroot/stdout.expected $testroot/stdout
228 ret=$?
229 if [ $ret -ne 0 ]; then
230 diff -u $testroot/stdout.expected $testroot/stdout
231 fi
232 test_done "$testroot" "$ret"
235 test_histedit_swap() {
236 local testroot=`test_init histedit_swap`
238 local orig_commit=`git_show_head $testroot/repo`
240 echo "modified alpha on master" > $testroot/repo/alpha
241 git -C $testroot/repo rm -q beta
242 echo "new file on master" > $testroot/repo/epsilon/new
243 git -C $testroot/repo add epsilon/new
244 git_commit $testroot/repo -m "committing changes"
245 local old_commit1=`git_show_head $testroot/repo`
247 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
248 git_commit $testroot/repo -m "committing to zeta on master"
249 local old_commit2=`git_show_head $testroot/repo`
251 got diff -r $testroot/repo $orig_commit $old_commit2 \
252 > $testroot/diff.expected
254 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
255 ret=$?
256 if [ $ret -ne 0 ]; then
257 test_done "$testroot" "$ret"
258 return 1
259 fi
261 echo "pick $old_commit2" > $testroot/histedit-script
262 echo "pick $old_commit1" >> $testroot/histedit-script
264 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
265 > $testroot/stdout)
267 local new_commit2=`git_show_parent_commit $testroot/repo`
268 local new_commit1=`git_show_head $testroot/repo`
270 local short_old_commit1=`trim_obj_id 28 $old_commit1`
271 local short_old_commit2=`trim_obj_id 28 $old_commit2`
272 local short_new_commit1=`trim_obj_id 28 $new_commit1`
273 local short_new_commit2=`trim_obj_id 28 $new_commit2`
275 echo "G epsilon/zeta" > $testroot/stdout.expected
276 echo -n "$short_old_commit2 -> $short_new_commit2: " \
277 >> $testroot/stdout.expected
278 echo "committing to zeta on master" >> $testroot/stdout.expected
279 echo "G alpha" >> $testroot/stdout.expected
280 echo "D beta" >> $testroot/stdout.expected
281 echo "A epsilon/new" >> $testroot/stdout.expected
282 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
283 >> $testroot/stdout.expected
284 echo "Switching work tree to refs/heads/master" \
285 >> $testroot/stdout.expected
287 cmp -s $testroot/stdout.expected $testroot/stdout
288 ret=$?
289 if [ $ret -ne 0 ]; then
290 diff -u $testroot/stdout.expected $testroot/stdout
291 test_done "$testroot" "$ret"
292 return 1
293 fi
295 echo "modified alpha on master" > $testroot/content.expected
296 cat $testroot/wt/alpha > $testroot/content
297 cmp -s $testroot/content.expected $testroot/content
298 ret=$?
299 if [ $ret -ne 0 ]; then
300 diff -u $testroot/content.expected $testroot/content
301 test_done "$testroot" "$ret"
302 return 1
303 fi
305 if [ -e $testroot/wt/beta ]; then
306 echo "removed file beta still exists on disk" >&2
307 test_done "$testroot" "1"
308 return 1
309 fi
311 echo "new file on master" > $testroot/content.expected
312 cat $testroot/wt/epsilon/new > $testroot/content
313 cmp -s $testroot/content.expected $testroot/content
314 ret=$?
315 if [ $ret -ne 0 ]; then
316 diff -u $testroot/content.expected $testroot/content
317 test_done "$testroot" "$ret"
318 return 1
319 fi
321 (cd $testroot/wt && got status > $testroot/stdout)
323 echo -n > $testroot/stdout.expected
324 cmp -s $testroot/stdout.expected $testroot/stdout
325 ret=$?
326 if [ $ret -ne 0 ]; then
327 diff -u $testroot/stdout.expected $testroot/stdout
328 test_done "$testroot" "$ret"
329 return 1
330 fi
332 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
333 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
334 echo "commit $new_commit2" >> $testroot/stdout.expected
335 echo "commit $orig_commit" >> $testroot/stdout.expected
336 cmp -s $testroot/stdout.expected $testroot/stdout
337 ret=$?
338 if [ $ret -ne 0 ]; then
339 diff -u $testroot/stdout.expected $testroot/stdout
340 test_done "$testroot" "$ret"
341 return 1
342 fi
344 got diff -r $testroot/repo $orig_commit $new_commit1 \
345 > $testroot/diff
346 ed -s $testroot/diff.expected <<-EOF
347 ,s/$old_commit2/$new_commit1/
349 EOF
350 cmp -s $testroot/diff.expected $testroot/diff
351 ret=$?
352 if [ $ret -ne 0 ]; then
353 diff -u $testroot/diff.expected $testroot/diff
354 fi
355 test_done "$testroot" "$ret"
358 test_histedit_drop() {
359 local testroot=`test_init histedit_drop`
360 local orig_commit=`git_show_head $testroot/repo`
362 echo "modified alpha on master" > $testroot/repo/alpha
363 git -C $testroot/repo rm -q beta
364 echo "new file on master" > $testroot/repo/epsilon/new
365 git -C $testroot/repo add epsilon/new
366 git_commit $testroot/repo -m "committing changes"
367 local old_commit1=`git_show_head $testroot/repo`
369 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
370 git_commit $testroot/repo -m "committing to zeta on master"
371 local old_commit2=`git_show_head $testroot/repo`
373 got diff -r $testroot/repo $old_commit1 $old_commit2 \
374 > $testroot/diff.expected
376 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
377 ret=$?
378 if [ $ret -ne 0 ]; then
379 test_done "$testroot" "$ret"
380 return 1
381 fi
383 echo "drop $old_commit1" > $testroot/histedit-script
384 echo "pick $old_commit2" >> $testroot/histedit-script
386 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
387 > $testroot/stdout)
389 local new_commit2=`git_show_head $testroot/repo`
391 local short_old_commit1=`trim_obj_id 28 $old_commit1`
392 local short_old_commit2=`trim_obj_id 28 $old_commit2`
393 local short_new_commit2=`trim_obj_id 28 $new_commit2`
395 echo "$short_old_commit1 -> drop commit: committing changes" \
396 > $testroot/stdout.expected
397 echo "G epsilon/zeta" >> $testroot/stdout.expected
398 echo -n "$short_old_commit2 -> $short_new_commit2: " \
399 >> $testroot/stdout.expected
400 echo "committing to zeta on master" >> $testroot/stdout.expected
401 echo "Switching work tree to refs/heads/master" \
402 >> $testroot/stdout.expected
404 cmp -s $testroot/stdout.expected $testroot/stdout
405 ret=$?
406 if [ $ret -ne 0 ]; then
407 diff -u $testroot/stdout.expected $testroot/stdout
408 test_done "$testroot" "$ret"
409 return 1
410 fi
412 for f in alpha beta; do
413 echo "$f" > $testroot/content.expected
414 cat $testroot/wt/$f > $testroot/content
415 cmp -s $testroot/content.expected $testroot/content
416 ret=$?
417 if [ $ret -ne 0 ]; then
418 diff -u $testroot/content.expected $testroot/content
419 test_done "$testroot" "$ret"
420 return 1
421 fi
422 done
424 if [ -e $testroot/wt/new ]; then
425 echo "file new exists on disk but should not" >&2
426 test_done "$testroot" "1"
427 return 1
428 fi
430 (cd $testroot/wt && got status > $testroot/stdout)
432 echo -n > $testroot/stdout.expected
433 cmp -s $testroot/stdout.expected $testroot/stdout
434 ret=$?
435 if [ $ret -ne 0 ]; then
436 diff -u $testroot/stdout.expected $testroot/stdout
437 test_done "$testroot" "$ret"
438 return 1
439 fi
441 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
442 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
443 echo "commit $orig_commit" >> $testroot/stdout.expected
444 cmp -s $testroot/stdout.expected $testroot/stdout
445 ret=$?
446 if [ $ret -ne 0 ]; then
447 diff -u $testroot/stdout.expected $testroot/stdout
448 test_done "$testroot" "$ret"
449 return 1
450 fi
452 got diff -r $testroot/repo $orig_commit $new_commit2 \
453 > $testroot/diff
454 ed -s $testroot/diff.expected <<-EOF
455 ,s/$old_commit1/$orig_commit/
456 ,s/$old_commit2/$new_commit2/
458 EOF
459 cmp -s $testroot/diff.expected $testroot/diff
460 ret=$?
461 if [ $ret -ne 0 ]; then
462 diff -u $testroot/diff.expected $testroot/diff
463 fi
464 test_done "$testroot" "$ret"
467 test_histedit_fold() {
468 local testroot=`test_init histedit_fold`
470 local orig_commit=`git_show_head $testroot/repo`
472 echo "modified alpha on master" > $testroot/repo/alpha
473 git -C $testroot/repo rm -q beta
474 echo "new file on master" > $testroot/repo/epsilon/new
475 git -C $testroot/repo add epsilon/new
476 git_commit $testroot/repo -m "committing changes"
477 local old_commit1=`git_show_head $testroot/repo`
479 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
480 git_commit $testroot/repo -m "committing to zeta on master"
481 local old_commit2=`git_show_head $testroot/repo`
483 echo "modified delta on master" > $testroot/repo/gamma/delta
484 git_commit $testroot/repo -m "committing to delta on master"
485 local old_commit3=`git_show_head $testroot/repo`
487 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
488 ret=$?
489 if [ $ret -ne 0 ]; then
490 test_done "$testroot" "$ret"
491 return 1
492 fi
494 cat > $testroot/editor.sh <<EOF
495 #!/bin/sh
496 ed -s "\$1" <<-EOF
497 ,s/.*/committing folded changes/
499 EOF
500 EOF
501 chmod +x $testroot/editor.sh
503 echo "fold $old_commit1" > $testroot/histedit-script
504 echo "drop $old_commit2" >> $testroot/histedit-script
505 echo "pick $old_commit3" >> $testroot/histedit-script
507 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
508 VISUAL="$testroot/editor.sh" \
509 got histedit -F $testroot/histedit-script > $testroot/stdout)
511 local new_commit1=`git_show_parent_commit $testroot/repo`
512 local new_commit2=`git_show_head $testroot/repo`
514 local short_old_commit1=`trim_obj_id 28 $old_commit1`
515 local short_old_commit2=`trim_obj_id 28 $old_commit2`
516 local short_old_commit3=`trim_obj_id 28 $old_commit3`
517 local short_new_commit1=`trim_obj_id 28 $new_commit1`
518 local short_new_commit2=`trim_obj_id 28 $new_commit2`
520 echo "G alpha" > $testroot/stdout.expected
521 echo "D beta" >> $testroot/stdout.expected
522 echo "A epsilon/new" >> $testroot/stdout.expected
523 echo "$short_old_commit1 -> fold commit: committing changes" \
524 >> $testroot/stdout.expected
525 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
526 echo "drop commit: committing to zeta on master" \
527 >> $testroot/stdout.expected
528 echo "G gamma/delta" >> $testroot/stdout.expected
529 echo -n "$short_old_commit3 -> $short_new_commit2: " \
530 >> $testroot/stdout.expected
531 echo "committing folded changes" >> $testroot/stdout.expected
532 echo "Switching work tree to refs/heads/master" \
533 >> $testroot/stdout.expected
535 cmp -s $testroot/stdout.expected $testroot/stdout
536 ret=$?
537 if [ $ret -ne 0 ]; then
538 diff -u $testroot/stdout.expected $testroot/stdout
539 test_done "$testroot" "$ret"
540 return 1
541 fi
543 echo "modified alpha on master" > $testroot/content.expected
544 cat $testroot/wt/alpha > $testroot/content
545 cmp -s $testroot/content.expected $testroot/content
546 ret=$?
547 if [ $ret -ne 0 ]; then
548 diff -u $testroot/content.expected $testroot/content
549 test_done "$testroot" "$ret"
550 return 1
551 fi
553 if [ -e $testroot/wt/beta ]; then
554 echo "removed file beta still exists on disk" >&2
555 test_done "$testroot" "1"
556 return 1
557 fi
559 echo "new file on master" > $testroot/content.expected
560 cat $testroot/wt/epsilon/new > $testroot/content
561 cmp -s $testroot/content.expected $testroot/content
562 ret=$?
563 if [ $ret -ne 0 ]; then
564 diff -u $testroot/content.expected $testroot/content
565 test_done "$testroot" "$ret"
566 return 1
567 fi
569 (cd $testroot/wt && got status > $testroot/stdout)
571 echo -n > $testroot/stdout.expected
572 cmp -s $testroot/stdout.expected $testroot/stdout
573 ret=$?
574 if [ $ret -ne 0 ]; then
575 diff -u $testroot/stdout.expected $testroot/stdout
576 test_done "$testroot" "$ret"
577 return 1
578 fi
580 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
581 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
582 echo "commit $orig_commit" >> $testroot/stdout.expected
583 cmp -s $testroot/stdout.expected $testroot/stdout
584 ret=$?
585 if [ $ret -ne 0 ]; then
586 diff -u $testroot/stdout.expected $testroot/stdout
587 fi
588 test_done "$testroot" "$ret"
591 test_histedit_edit() {
592 local testroot=`test_init histedit_edit`
594 local orig_commit=`git_show_head $testroot/repo`
596 echo "modified alpha on master" > $testroot/repo/alpha
597 git -C $testroot/repo rm -q beta
598 echo "new file on master" > $testroot/repo/epsilon/new
599 git -C $testroot/repo add epsilon/new
600 git_commit $testroot/repo -m "committing changes"
601 local old_commit1=`git_show_head $testroot/repo`
603 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
604 git_commit $testroot/repo -m "committing to zeta on master"
605 local old_commit2=`git_show_head $testroot/repo`
607 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
608 ret=$?
609 if [ $ret -ne 0 ]; then
610 test_done "$testroot" "$ret"
611 return 1
612 fi
614 echo "edit $old_commit1" > $testroot/histedit-script
615 echo "pick $old_commit2" >> $testroot/histedit-script
617 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
618 > $testroot/stdout)
620 local short_old_commit1=`trim_obj_id 28 $old_commit1`
621 local short_old_commit2=`trim_obj_id 28 $old_commit2`
623 echo "G alpha" > $testroot/stdout.expected
624 echo "D beta" >> $testroot/stdout.expected
625 echo "A epsilon/new" >> $testroot/stdout.expected
626 echo "Stopping histedit for amending commit $old_commit1" \
627 >> $testroot/stdout.expected
628 cmp -s $testroot/stdout.expected $testroot/stdout
629 ret=$?
630 if [ $ret -ne 0 ]; then
631 diff -u $testroot/stdout.expected $testroot/stdout
632 test_done "$testroot" "$ret"
633 return 1
634 fi
636 echo "edited modified alpha on master" > $testroot/wt/alpha
638 # test interaction of 'got stage' and histedit -c
639 (cd $testroot/wt && got stage alpha > /dev/null)
640 (cd $testroot/wt && got histedit -c > $testroot/stdout \
641 2> $testroot/stderr)
642 ret=$?
643 if [ $ret -eq 0 ]; then
644 echo "histedit succeeded unexpectedly" >&2
645 test_done "$testroot" "1"
646 return 1
647 fi
648 echo -n "got: work tree contains files with staged changes; " \
649 > $testroot/stderr.expected
650 echo "these changes must be committed or unstaged first" \
651 >> $testroot/stderr.expected
652 cmp -s $testroot/stderr.expected $testroot/stderr
653 ret=$?
654 if [ $ret -ne 0 ]; then
655 diff -u $testroot/stderr.expected $testroot/stderr
656 test_done "$testroot" "$ret"
657 return 1
658 fi
660 (cd $testroot/wt && got unstage alpha > /dev/null)
662 cat > $testroot/editor.sh <<EOF
663 #!/bin/sh
664 ed -s "\$1" <<-EOF
665 ,s/.*/committing changes/
667 EOF
668 EOF
669 chmod +x $testroot/editor.sh
671 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
672 VISUAL="$testroot/editor.sh" \
673 got histedit -c > $testroot/stdout)
675 local new_commit1=`git_show_parent_commit $testroot/repo`
676 local new_commit2=`git_show_head $testroot/repo`
678 local short_new_commit1=`trim_obj_id 28 $new_commit1`
679 local short_new_commit2=`trim_obj_id 28 $new_commit2`
681 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
682 > $testroot/stdout.expected
683 echo "G epsilon/zeta" >> $testroot/stdout.expected
684 echo -n "$short_old_commit2 -> $short_new_commit2: " \
685 >> $testroot/stdout.expected
686 echo "committing to zeta on master" >> $testroot/stdout.expected
687 echo "Switching work tree to refs/heads/master" \
688 >> $testroot/stdout.expected
690 cmp -s $testroot/stdout.expected $testroot/stdout
691 ret=$?
692 if [ $ret -ne 0 ]; then
693 diff -u $testroot/stdout.expected $testroot/stdout
694 test_done "$testroot" "$ret"
695 return 1
696 fi
698 echo "edited modified alpha on master" > $testroot/content.expected
699 cat $testroot/wt/alpha > $testroot/content
700 cmp -s $testroot/content.expected $testroot/content
701 ret=$?
702 if [ $ret -ne 0 ]; then
703 diff -u $testroot/content.expected $testroot/content
704 test_done "$testroot" "$ret"
705 return 1
706 fi
708 if [ -e $testroot/wt/beta ]; then
709 echo "removed file beta still exists on disk" >&2
710 test_done "$testroot" "1"
711 return 1
712 fi
714 echo "new file on master" > $testroot/content.expected
715 cat $testroot/wt/epsilon/new > $testroot/content
716 cmp -s $testroot/content.expected $testroot/content
717 ret=$?
718 if [ $ret -ne 0 ]; then
719 diff -u $testroot/content.expected $testroot/content
720 test_done "$testroot" "$ret"
721 return 1
722 fi
724 (cd $testroot/wt && got status > $testroot/stdout)
726 echo -n > $testroot/stdout.expected
727 cmp -s $testroot/stdout.expected $testroot/stdout
728 ret=$?
729 if [ $ret -ne 0 ]; then
730 diff -u $testroot/stdout.expected $testroot/stdout
731 test_done "$testroot" "$ret"
732 return 1
733 fi
735 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
736 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
737 echo "commit $new_commit1" >> $testroot/stdout.expected
738 echo "commit $orig_commit" >> $testroot/stdout.expected
739 cmp -s $testroot/stdout.expected $testroot/stdout
740 ret=$?
741 if [ $ret -ne 0 ]; then
742 diff -u $testroot/stdout.expected $testroot/stdout
743 fi
744 test_done "$testroot" "$ret"
747 test_histedit_fold_last_commit() {
748 local testroot=`test_init histedit_fold_last_commit`
750 local orig_commit=`git_show_head $testroot/repo`
752 echo "modified alpha on master" > $testroot/repo/alpha
753 git -C $testroot/repo rm -q beta
754 echo "new file on master" > $testroot/repo/epsilon/new
755 git -C $testroot/repo add epsilon/new
756 git_commit $testroot/repo -m "committing changes"
757 local old_commit1=`git_show_head $testroot/repo`
759 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
760 git_commit $testroot/repo -m "committing to zeta on master"
761 local old_commit2=`git_show_head $testroot/repo`
763 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
764 ret=$?
765 if [ $ret -ne 0 ]; then
766 test_done "$testroot" "$ret"
767 return 1
768 fi
770 echo "pick $old_commit1" > $testroot/histedit-script
771 echo "fold $old_commit2" >> $testroot/histedit-script
773 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
774 > $testroot/stdout 2> $testroot/stderr)
776 ret=$?
777 if [ $ret -eq 0 ]; then
778 echo "histedit succeeded unexpectedly" >&2
779 test_done "$testroot" "1"
780 return 1
781 fi
783 echo "got: last commit in histedit script cannot be folded" \
784 > $testroot/stderr.expected
786 cmp -s $testroot/stderr.expected $testroot/stderr
787 ret=$?
788 if [ $ret -ne 0 ]; then
789 diff -u $testroot/stderr.expected $testroot/stderr
790 fi
791 test_done "$testroot" "$ret"
794 test_histedit_missing_commit_pick() {
795 local testroot=`test_init histedit_missing_commit`
797 local orig_commit=`git_show_head $testroot/repo`
799 echo "modified alpha on master" > $testroot/repo/alpha
800 git -C $testroot/repo rm -q beta
801 echo "new file on master" > $testroot/repo/epsilon/new
802 git -C $testroot/repo add epsilon/new
803 git_commit $testroot/repo -m "committing changes"
804 local old_commit1=`git_show_head $testroot/repo`
806 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
807 git_commit $testroot/repo -m "committing to zeta on master"
808 local old_commit2=`git_show_head $testroot/repo`
810 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
811 ret=$?
812 if [ $ret -ne 0 ]; then
813 test_done "$testroot" "$ret"
814 return 1
815 fi
817 echo "pick $old_commit1" > $testroot/histedit-script
819 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
820 > $testroot/stdout 2> $testroot/stderr)
822 ret=$?
823 if [ $ret -eq 0 ]; then
824 echo "histedit succeeded unexpectedly" >&2
825 test_done "$testroot" "1"
826 return 1
827 fi
829 echo "got: commit $old_commit2 missing from histedit script" \
830 > $testroot/stderr.expected
832 cmp -s $testroot/stderr.expected $testroot/stderr
833 ret=$?
834 if [ $ret -ne 0 ]; then
835 diff -u $testroot/stderr.expected $testroot/stderr
836 fi
837 test_done "$testroot" "$ret"
840 test_histedit_missing_commit_mesg() {
841 local testroot=`test_init histedit_missing_commit`
843 local orig_commit=`git_show_head $testroot/repo`
845 echo "modified alpha on master" > $testroot/repo/alpha
846 git -C $testroot/repo rm -q beta
847 echo "new file on master" > $testroot/repo/epsilon/new
848 git -C $testroot/repo add epsilon/new
849 git_commit $testroot/repo -m "committing changes"
850 local old_commit1=`git_show_head $testroot/repo`
852 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
853 git_commit $testroot/repo -m "committing to zeta on master"
854 local old_commit2=`git_show_head $testroot/repo`
856 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
857 ret=$?
858 if [ $ret -ne 0 ]; then
859 test_done "$testroot" "$ret"
860 return 1
861 fi
863 cat > $testroot/editor.sh <<EOF
864 #!/bin/sh
865 ed -s "\$1" <<-EOF
866 ,s/.*/committing folded changes/
868 EOF
869 EOF
870 chmod +x $testroot/editor.sh
872 echo "mesg $old_commit1" > $testroot/histedit-script
874 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
875 VISUAL="$testroot/editor.sh" \
876 got histedit -F $testroot/histedit-script > $testroot/stdout \
877 2>$testroot/stderr)
879 ret=$?
880 if [ $ret -eq 0 ]; then
881 echo "histedit succeeded unexpectedly" >&2
882 test_done "$testroot" "1"
883 return 1
884 fi
886 echo "got: commit $old_commit2 missing from histedit script" \
887 > $testroot/stderr.expected
889 cmp -s $testroot/stderr.expected $testroot/stderr
890 ret=$?
891 if [ $ret -ne 0 ]; then
892 diff -u $testroot/stderr.expected $testroot/stderr
893 fi
894 test_done "$testroot" "$ret"
897 test_histedit_abort() {
898 local testroot=`test_init histedit_abort`
900 local orig_commit=`git_show_head $testroot/repo`
902 echo "modified alpha on master" > $testroot/repo/alpha
903 git -C $testroot/repo rm -q beta
904 echo "new file on master" > $testroot/repo/epsilon/new
905 git -C $testroot/repo add epsilon/new
906 git_commit $testroot/repo -m "committing changes"
907 local old_commit1=`git_show_head $testroot/repo`
909 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
910 git_commit $testroot/repo -m "committing to zeta on master"
911 local old_commit2=`git_show_head $testroot/repo`
913 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
914 ret=$?
915 if [ $ret -ne 0 ]; then
916 test_done "$testroot" "$ret"
917 return 1
918 fi
920 # unrelated unversioned file in work tree
921 touch $testroot/wt/unversioned-file
923 echo "edit $old_commit1" > $testroot/histedit-script
924 echo "pick $old_commit2" >> $testroot/histedit-script
926 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
927 > $testroot/stdout)
929 local short_old_commit1=`trim_obj_id 28 $old_commit1`
930 local short_old_commit2=`trim_obj_id 28 $old_commit2`
932 echo "G alpha" > $testroot/stdout.expected
933 echo "D beta" >> $testroot/stdout.expected
934 echo "A epsilon/new" >> $testroot/stdout.expected
935 echo "Stopping histedit for amending commit $old_commit1" \
936 >> $testroot/stdout.expected
937 cmp -s $testroot/stdout.expected $testroot/stdout
938 ret=$?
939 if [ $ret -ne 0 ]; then
940 diff -u $testroot/stdout.expected $testroot/stdout
941 test_done "$testroot" "$ret"
942 return 1
943 fi
945 echo "edited modified alpha on master" > $testroot/wt/alpha
947 (cd $testroot/wt && got histedit -a > $testroot/stdout)
949 local new_commit1=`git_show_parent_commit $testroot/repo`
950 local new_commit2=`git_show_head $testroot/repo`
952 echo "Switching work tree to refs/heads/master" \
953 > $testroot/stdout.expected
954 echo "R alpha" >> $testroot/stdout.expected
955 echo "R beta" >> $testroot/stdout.expected
956 echo "R epsilon/new" >> $testroot/stdout.expected
957 echo "Histedit of refs/heads/master aborted" \
958 >> $testroot/stdout.expected
960 cmp -s $testroot/stdout.expected $testroot/stdout
961 ret=$?
962 if [ $ret -ne 0 ]; then
963 diff -u $testroot/stdout.expected $testroot/stdout
964 test_done "$testroot" "$ret"
965 return 1
966 fi
968 for f in alpha beta; do
969 echo "$f" > $testroot/content.expected
970 cat $testroot/wt/$f > $testroot/content
971 cmp -s $testroot/content.expected $testroot/content
972 ret=$?
973 if [ $ret -ne 0 ]; then
974 diff -u $testroot/content.expected $testroot/content
975 test_done "$testroot" "$ret"
976 return 1
977 fi
978 done
980 if [ -e $testroot/wt/epsilon/new ]; then
981 echo "removed file new still exists on disk" >&2
982 test_done "$testroot" "1"
983 return 1
984 fi
986 (cd $testroot/wt && got status > $testroot/stdout)
988 echo "? unversioned-file" > $testroot/stdout.expected
989 cmp -s $testroot/stdout.expected $testroot/stdout
990 ret=$?
991 if [ $ret -ne 0 ]; then
992 diff -u $testroot/stdout.expected $testroot/stdout
993 test_done "$testroot" "$ret"
994 return 1
995 fi
997 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
998 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
999 echo "commit $new_commit1" >> $testroot/stdout.expected
1000 echo "commit $orig_commit" >> $testroot/stdout.expected
1001 cmp -s $testroot/stdout.expected $testroot/stdout
1002 ret=$?
1003 if [ $ret -ne 0 ]; then
1004 diff -u $testroot/stdout.expected $testroot/stdout
1006 test_done "$testroot" "$ret"
1009 test_histedit_path_prefix_drop() {
1010 local testroot=`test_init histedit_path_prefix_drop`
1011 local orig_commit=`git_show_head $testroot/repo`
1013 echo "modified zeta" > $testroot/repo/epsilon/zeta
1014 git_commit $testroot/repo -m "changing zeta"
1015 local old_commit1=`git_show_head $testroot/repo`
1017 got checkout -c $orig_commit -p gamma $testroot/repo \
1018 $testroot/wt > /dev/null
1019 ret=$?
1020 if [ $ret -ne 0 ]; then
1021 test_done "$testroot" "$ret"
1022 return 1
1025 echo "drop $old_commit1" > $testroot/histedit-script
1027 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1028 > $testroot/stdout 2> $testroot/stderr)
1030 ret=$?
1031 if [ $ret -eq 0 ]; then
1032 echo "histedit succeeded unexpectedly" >&2
1033 test_done "$testroot" "1"
1034 return 1
1037 echo -n "got: cannot edit branch history which contains changes " \
1038 > $testroot/stderr.expected
1039 echo "outside of this work tree's path prefix" \
1040 >> $testroot/stderr.expected
1042 cmp -s $testroot/stderr.expected $testroot/stderr
1043 ret=$?
1044 if [ $ret -ne 0 ]; then
1045 diff -u $testroot/stderr.expected $testroot/stderr
1046 test_done "$testroot" "$ret"
1047 return 1
1050 rm -rf $testroot/wt
1051 got checkout -c $orig_commit -p epsilon $testroot/repo \
1052 $testroot/wt > /dev/null
1053 ret=$?
1054 if [ $ret -ne 0 ]; then
1055 test_done "$testroot" "$ret"
1056 return 1
1058 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1059 > $testroot/stdout)
1061 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1062 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1064 echo "$short_old_commit1 -> drop commit: changing zeta" \
1065 > $testroot/stdout.expected
1066 echo "Switching work tree to refs/heads/master" \
1067 >> $testroot/stdout.expected
1069 cmp -s $testroot/stdout.expected $testroot/stdout
1070 ret=$?
1071 if [ $ret -ne 0 ]; then
1072 diff -u $testroot/stdout.expected $testroot/stdout
1073 test_done "$testroot" "$ret"
1074 return 1
1077 echo "zeta" > $testroot/content.expected
1078 cat $testroot/wt/zeta > $testroot/content
1079 cmp -s $testroot/content.expected $testroot/content
1080 ret=$?
1081 if [ $ret -ne 0 ]; then
1082 diff -u $testroot/content.expected $testroot/content
1083 test_done "$testroot" "$ret"
1084 return 1
1088 (cd $testroot/wt && got status > $testroot/stdout)
1090 echo -n > $testroot/stdout.expected
1091 cmp -s $testroot/stdout.expected $testroot/stdout
1092 ret=$?
1093 if [ $ret -ne 0 ]; then
1094 diff -u $testroot/stdout.expected $testroot/stdout
1095 test_done "$testroot" "$ret"
1096 return 1
1099 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1100 echo "commit $orig_commit (master)" > $testroot/stdout.expected
1101 cmp -s $testroot/stdout.expected $testroot/stdout
1102 ret=$?
1103 if [ $ret -ne 0 ]; then
1104 diff -u $testroot/stdout.expected $testroot/stdout
1106 test_done "$testroot" "$ret"
1109 test_histedit_path_prefix_edit() {
1110 local testroot=`test_init histedit_path_prefix_edit`
1111 local orig_commit=`git_show_head $testroot/repo`
1113 echo "modified zeta" > $testroot/repo/epsilon/zeta
1114 git_commit $testroot/repo -m "changing zeta"
1115 local old_commit1=`git_show_head $testroot/repo`
1117 got diff -r $testroot/repo $orig_commit $old_commit1 \
1118 > $testroot/diff.expected
1120 got checkout -c $orig_commit -p gamma $testroot/repo \
1121 $testroot/wt > /dev/null
1122 ret=$?
1123 if [ $ret -ne 0 ]; then
1124 test_done "$testroot" "$ret"
1125 return 1
1128 echo "edit $old_commit1" > $testroot/histedit-script
1130 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1131 > $testroot/stdout 2> $testroot/stderr)
1133 ret=$?
1134 if [ $ret -eq 0 ]; then
1135 echo "histedit succeeded unexpectedly" >&2
1136 test_done "$testroot" "1"
1137 return 1
1140 echo -n "got: cannot edit branch history which contains changes " \
1141 > $testroot/stderr.expected
1142 echo "outside of this work tree's path prefix" \
1143 >> $testroot/stderr.expected
1145 cmp -s $testroot/stderr.expected $testroot/stderr
1146 ret=$?
1147 if [ $ret -ne 0 ]; then
1148 diff -u $testroot/stderr.expected $testroot/stderr
1149 test_done "$testroot" "$ret"
1150 return 1
1153 rm -rf $testroot/wt
1154 got checkout -c $orig_commit -p epsilon $testroot/repo \
1155 $testroot/wt > /dev/null
1156 ret=$?
1157 if [ $ret -ne 0 ]; then
1158 test_done "$testroot" "$ret"
1159 return 1
1161 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1162 > $testroot/stdout)
1164 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1166 echo "G zeta" > $testroot/stdout.expected
1167 echo "Stopping histedit for amending commit $old_commit1" \
1168 >> $testroot/stdout.expected
1169 cmp -s $testroot/stdout.expected $testroot/stdout
1170 ret=$?
1171 if [ $ret -ne 0 ]; then
1172 diff -u $testroot/stdout.expected $testroot/stdout
1173 test_done "$testroot" "$ret"
1174 return 1
1177 echo "modified zeta" > $testroot/content.expected
1178 cat $testroot/wt/zeta > $testroot/content
1179 cmp -s $testroot/content.expected $testroot/content
1180 ret=$?
1181 if [ $ret -ne 0 ]; then
1182 diff -u $testroot/content.expected $testroot/content
1183 test_done "$testroot" "$ret"
1184 return 1
1187 (cd $testroot/wt && got status > $testroot/stdout)
1189 cat > $testroot/stdout.expected <<EOF
1190 M zeta
1191 Work tree is editing the history of refs/heads/master
1192 EOF
1193 cmp -s $testroot/stdout.expected $testroot/stdout
1194 ret=$?
1195 if [ $ret -ne 0 ]; then
1196 diff -u $testroot/stdout.expected $testroot/stdout
1197 test_done "$testroot" "$ret"
1198 return 1
1201 cat > $testroot/editor.sh <<EOF
1202 #!/bin/sh
1203 ed -s "\$1" <<-EOF
1204 ,s/.*/modified zeta/
1206 EOF
1207 EOF
1208 chmod +x $testroot/editor.sh
1210 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1211 VISUAL="$testroot/editor.sh" \
1212 got histedit -c > $testroot/stdout)
1214 local new_commit1=`git_show_head $testroot/repo`
1215 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1217 echo -n "$short_old_commit1 -> $short_new_commit1: " \
1218 > $testroot/stdout.expected
1219 echo "modified zeta" >> $testroot/stdout.expected
1220 echo "Switching work tree to refs/heads/master" \
1221 >> $testroot/stdout.expected
1223 cmp -s $testroot/stdout.expected $testroot/stdout
1224 ret=$?
1225 if [ $ret -ne 0 ]; then
1226 diff -u $testroot/stdout.expected $testroot/stdout
1227 test_done "$testroot" "$ret"
1228 return 1
1231 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1232 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1233 echo "commit $orig_commit" >> $testroot/stdout.expected
1234 cmp -s $testroot/stdout.expected $testroot/stdout
1235 ret=$?
1236 if [ $ret -ne 0 ]; then
1237 diff -u $testroot/stdout.expected $testroot/stdout
1238 test_done "$testroot" "$ret"
1239 return 1
1242 got diff -r $testroot/repo $orig_commit $new_commit1 \
1243 > $testroot/diff
1244 ed -s $testroot/diff.expected <<-EOF
1245 ,s/$old_commit1/$new_commit1/
1247 EOF
1248 cmp -s $testroot/diff.expected $testroot/diff
1249 ret=$?
1250 if [ $ret -ne 0 ]; then
1251 diff -u $testroot/diff.expected $testroot/diff
1253 test_done "$testroot" "$ret"
1256 test_histedit_outside_refs_heads() {
1257 local testroot=`test_init histedit_outside_refs_heads`
1258 local commit1=`git_show_head $testroot/repo`
1260 got checkout $testroot/repo $testroot/wt > /dev/null
1261 ret=$?
1262 if [ $ret -ne 0 ]; then
1263 echo "got checkout failed unexpectedly"
1264 test_done "$testroot" "$ret"
1265 return 1
1268 echo "modified alpha" > $testroot/wt/alpha
1270 (cd $testroot/wt && got commit -m 'change alpha' \
1271 > $testroot/stdout 2> $testroot/stderr)
1272 ret=$?
1273 if [ $ret -ne 0 ]; then
1274 echo "got commit failed unexpectedly" >&2
1275 test_done "$testroot" "1"
1276 return 1
1278 local commit2=`git_show_head $testroot/repo`
1280 got ref -r $testroot/repo -c master refs/remotes/origin/master
1281 ret=$?
1282 if [ $ret -ne 0 ]; then
1283 echo "got ref failed unexpectedly" >&2
1284 test_done "$testroot" "1"
1285 return 1
1288 (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1289 ret=$?
1290 if [ $ret -ne 0 ]; then
1291 echo "got update failed unexpectedly"
1292 test_done "$testroot" "$ret"
1293 return 1
1296 echo "edit $commit2" > $testroot/histedit-script
1297 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1298 2> $testroot/stderr)
1300 echo -n "got: will not edit commit history of a branch outside the " \
1301 > $testroot/stderr.expected
1302 echo '"refs/heads/" reference namespace' \
1303 >> $testroot/stderr.expected
1304 cmp -s $testroot/stderr.expected $testroot/stderr
1305 ret=$?
1306 if [ $ret -ne 0 ]; then
1307 diff -u $testroot/stderr.expected $testroot/stderr
1309 test_done "$testroot" "$ret"
1312 test_histedit_fold_last_commit_swap() {
1313 local testroot=`test_init histedit_fold_last_commit_swap`
1315 local orig_commit=`git_show_head $testroot/repo`
1317 echo "modified alpha on master" > $testroot/repo/alpha
1318 git -C $testroot/repo rm -q beta
1319 echo "new file on master" > $testroot/repo/epsilon/new
1320 git -C $testroot/repo add epsilon/new
1321 git_commit $testroot/repo -m "committing changes"
1322 local old_commit1=`git_show_head $testroot/repo`
1324 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1325 git_commit $testroot/repo -m "committing to zeta on master"
1326 local old_commit2=`git_show_head $testroot/repo`
1328 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1329 ret=$?
1330 if [ $ret -ne 0 ]; then
1331 test_done "$testroot" "$ret"
1332 return 1
1335 cat > $testroot/editor.sh <<EOF
1336 #!/bin/sh
1337 ed -s "\$1" <<-EOF
1338 ,s/.*/committing folded changes/
1340 EOF
1341 EOF
1342 chmod +x $testroot/editor.sh
1344 # fold commit2 into commit1 (requires swapping commits)
1345 echo "fold $old_commit2" > $testroot/histedit-script
1346 echo "mesg $old_commit1" >> $testroot/histedit-script
1348 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1349 VISUAL="$testroot/editor.sh" \
1350 got histedit -F $testroot/histedit-script > $testroot/stdout \
1351 2> $testroot/stderr)
1353 ret=$?
1354 if [ $ret -ne 0 ]; then
1355 echo "histedit failed unexpectedly" >&2
1356 test_done "$testroot" "$ret"
1357 return 1
1360 local new_commit=`git_show_head $testroot/repo`
1362 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1363 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1364 local short_new_commit=`trim_obj_id 28 $new_commit`
1366 echo "G epsilon/zeta" >> $testroot/stdout.expected
1367 echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1368 >> $testroot/stdout.expected
1369 echo "on master" >> $testroot/stdout.expected
1370 echo "G alpha" >> $testroot/stdout.expected
1371 echo "D beta" >> $testroot/stdout.expected
1372 echo "A epsilon/new" >> $testroot/stdout.expected
1373 echo -n "$short_old_commit1 -> $short_new_commit: " \
1374 >> $testroot/stdout.expected
1375 echo "committing folded changes" >> $testroot/stdout.expected
1376 echo "Switching work tree to refs/heads/master" \
1377 >> $testroot/stdout.expected
1379 cmp -s $testroot/stdout.expected $testroot/stdout
1380 ret=$?
1381 if [ $ret -ne 0 ]; then
1382 diff -u $testroot/stdout.expected $testroot/stdout
1384 test_done "$testroot" "$ret"
1387 test_histedit_split_commit() {
1388 local testroot=`test_init histedit_split_commit`
1390 local orig_commit=`git_show_head $testroot/repo`
1392 echo "modified alpha on master" > $testroot/repo/alpha
1393 git -C $testroot/repo rm -q beta
1394 echo "new file on master" > $testroot/repo/epsilon/new
1395 git -C $testroot/repo add epsilon/new
1396 git_commit $testroot/repo -m "committing changes 1"
1397 local old_commit1=`git_show_head $testroot/repo`
1398 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1400 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1401 git_commit $testroot/repo -m "committing changes 2"
1402 local old_commit2=`git_show_head $testroot/repo`
1403 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1405 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1406 ret=$?
1407 if [ $ret -ne 0 ]; then
1408 test_done "$testroot" "$ret"
1409 return 1
1412 # split commit1 into commitA and commitB and commitC
1413 echo "e $old_commit1" > $testroot/histedit-script
1414 echo "p $old_commit2" >> $testroot/histedit-script
1416 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1417 > $testroot/stdout 2> $testroot/stderr)
1418 ret=$?
1419 if [ $ret -ne 0 ]; then
1420 echo "histedit failed unexpectedly:" >&2
1421 cat $testroot/stderr >&2
1422 test_done "$testroot" "$ret"
1423 return 1
1426 echo "G alpha" > $testroot/stdout.expected
1427 echo "D beta" >> $testroot/stdout.expected
1428 echo "A epsilon/new" >> $testroot/stdout.expected
1429 echo "Stopping histedit for amending commit $old_commit1" \
1430 >> $testroot/stdout.expected
1432 cmp -s $testroot/stdout.expected $testroot/stdout
1433 ret=$?
1434 if [ $ret -ne 0 ]; then
1435 diff -u $testroot/stdout.expected $testroot/stdout
1436 test_done "$testroot" "$ret"
1437 return 1
1440 (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1441 ret=$?
1442 if [ $ret -ne 0 ]; then
1443 echo "commit failed unexpectedly" >&2
1444 test_done "$testroot" "$ret"
1445 return 1
1448 (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1449 ret=$?
1450 if [ $ret -ne 0 ]; then
1451 echo "commit failed unexpectedly" >&2
1452 test_done "$testroot" "$ret"
1453 return 1
1456 (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1457 ret=$?
1458 if [ $ret -ne 0 ]; then
1459 echo "commit failed unexpectedly" >&2
1460 test_done "$testroot" "$ret"
1461 return 1
1464 (cd $testroot/wt && got histedit -c \
1465 > $testroot/stdout 2> $testroot/stderr)
1466 ret=$?
1467 if [ $ret -ne 0 ]; then
1468 echo "histedit failed unexpectedly:" >&2
1469 cat $testroot/stderr >&2
1470 test_done "$testroot" "$ret"
1471 return 1
1473 local new_commit2=`git_show_head $testroot/repo`
1474 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1476 echo "$short_old_commit1 -> no-op change: committing changes 1" \
1477 > $testroot/stdout.expected
1478 echo "G epsilon/zeta" >> $testroot/stdout.expected
1479 echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1480 >> $testroot/stdout.expected
1481 echo "Switching work tree to refs/heads/master" \
1482 >> $testroot/stdout.expected
1484 cmp -s $testroot/stdout.expected $testroot/stdout
1485 ret=$?
1486 if [ $ret -ne 0 ]; then
1487 diff -u $testroot/stdout.expected $testroot/stdout
1489 test_done "$testroot" "$ret"
1493 test_histedit_duplicate_commit_in_script() {
1494 local testroot=`test_init histedit_duplicate_commit_in_script`
1496 local orig_commit=`git_show_head $testroot/repo`
1498 echo "modified alpha on master" > $testroot/repo/alpha
1499 git -C $testroot/repo rm -q beta
1500 echo "new file on master" > $testroot/repo/epsilon/new
1501 git -C $testroot/repo add epsilon/new
1502 git_commit $testroot/repo -m "committing changes 1"
1503 local old_commit1=`git_show_head $testroot/repo`
1505 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1506 git_commit $testroot/repo -m "committing changes 2"
1507 local old_commit2=`git_show_head $testroot/repo`
1509 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1510 ret=$?
1511 if [ $ret -ne 0 ]; then
1512 test_done "$testroot" "$ret"
1513 return 1
1516 # This histedit script lists commit1 more than once
1517 echo "p $old_commit1" > $testroot/histedit-script
1518 echo "p $old_commit1" >> $testroot/histedit-script
1519 echo "p $old_commit2" >> $testroot/histedit-script
1521 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1522 > $testroot/stdout 2> $testroot/stderr)
1523 ret=$?
1524 if [ $ret -eq 0 ]; then
1525 echo "histedit succeeded unexpectedly:" >&2
1526 cat $testroot/stdout >&2
1527 test_done "$testroot" 1
1528 return 1
1531 echo -n "got: commit $old_commit1 is listed more than once " \
1532 > $testroot/stderr.expected
1533 echo "in histedit script" >> $testroot/stderr.expected
1535 cmp -s $testroot/stderr.expected $testroot/stderr
1536 ret=$?
1537 if [ $ret -ne 0 ]; then
1538 diff -u $testroot/stderr.expected $testroot/stderr
1540 test_done "$testroot" "$ret"
1544 # if a previous commit introduces a new file, and it is folded into a commit
1545 # that deletes the same file, the file still exists after the histedit
1546 test_histedit_fold_add_delete() {
1547 local testroot=`test_init histedit_fold_add_delete`
1549 local orig_commit=`git_show_head $testroot/repo`
1551 echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1552 git -C $testroot/repo add epsilon/psi
1553 git_commit $testroot/repo -m "committing changes"
1554 local old_commit1=`git_show_head $testroot/repo`
1556 echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1557 git_commit $testroot/repo -m "editing psi"
1558 local old_commit2=`git_show_head $testroot/repo`
1560 git -C $testroot/repo rm -q epsilon/psi
1561 git_commit $testroot/repo -m "removing psi"
1562 local old_commit3=`git_show_head $testroot/repo`
1564 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1565 ret=$?
1566 if [ $ret -ne 0 ]; then
1567 test_done "$testroot" "$ret"
1568 return 1
1571 cat > $testroot/editor.sh <<EOF
1572 #!/bin/sh
1573 ed -s "\$1" <<-EOF
1574 ,s/.*/folded changes/
1576 EOF
1577 EOF
1578 chmod +x $testroot/editor.sh
1580 echo "fold $old_commit1" > $testroot/histedit-script
1581 echo "fold $old_commit2" >> $testroot/histedit-script
1582 echo "pick $old_commit3" >> $testroot/histedit-script
1584 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1585 VISUAL="$testroot/editor.sh" \
1586 got histedit -F $testroot/histedit-script > $testroot/stdout)
1588 local new_commit1=`git_show_head $testroot/repo`
1590 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1591 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1592 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1593 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1595 echo "A epsilon/psi" >> $testroot/stdout.expected
1596 echo "$short_old_commit1 -> fold commit: committing changes" \
1597 >> $testroot/stdout.expected
1598 echo "G epsilon/psi" >> $testroot/stdout.expected
1599 echo "$short_old_commit2 -> fold commit: editing psi" \
1600 >> $testroot/stdout.expected
1601 echo "D epsilon/psi" >> $testroot/stdout.expected
1602 echo "$short_old_commit3 -> no-op change: folded changes" \
1603 >> $testroot/stdout.expected
1604 echo "Switching work tree to refs/heads/master" \
1605 >> $testroot/stdout.expected
1607 cmp -s $testroot/stdout.expected $testroot/stdout
1608 ret=$?
1609 if [ $ret -ne 0 ]; then
1610 diff -u $testroot/stdout.expected $testroot/stdout
1611 test_done "$testroot" "$ret"
1612 return 1
1615 if [ -e $testroot/wt/epsilon/psi ]; then
1616 echo "removed file psi still exists on disk" >&2
1617 test_done "$testroot" "1"
1618 return 1
1621 (cd $testroot/wt && got status > $testroot/stdout)
1623 echo -n > $testroot/stdout.expected
1624 cmp -s $testroot/stdout.expected $testroot/stdout
1625 ret=$?
1626 if [ $ret -ne 0 ]; then
1627 diff -u $testroot/stdout.expected $testroot/stdout
1628 test_done "$testroot" "$ret"
1629 return 1
1632 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1633 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1634 cmp -s $testroot/stdout.expected $testroot/stdout
1635 ret=$?
1636 if [ $ret -ne 0 ]; then
1637 diff -u $testroot/stdout.expected $testroot/stdout
1638 test_done "$testroot" "$ret"
1639 return 1
1642 got tree -r $testroot/repo epsilon > $testroot/stdout
1643 echo "zeta" > $testroot/stdout.expected
1644 cmp -s $testroot/stdout.expected $testroot/stdout
1645 ret=$?
1646 if [ $ret -ne 0 ]; then
1647 diff -u $testroot/stdout.expected $testroot/stdout
1649 test_done "$testroot" "$ret"
1652 # if a previous commit edits a file, and it is folded into a commit
1653 # that deletes the same file, the file will be deleted by histedit
1654 test_histedit_fold_edit_delete() {
1655 local testroot=`test_init histedit_fold_edit_delete`
1657 local orig_commit=`git_show_head $testroot/repo`
1659 echo "modify alpha" > $testroot/repo/alpha
1660 git -C $testroot/repo add alpha
1661 git_commit $testroot/repo -m "modified alpha"
1662 local old_commit1=`git_show_head $testroot/repo`
1664 git_rm $testroot/repo alpha
1665 git_commit $testroot/repo -m "deleted alpha"
1666 local old_commit2=`git_show_head $testroot/repo`
1668 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1669 ret=$?
1670 if [ $ret -ne 0 ]; then
1671 test_done "$testroot" "$ret"
1672 return 1
1675 cat > $testroot/editor.sh <<EOF
1676 #!/bin/sh
1677 ed -s "\$1" <<-EOF
1678 ,s/.*/folded changes/
1680 EOF
1681 EOF
1682 chmod +x $testroot/editor.sh
1684 echo "fold $old_commit1" > $testroot/histedit-script
1685 echo "pick $old_commit2" >> $testroot/histedit-script
1687 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1688 VISUAL="$testroot/editor.sh" \
1689 got histedit -F $testroot/histedit-script > $testroot/stdout)
1691 local new_commit1=`git_show_head $testroot/repo`
1693 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1694 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1695 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1697 echo "G alpha" >> $testroot/stdout.expected
1698 echo "$short_old_commit1 -> fold commit: modified alpha" \
1699 >> $testroot/stdout.expected
1700 echo "D alpha" >> $testroot/stdout.expected
1701 echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1702 >> $testroot/stdout.expected
1703 echo "Switching work tree to refs/heads/master" \
1704 >> $testroot/stdout.expected
1706 cmp -s $testroot/stdout.expected $testroot/stdout
1707 ret=$?
1708 if [ $ret -ne 0 ]; then
1709 diff -u $testroot/stdout.expected $testroot/stdout
1710 test_done "$testroot" "$ret"
1711 return 1
1714 if [ -e $testroot/wt/alpha ]; then
1715 echo "removed file alpha still exists on disk" >&2
1716 test_done "$testroot" "1"
1717 return 1
1720 (cd $testroot/wt && got status > $testroot/stdout)
1722 echo -n > $testroot/stdout.expected
1723 cmp -s $testroot/stdout.expected $testroot/stdout
1724 ret=$?
1725 if [ $ret -ne 0 ]; then
1726 diff -u $testroot/stdout.expected $testroot/stdout
1727 test_done "$testroot" "$ret"
1728 return 1
1731 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
1732 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1733 echo "commit $orig_commit" >> $testroot/stdout.expected
1734 cmp -s $testroot/stdout.expected $testroot/stdout
1735 ret=$?
1736 if [ $ret -ne 0 ]; then
1737 diff -u $testroot/stdout.expected $testroot/stdout
1740 test_done "$testroot" "$ret"
1743 test_histedit_fold_delete_add() {
1744 local testroot=`test_init histedit_fold_delete_add`
1746 local orig_commit=`git_show_head $testroot/repo`
1748 git -C $testroot/repo rm -q alpha
1749 git_commit $testroot/repo -m "removing alpha"
1750 local old_commit1=`git_show_head $testroot/repo`
1752 echo "modified alpha" >$testroot/repo/alpha
1753 git -C $testroot/repo add alpha
1754 git_commit $testroot/repo -m "add back modified alpha"
1755 local old_commit2=`git_show_head $testroot/repo`
1757 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1758 ret=$?
1759 if [ $ret -ne 0 ]; then
1760 test_done "$testroot" "$ret"
1761 return 1
1764 cat > $testroot/editor.sh <<EOF
1765 #!/bin/sh
1766 ed -s "\$1" <<-EOF
1767 ,s/.*/folded changes/
1769 EOF
1770 EOF
1771 chmod +x $testroot/editor.sh
1773 echo "fold $old_commit1" > $testroot/histedit-script
1774 echo "pick $old_commit2" >> $testroot/histedit-script
1776 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1777 VISUAL="$testroot/editor.sh" \
1778 got histedit -F $testroot/histedit-script > $testroot/stdout)
1780 local new_commit1=`git_show_head $testroot/repo`
1782 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1783 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1784 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1786 echo "D alpha" > $testroot/stdout.expected
1787 echo "$short_old_commit1 -> fold commit: removing alpha" \
1788 >> $testroot/stdout.expected
1789 echo "A alpha" >> $testroot/stdout.expected
1790 echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1791 >> $testroot/stdout.expected
1792 echo "Switching work tree to refs/heads/master" \
1793 >> $testroot/stdout.expected
1795 cmp -s $testroot/stdout.expected $testroot/stdout
1796 ret=$?
1797 if [ $ret -ne 0 ]; then
1798 diff -u $testroot/stdout.expected $testroot/stdout
1799 test_done "$testroot" "$ret"
1800 return 1
1803 if [ ! -e $testroot/wt/alpha ]; then
1804 echo "file alpha is missing on disk" >&2
1805 test_done "$testroot" "1"
1806 return 1
1809 echo "modified alpha" > $testroot/content.expected
1810 cat $testroot/wt/alpha > $testroot/content
1811 cmp -s $testroot/content.expected $testroot/content
1812 ret=$?
1813 if [ $ret -ne 0 ]; then
1814 diff -u $testroot/content.expected $testroot/content
1815 test_done "$testroot" "$ret"
1816 return 1
1818 test_done "$testroot" "0"
1821 test_histedit_fold_only() {
1822 local testroot=`test_init histedit_fold_only`
1824 local orig_commit=`git_show_head $testroot/repo`
1826 echo "modified alpha on master" > $testroot/repo/alpha
1827 git -C $testroot/repo rm -q beta
1828 echo "new file on master" > $testroot/repo/epsilon/new
1829 git -C $testroot/repo add epsilon/new
1830 git_commit $testroot/repo -m "committing changes"
1831 local old_commit1=`git_show_head $testroot/repo`
1833 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1834 git_commit $testroot/repo -m "committing to zeta on master"
1835 local old_commit2=`git_show_head $testroot/repo`
1837 echo "modified delta on master" > $testroot/repo/gamma/delta
1838 git_commit $testroot/repo -m "committing to delta on master"
1839 local old_commit3=`git_show_head $testroot/repo`
1841 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1842 ret=$?
1843 if [ $ret -ne 0 ]; then
1844 test_done "$testroot" "$ret"
1845 return 1
1848 cat > $testroot/editor.sh <<EOF
1849 #!/bin/sh
1850 ed -s "\$1" <<-EOF
1851 ,s/.*/committing folded changes/
1853 EOF
1854 EOF
1855 chmod +x $testroot/editor.sh
1857 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1858 VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1860 local new_commit1=`git_show_head $testroot/repo`
1862 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1863 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1864 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1865 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1866 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1868 echo "G alpha" > $testroot/stdout.expected
1869 echo "D beta" >> $testroot/stdout.expected
1870 echo "A epsilon/new" >> $testroot/stdout.expected
1871 echo "$short_old_commit1 -> fold commit: committing changes" \
1872 >> $testroot/stdout.expected
1873 echo "G epsilon/zeta" >> $testroot/stdout.expected
1874 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1875 echo "fold commit: committing to zeta on master" \
1876 >> $testroot/stdout.expected
1877 echo "G gamma/delta" >> $testroot/stdout.expected
1878 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1879 >> $testroot/stdout.expected
1880 echo "committing folded changes" >> $testroot/stdout.expected
1881 echo "Switching work tree to refs/heads/master" \
1882 >> $testroot/stdout.expected
1884 cmp -s $testroot/stdout.expected $testroot/stdout
1885 ret=$?
1886 if [ $ret -ne 0 ]; then
1887 diff -u $testroot/stdout.expected $testroot/stdout
1888 test_done "$testroot" "$ret"
1889 return 1
1892 echo "modified alpha on master" > $testroot/content.expected
1893 cat $testroot/wt/alpha > $testroot/content
1894 cmp -s $testroot/content.expected $testroot/content
1895 ret=$?
1896 if [ $ret -ne 0 ]; then
1897 diff -u $testroot/content.expected $testroot/content
1898 test_done "$testroot" "$ret"
1899 return 1
1902 if [ -e $testroot/wt/beta ]; then
1903 echo "removed file beta still exists on disk" >&2
1904 test_done "$testroot" "1"
1905 return 1
1908 echo "new file on master" > $testroot/content.expected
1909 cat $testroot/wt/epsilon/new > $testroot/content
1910 cmp -s $testroot/content.expected $testroot/content
1911 ret=$?
1912 if [ $ret -ne 0 ]; then
1913 diff -u $testroot/content.expected $testroot/content
1914 test_done "$testroot" "$ret"
1915 return 1
1918 (cd $testroot/wt && got status > $testroot/stdout)
1920 echo -n > $testroot/stdout.expected
1921 cmp -s $testroot/stdout.expected $testroot/stdout
1922 ret=$?
1923 if [ $ret -ne 0 ]; then
1924 diff -u $testroot/stdout.expected $testroot/stdout
1925 test_done "$testroot" "$ret"
1926 return 1
1929 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1930 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1931 echo "commit $orig_commit" >> $testroot/stdout.expected
1932 cmp -s $testroot/stdout.expected $testroot/stdout
1933 ret=$?
1934 if [ $ret -ne 0 ]; then
1935 diff -u $testroot/stdout.expected $testroot/stdout
1937 test_done "$testroot" "$ret"
1940 test_histedit_fold_only_empty_logmsg() {
1941 local testroot=`test_init histedit_fold_only_empty_logmsg`
1943 local orig_commit=`git_show_head $testroot/repo`
1945 echo "modified alpha on master" > $testroot/repo/alpha
1946 git -C $testroot/repo rm -q beta
1947 echo "new file on master" > $testroot/repo/epsilon/new
1948 git -C $testroot/repo add epsilon/new
1949 git_commit $testroot/repo -m "committing changes"
1950 local old_commit1=`git_show_head $testroot/repo`
1952 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1953 git_commit $testroot/repo -m "committing to zeta on master"
1954 local old_commit2=`git_show_head $testroot/repo`
1956 echo "modified delta on master" > $testroot/repo/gamma/delta
1957 git_commit $testroot/repo -m "committing to delta on master"
1958 local old_commit3=`git_show_head $testroot/repo`
1960 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1961 ret=$?
1962 if [ $ret -ne 0 ]; then
1963 test_done "$testroot" "$ret"
1964 return 1
1967 cat > $testroot/editor.sh <<EOF
1968 #!/bin/sh
1969 ed -s "\$1" <<-EOF
1972 EOF
1973 EOF
1974 chmod +x $testroot/editor.sh
1976 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1977 VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1979 local new_commit1=`git_show_head $testroot/repo`
1981 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1982 local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1983 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1984 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1985 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1986 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1988 echo "G alpha" > $testroot/stdout.expected
1989 echo "D beta" >> $testroot/stdout.expected
1990 echo "A epsilon/new" >> $testroot/stdout.expected
1991 echo "$short_old_commit1 -> fold commit: committing changes" \
1992 >> $testroot/stdout.expected
1993 echo "G epsilon/zeta" >> $testroot/stdout.expected
1994 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1995 echo "fold commit: committing to zeta on master" \
1996 >> $testroot/stdout.expected
1997 echo "G gamma/delta" >> $testroot/stdout.expected
1998 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1999 >> $testroot/stdout.expected
2000 echo "# log message of folded commit $very_short_old_commit1" \
2001 >> $testroot/stdout.expected
2002 echo "Switching work tree to refs/heads/master" \
2003 >> $testroot/stdout.expected
2005 cmp -s $testroot/stdout.expected $testroot/stdout
2006 ret=$?
2007 if [ $ret -ne 0 ]; then
2008 diff -u $testroot/stdout.expected $testroot/stdout
2009 test_done "$testroot" "$ret"
2010 return 1
2013 echo "modified alpha on master" > $testroot/content.expected
2014 cat $testroot/wt/alpha > $testroot/content
2015 cmp -s $testroot/content.expected $testroot/content
2016 ret=$?
2017 if [ $ret -ne 0 ]; then
2018 diff -u $testroot/content.expected $testroot/content
2019 test_done "$testroot" "$ret"
2020 return 1
2023 if [ -e $testroot/wt/beta ]; then
2024 echo "removed file beta still exists on disk" >&2
2025 test_done "$testroot" "1"
2026 return 1
2029 echo "new file on master" > $testroot/content.expected
2030 cat $testroot/wt/epsilon/new > $testroot/content
2031 cmp -s $testroot/content.expected $testroot/content
2032 ret=$?
2033 if [ $ret -ne 0 ]; then
2034 diff -u $testroot/content.expected $testroot/content
2035 test_done "$testroot" "$ret"
2036 return 1
2039 (cd $testroot/wt && got status > $testroot/stdout)
2041 echo -n > $testroot/stdout.expected
2042 cmp -s $testroot/stdout.expected $testroot/stdout
2043 ret=$?
2044 if [ $ret -ne 0 ]; then
2045 diff -u $testroot/stdout.expected $testroot/stdout
2046 test_done "$testroot" "$ret"
2047 return 1
2050 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2051 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
2052 echo "commit $orig_commit" >> $testroot/stdout.expected
2053 cmp -s $testroot/stdout.expected $testroot/stdout
2054 ret=$?
2055 if [ $ret -ne 0 ]; then
2056 diff -u $testroot/stdout.expected $testroot/stdout
2058 test_done "$testroot" "$ret"
2061 test_histedit_edit_only() {
2062 local testroot=`test_init histedit_edit_only`
2064 local orig_commit=`git_show_head $testroot/repo`
2066 echo "modified alpha on master" > $testroot/repo/alpha
2067 git -C $testroot/repo rm -q beta
2068 echo "new file on master" > $testroot/repo/epsilon/new
2069 git -C $testroot/repo add epsilon/new
2070 git_commit $testroot/repo -m "committing changes"
2071 local old_commit1=`git_show_head $testroot/repo`
2073 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2074 git_commit $testroot/repo -m "committing to zeta on master"
2075 local old_commit2=`git_show_head $testroot/repo`
2077 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2078 ret=$?
2079 if [ $ret -ne 0 ]; then
2080 test_done "$testroot" "$ret"
2081 return 1
2084 (cd $testroot/wt && got histedit -e > $testroot/stdout)
2086 local short_old_commit1=`trim_obj_id 28 $old_commit1`
2087 local short_old_commit2=`trim_obj_id 28 $old_commit2`
2089 echo "G alpha" > $testroot/stdout.expected
2090 echo "D beta" >> $testroot/stdout.expected
2091 echo "A epsilon/new" >> $testroot/stdout.expected
2092 echo "Stopping histedit for amending commit $old_commit1" \
2093 >> $testroot/stdout.expected
2094 cmp -s $testroot/stdout.expected $testroot/stdout
2095 ret=$?
2096 if [ $ret -ne 0 ]; then
2097 diff -u $testroot/stdout.expected $testroot/stdout
2098 test_done "$testroot" "$ret"
2099 return 1
2102 echo "edited modified alpha on master" > $testroot/wt/alpha
2104 cat > $testroot/editor.sh <<EOF
2105 #!/bin/sh
2106 ed -s "\$1" <<-EOF
2107 ,s/.*/committing edited changes 1/
2109 EOF
2110 EOF
2111 chmod +x $testroot/editor.sh
2113 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2114 VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2116 local new_commit1=$(cd $testroot/wt && got info | \
2117 grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
2118 local short_new_commit1=`trim_obj_id 28 $new_commit1`
2120 echo -n "$short_old_commit1 -> $short_new_commit1: " \
2121 > $testroot/stdout.expected
2122 echo "committing edited changes 1" >> $testroot/stdout.expected
2123 echo "G epsilon/zeta" >> $testroot/stdout.expected
2124 echo "Stopping histedit for amending commit $old_commit2" \
2125 >> $testroot/stdout.expected
2126 cmp -s $testroot/stdout.expected $testroot/stdout
2127 ret=$?
2128 if [ $ret -ne 0 ]; then
2129 diff -u $testroot/stdout.expected $testroot/stdout
2130 test_done "$testroot" "$ret"
2131 return 1
2134 echo "edited zeta on master" > $testroot/wt/epsilon/zeta
2136 cat > $testroot/editor.sh <<EOF
2137 #!/bin/sh
2138 ed -s "\$1" <<-EOF
2139 ,s/.*/committing edited changes 2/
2141 EOF
2142 EOF
2143 chmod +x $testroot/editor.sh
2145 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2146 VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2148 local new_commit2=`git_show_head $testroot/repo`
2149 local short_new_commit2=`trim_obj_id 28 $new_commit2`
2151 echo -n "$short_old_commit2 -> $short_new_commit2: " \
2152 > $testroot/stdout.expected
2153 echo "committing edited changes 2" >> $testroot/stdout.expected
2154 echo "Switching work tree to refs/heads/master" \
2155 >> $testroot/stdout.expected
2157 cmp -s $testroot/stdout.expected $testroot/stdout
2158 ret=$?
2159 if [ $ret -ne 0 ]; then
2160 diff -u $testroot/stdout.expected $testroot/stdout
2161 test_done "$testroot" "$ret"
2162 return 1
2165 echo "edited modified alpha on master" > $testroot/content.expected
2166 cat $testroot/wt/alpha > $testroot/content
2167 cmp -s $testroot/content.expected $testroot/content
2168 ret=$?
2169 if [ $ret -ne 0 ]; then
2170 diff -u $testroot/content.expected $testroot/content
2171 test_done "$testroot" "$ret"
2172 return 1
2175 if [ -e $testroot/wt/beta ]; then
2176 echo "removed file beta still exists on disk" >&2
2177 test_done "$testroot" "1"
2178 return 1
2181 echo "new file on master" > $testroot/content.expected
2182 cat $testroot/wt/epsilon/new > $testroot/content
2183 cmp -s $testroot/content.expected $testroot/content
2184 ret=$?
2185 if [ $ret -ne 0 ]; then
2186 diff -u $testroot/content.expected $testroot/content
2187 test_done "$testroot" "$ret"
2188 return 1
2191 (cd $testroot/wt && got status > $testroot/stdout)
2193 echo -n > $testroot/stdout.expected
2194 cmp -s $testroot/stdout.expected $testroot/stdout
2195 ret=$?
2196 if [ $ret -ne 0 ]; then
2197 diff -u $testroot/stdout.expected $testroot/stdout
2198 test_done "$testroot" "$ret"
2199 return 1
2202 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
2203 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
2204 echo "commit $new_commit1" >> $testroot/stdout.expected
2205 echo "commit $orig_commit" >> $testroot/stdout.expected
2206 cmp -s $testroot/stdout.expected $testroot/stdout
2207 ret=$?
2208 if [ $ret -ne 0 ]; then
2209 diff -u $testroot/stdout.expected $testroot/stdout
2211 test_done "$testroot" "$ret"
2214 test_histedit_prepend_line() {
2215 local testroot=`test_init histedit_prepend_line`
2216 local orig_commit=`git_show_head $testroot/repo`
2218 got checkout $testroot/repo $testroot/wt > /dev/null
2220 ed -s "$testroot/wt/alpha" <<EOF
2222 first line
2225 EOF
2227 cp $testroot/wt/alpha $testroot/content.expected
2229 (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2230 alpha > /dev/null)
2231 ret=$?
2232 if [ "$?" != 0 ]; then
2233 echo "got commit failed unexpectedly" >&2
2234 test_done "$testroot" "$ret"
2235 return 1
2238 local top_commit=`git_show_head $testroot/repo`
2239 echo "pick $top_commit" > "$testroot/histedit-script"
2241 (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2242 ret=$?
2243 if [ "$?" != 0 ]; then
2244 echo "got update failed unexpectedly" >&2
2245 test_done "$testroot" "$ret"
2246 return 1
2249 (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
2250 > /dev/null)
2251 ret=$?
2252 if [ "$?" != 0 ]; then
2253 echo "got histedit failed unexpectedly" >&2
2254 test_done "$testroot" "$ret"
2255 return 1
2258 cp $testroot/wt/alpha $testroot/content
2259 cmp -s $testroot/content.expected $testroot/content
2260 ret=$?
2261 if [ $ret -ne 0 ]; then
2262 diff -u $testroot/content.expected $testroot/content
2263 test_done "$testroot" "$ret"
2264 return 1
2267 test_done "$testroot" $ret
2270 test_histedit_resets_committer() {
2271 local testroot=`test_init histedit_resets_committer`
2272 local orig_commit=`git_show_head $testroot/repo`
2273 local committer="Flan Luck <flan_luck@openbsd.org>"
2275 got checkout $testroot/repo $testroot/wt > /dev/null
2277 echo "modified alpha" > $testroot/wt/alpha
2279 (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2280 alpha > /dev/null)
2281 ret=$?
2282 if [ "$?" != 0 ]; then
2283 echo "got commit failed unexpectedly" >&2
2284 test_done "$testroot" "$ret"
2285 return 1
2288 local top_commit=`git_show_head $testroot/repo`
2289 echo "pick $top_commit" > "$testroot/histedit-script"
2291 (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2292 ret=$?
2293 if [ "$?" != 0 ]; then
2294 echo "got update failed unexpectedly" >&2
2295 test_done "$testroot" "$ret"
2296 return 1
2299 (cd $testroot/wt && env GOT_AUTHOR="$committer" \
2300 got histedit -F "$testroot/histedit-script" > /dev/null)
2301 ret=$?
2302 if [ "$?" != 0 ]; then
2303 echo "got histedit failed unexpectedly" >&2
2304 test_done "$testroot" "$ret"
2305 return 1
2307 local edited_commit=`git_show_head $testroot/repo`
2309 # Original commit only had one author
2310 (cd $testroot/repo && got log -l1 -c $top_commit | \
2311 egrep '^(from|via):' > $testroot/stdout)
2312 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2313 cmp -s $testroot/stdout.expected $testroot/stdout
2314 ret=$?
2315 if [ $ret -ne 0 ]; then
2316 diff -u $testroot/stdout.expected $testroot/stdout
2317 test_done "$testroot" "$ret"
2318 return 1
2321 # Edited commit should have new committer name added
2322 (cd $testroot/repo && got log -l1 -c $edited_commit | \
2323 egrep '^(from|via):' > $testroot/stdout)
2324 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2325 echo "via: $committer" >> $testroot/stdout.expected
2327 cmp -s $testroot/stdout.expected $testroot/stdout
2328 ret=$?
2329 if [ $ret -ne 0 ]; then
2330 diff -u $testroot/stdout.expected $testroot/stdout
2332 test_done "$testroot" "$ret"
2335 test_histedit_umask() {
2336 local testroot=`test_init histedit_umask`
2337 local orig_commit=`git_show_head "$testroot/repo"`
2339 got checkout "$testroot/repo" "$testroot/wt" >/dev/null
2341 echo "modified alpha" > $testroot/wt/alpha
2342 (cd "$testroot/wt" && got commit -m 'edit #1') >/dev/null
2343 local commit1=`git_show_head "$testroot/repo"`
2345 echo "modified again" > $testroot/wt/alpha
2346 (cd "$testroot/wt" && got commit -m 'edit #2') >/dev/null
2347 local commit2=`git_show_head "$testroot/repo"`
2349 echo "modified again!" > $testroot/wt/alpha
2350 echo "modify beta too!" > $testroot/wt/beta
2351 (cd "$testroot/wt" && got commit -m 'edit #3') >/dev/null
2352 local commit3=`git_show_head "$testroot/repo"`
2354 (cd "$testroot/wt" && got update -c "$orig_commit") >/dev/null
2355 ret=$?
2356 if [ $ret -ne 0 ]; then
2357 echo "update to $orig_commit failed!" >&2
2358 test_done "$testroot" 1
2359 return 1
2362 cat > $testroot/editor.sh <<EOF
2363 #!/bin/sh
2364 ed -s "\$1" <<-EOF
2365 ,s/.*/folding changes/
2367 EOF
2368 EOF
2369 chmod +x $testroot/editor.sh
2371 echo fold $commit1 >$testroot/histedit-script
2372 echo fold $commit2 >>$testroot/histedit-script
2373 echo pick $commit3 >>$testroot/histedit-script
2375 # using a subshell to avoid clobbering global umask
2376 (umask 077 && cd "$testroot/wt" && \
2377 env EDITOR="$testroot/editor.sh" VISUAL="$testroot/editor.sh" \
2378 got histedit -F "$testroot/histedit-script") >/dev/null
2379 ret=$?
2381 if [ $ret -ne 0 ]; then
2382 echo "histedit operation failed" >&2
2383 test_done "$testroot" $ret
2384 return 1
2387 for f in alpha beta; do
2388 ls -l "$testroot/wt/$f" | grep -q ^-rw-------
2389 if [ $? -ne 0 ]; then
2390 echo "$f is not 0600 after histedi" >&2
2391 ls -l "$testroot/wt/$f" >&2
2392 test_done "$testroot" 1
2393 return 1
2395 done
2397 test_done "$testroot" 0
2400 test_histedit_mesg_filemode_change() {
2401 local testroot=`test_init histedit_mode_change`
2403 local orig_commit=`git_show_head $testroot/repo`
2404 local orig_author_time=`git_show_author_time $testroot/repo`
2406 chmod +x $testroot/repo/alpha
2407 git_commit $testroot/repo -m "set x bit on alpha"
2408 local old_commit1=`git_show_head $testroot/repo`
2409 local old_author_time1=`git_show_author_time $testroot/repo`
2411 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2412 ret=$?
2413 if [ $ret -ne 0 ]; then
2414 test_done "$testroot" "$ret"
2415 return 1
2418 if [ -x $testroot/wt/alpha ]; then
2419 echo "file alpha has unexpected executable bit" >&2
2420 test_done "$testroot" "1"
2421 return 1
2424 cat > $testroot/editor.sh <<EOF
2425 #!/bin/sh
2426 ed -s "\$1" <<-EOF
2427 ,s/ x bit / executable bit /
2429 EOF
2430 EOF
2432 chmod +x $testroot/editor.sh
2434 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2435 got histedit -m > $testroot/stdout)
2437 local new_commit1=`git_show_head $testroot/repo`
2438 local new_author_time1=`git_show_author_time $testroot/repo`
2440 local short_old_commit1=`trim_obj_id 28 $old_commit1`
2441 local short_new_commit1=`trim_obj_id 28 $new_commit1`
2443 echo "G alpha" > $testroot/stdout.expected
2444 echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \
2445 >> $testroot/stdout.expected
2446 echo "Switching work tree to refs/heads/master" \
2447 >> $testroot/stdout.expected
2449 cmp -s $testroot/stdout.expected $testroot/stdout
2450 ret=$?
2451 if [ $ret -ne 0 ]; then
2452 diff -u $testroot/stdout.expected $testroot/stdout
2453 test_done "$testroot" "$ret"
2454 return 1
2457 echo "alpha" > $testroot/content.expected
2458 cmp -s $testroot/content.expected $testroot/wt/alpha
2459 ret=$?
2460 if [ $ret -ne 0 ]; then
2461 diff -u $testroot/content.expected $testroot/wt/alpha
2462 test_done "$testroot" "$ret"
2463 return 1
2466 if [ ! -x $testroot/wt/alpha ]; then
2467 echo "file alpha lost its executable bit" >&2
2468 test_done "$testroot" "1"
2469 return 1
2472 (cd $testroot/wt && got status > $testroot/stdout)
2474 echo -n > $testroot/stdout.expected
2475 cmp -s $testroot/stdout.expected $testroot/stdout
2476 ret=$?
2477 if [ $ret -ne 0 ]; then
2478 diff -u $testroot/stdout.expected $testroot/stdout
2479 test_done "$testroot" "$ret"
2480 return 1
2483 (cd $testroot/wt && got log -l1 | grep ' set executable bit on alpha' \
2484 > $testroot/stdout)
2486 echo ' set executable bit on alpha' > $testroot/stdout.expected
2487 cmp -s $testroot/stdout.expected $testroot/stdout
2488 ret=$?
2489 if [ $ret -ne 0 ]; then
2490 diff -u $testroot/stdout.expected $testroot/stdout
2491 test_done "$testroot" "$ret"
2492 return 1
2495 test_done "$testroot" "$ret"
2498 test_histedit_drop_only() {
2499 local testroot=`test_init histedit_drop_only`
2501 local orig_commit=`git_show_head $testroot/repo`
2502 local drop="-> drop commit:"
2503 local dropmsg="commit changes to drop"
2505 echo "modified alpha on master" > $testroot/repo/alpha
2506 git -C $testroot/repo rm -q beta
2507 echo "new file on master" > $testroot/repo/epsilon/new
2508 git -C $testroot/repo add epsilon/new
2510 git_commit $testroot/repo -m "$dropmsg 1"
2511 local drop_commit1=`git_show_head $testroot/repo`
2513 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2515 git_commit $testroot/repo -m "$dropmsg 2"
2516 local drop_commit2=`git_show_head $testroot/repo`
2518 echo "modified delta on master" > $testroot/repo/gamma/delta
2520 git_commit $testroot/repo -m "$dropmsg 3"
2521 local drop_commit3=`git_show_head $testroot/repo`
2523 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2524 ret=$?
2525 if [ $ret -ne 0 ]; then
2526 test_done "$testroot" "$ret"
2527 return 1
2530 (cd $testroot/wt && got histedit -d > $testroot/stdout)
2531 local new_commit1=`git_show_head $testroot/repo`
2533 local short_commit1=`trim_obj_id 28 $drop_commit1`
2534 local short_commit2=`trim_obj_id 28 $drop_commit2`
2535 local short_commit3=`trim_obj_id 28 $drop_commit3`
2537 echo "$short_commit1 $drop $dropmsg 1" > $testroot/stdout.expected
2538 echo "$short_commit2 $drop $dropmsg 2" >> $testroot/stdout.expected
2539 echo "$short_commit3 $drop $dropmsg 3" >> $testroot/stdout.expected
2540 echo "Switching work tree to refs/heads/master" \
2541 >> $testroot/stdout.expected
2543 cmp -s $testroot/stdout.expected $testroot/stdout
2544 ret=$?
2545 if [ $ret -ne 0 ]; then
2546 diff -u $testroot/stdout.expected $testroot/stdout
2547 test_done "$testroot" "$ret"
2548 return 1
2551 echo "alpha" > $testroot/content.expected
2552 cat $testroot/wt/alpha > $testroot/content
2553 cmp -s $testroot/content.expected $testroot/content
2554 ret=$?
2555 if [ $ret -ne 0 ]; then
2556 diff -u $testroot/content.expected $testroot/content
2557 test_done "$testroot" "$ret"
2558 return 1
2561 echo "zeta" > $testroot/content.expected
2562 cat $testroot/wt/epsilon/zeta > $testroot/content
2563 cmp -s $testroot/content.expected $testroot/content
2564 ret=$?
2565 if [ $ret -ne 0 ]; then
2566 diff -u $testroot/content.expected $testroot/content
2567 test_done "$testroot" "$ret"
2568 return 1
2571 echo "delta" > $testroot/content.expected
2572 cat $testroot/wt/gamma/delta > $testroot/content
2573 cmp -s $testroot/content.expected $testroot/content
2574 ret=$?
2575 if [ $ret -ne 0 ]; then
2576 diff -u $testroot/content.expected $testroot/content
2577 test_done "$testroot" "$ret"
2578 return 1
2581 if [ ! -e $testroot/wt/beta ]; then
2582 echo "removed file beta should be restored" >&2
2583 test_done "$testroot" "1"
2584 return 1
2587 if [ -e $testroot/wt/new ]; then
2588 echo "new file should no longer exist" >&2
2589 test_done "$testroot" "$ret"
2590 return 1
2593 (cd $testroot/wt && got status > $testroot/stdout)
2595 echo -n > $testroot/stdout.expected
2596 cmp -s $testroot/stdout.expected $testroot/stdout
2597 ret=$?
2598 if [ $ret -ne 0 ]; then
2599 diff -u $testroot/stdout.expected $testroot/stdout
2600 test_done "$testroot" "$ret"
2601 return 1
2604 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2605 echo "commit $orig_commit (master)" > $testroot/stdout.expected
2606 cmp -s $testroot/stdout.expected $testroot/stdout
2607 ret=$?
2608 if [ $ret -ne 0 ]; then
2609 diff -u $testroot/stdout.expected $testroot/stdout
2611 test_done "$testroot" "$ret"
2614 test_parseargs "$@"
2615 run_test test_histedit_no_op
2616 run_test test_histedit_swap
2617 run_test test_histedit_drop
2618 run_test test_histedit_fold
2619 run_test test_histedit_edit
2620 run_test test_histedit_fold_last_commit
2621 run_test test_histedit_missing_commit_pick
2622 run_test test_histedit_missing_commit_mesg
2623 run_test test_histedit_abort
2624 run_test test_histedit_path_prefix_drop
2625 run_test test_histedit_path_prefix_edit
2626 run_test test_histedit_outside_refs_heads
2627 run_test test_histedit_fold_last_commit_swap
2628 run_test test_histedit_split_commit
2629 run_test test_histedit_duplicate_commit_in_script
2630 run_test test_histedit_fold_add_delete
2631 run_test test_histedit_fold_edit_delete
2632 run_test test_histedit_fold_delete_add
2633 run_test test_histedit_fold_only
2634 run_test test_histedit_fold_only_empty_logmsg
2635 run_test test_histedit_edit_only
2636 run_test test_histedit_prepend_line
2637 run_test test_histedit_resets_committer
2638 run_test test_histedit_umask
2639 run_test test_histedit_mesg_filemode_change
2640 run_test test_histedit_drop_only