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 (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
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 +"%G-%m-%d"`
160 d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"`
161 d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
162 d_orig=`date -u -r $orig_author_time +"%G-%m-%d"`
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 (cd $testroot/repo && git rm -q beta)
242 echo "new file on master" > $testroot/repo/epsilon/new
243 (cd $testroot/repo && git 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 (cd $testroot/repo && git rm -q beta)
364 echo "new file on master" > $testroot/repo/epsilon/new
365 (cd $testroot/repo && git 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 (cd $testroot/repo && git rm -q beta)
474 echo "new file on master" > $testroot/repo/epsilon/new
475 (cd $testroot/repo && git 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 echo "fold $old_commit1" > $testroot/histedit-script
495 echo "drop $old_commit2" >> $testroot/histedit-script
496 echo "pick $old_commit3" >> $testroot/histedit-script
497 echo "mesg committing folded changes" >> $testroot/histedit-script
499 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
500 > $testroot/stdout)
502 local new_commit1=`git_show_parent_commit $testroot/repo`
503 local new_commit2=`git_show_head $testroot/repo`
505 local short_old_commit1=`trim_obj_id 28 $old_commit1`
506 local short_old_commit2=`trim_obj_id 28 $old_commit2`
507 local short_old_commit3=`trim_obj_id 28 $old_commit3`
508 local short_new_commit1=`trim_obj_id 28 $new_commit1`
509 local short_new_commit2=`trim_obj_id 28 $new_commit2`
511 echo "G alpha" > $testroot/stdout.expected
512 echo "D beta" >> $testroot/stdout.expected
513 echo "A epsilon/new" >> $testroot/stdout.expected
514 echo "$short_old_commit1 -> fold commit: committing changes" \
515 >> $testroot/stdout.expected
516 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
517 echo "drop commit: committing to zeta on master" \
518 >> $testroot/stdout.expected
519 echo "G gamma/delta" >> $testroot/stdout.expected
520 echo -n "$short_old_commit3 -> $short_new_commit2: " \
521 >> $testroot/stdout.expected
522 echo "committing folded changes" >> $testroot/stdout.expected
523 echo "Switching work tree to refs/heads/master" \
524 >> $testroot/stdout.expected
526 cmp -s $testroot/stdout.expected $testroot/stdout
527 ret=$?
528 if [ $ret -ne 0 ]; then
529 diff -u $testroot/stdout.expected $testroot/stdout
530 test_done "$testroot" "$ret"
531 return 1
532 fi
534 echo "modified alpha on master" > $testroot/content.expected
535 cat $testroot/wt/alpha > $testroot/content
536 cmp -s $testroot/content.expected $testroot/content
537 ret=$?
538 if [ $ret -ne 0 ]; then
539 diff -u $testroot/content.expected $testroot/content
540 test_done "$testroot" "$ret"
541 return 1
542 fi
544 if [ -e $testroot/wt/beta ]; then
545 echo "removed file beta still exists on disk" >&2
546 test_done "$testroot" "1"
547 return 1
548 fi
550 echo "new file on master" > $testroot/content.expected
551 cat $testroot/wt/epsilon/new > $testroot/content
552 cmp -s $testroot/content.expected $testroot/content
553 ret=$?
554 if [ $ret -ne 0 ]; then
555 diff -u $testroot/content.expected $testroot/content
556 test_done "$testroot" "$ret"
557 return 1
558 fi
560 (cd $testroot/wt && got status > $testroot/stdout)
562 echo -n > $testroot/stdout.expected
563 cmp -s $testroot/stdout.expected $testroot/stdout
564 ret=$?
565 if [ $ret -ne 0 ]; then
566 diff -u $testroot/stdout.expected $testroot/stdout
567 test_done "$testroot" "$ret"
568 return 1
569 fi
571 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
572 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
573 echo "commit $orig_commit" >> $testroot/stdout.expected
574 cmp -s $testroot/stdout.expected $testroot/stdout
575 ret=$?
576 if [ $ret -ne 0 ]; then
577 diff -u $testroot/stdout.expected $testroot/stdout
578 fi
579 test_done "$testroot" "$ret"
582 test_histedit_edit() {
583 local testroot=`test_init histedit_edit`
585 local orig_commit=`git_show_head $testroot/repo`
587 echo "modified alpha on master" > $testroot/repo/alpha
588 (cd $testroot/repo && git rm -q beta)
589 echo "new file on master" > $testroot/repo/epsilon/new
590 (cd $testroot/repo && git add epsilon/new)
591 git_commit $testroot/repo -m "committing changes"
592 local old_commit1=`git_show_head $testroot/repo`
594 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
595 git_commit $testroot/repo -m "committing to zeta on master"
596 local old_commit2=`git_show_head $testroot/repo`
598 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
599 ret=$?
600 if [ $ret -ne 0 ]; then
601 test_done "$testroot" "$ret"
602 return 1
603 fi
605 echo "edit $old_commit1" > $testroot/histedit-script
606 echo "mesg committing changes" >> $testroot/histedit-script
607 echo "pick $old_commit2" >> $testroot/histedit-script
609 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
610 > $testroot/stdout)
612 local short_old_commit1=`trim_obj_id 28 $old_commit1`
613 local short_old_commit2=`trim_obj_id 28 $old_commit2`
615 echo "G alpha" > $testroot/stdout.expected
616 echo "D beta" >> $testroot/stdout.expected
617 echo "A epsilon/new" >> $testroot/stdout.expected
618 echo "Stopping histedit for amending commit $old_commit1" \
619 >> $testroot/stdout.expected
620 cmp -s $testroot/stdout.expected $testroot/stdout
621 ret=$?
622 if [ $ret -ne 0 ]; then
623 diff -u $testroot/stdout.expected $testroot/stdout
624 test_done "$testroot" "$ret"
625 return 1
626 fi
628 echo "edited modified alpha on master" > $testroot/wt/alpha
630 # test interaction of 'got stage' and histedit -c
631 (cd $testroot/wt && got stage alpha > /dev/null)
632 (cd $testroot/wt && got histedit -c > $testroot/stdout \
633 2> $testroot/stderr)
634 ret=$?
635 if [ $ret -eq 0 ]; then
636 echo "histedit succeeded unexpectedly" >&2
637 test_done "$testroot" "1"
638 return 1
639 fi
640 echo -n "got: work tree contains files with staged changes; " \
641 > $testroot/stderr.expected
642 echo "these changes must be committed or unstaged first" \
643 >> $testroot/stderr.expected
644 cmp -s $testroot/stderr.expected $testroot/stderr
645 ret=$?
646 if [ $ret -ne 0 ]; then
647 diff -u $testroot/stderr.expected $testroot/stderr
648 test_done "$testroot" "$ret"
649 return 1
650 fi
652 (cd $testroot/wt && got unstage alpha > /dev/null)
653 (cd $testroot/wt && got histedit -c > $testroot/stdout)
655 local new_commit1=`git_show_parent_commit $testroot/repo`
656 local new_commit2=`git_show_head $testroot/repo`
658 local short_new_commit1=`trim_obj_id 28 $new_commit1`
659 local short_new_commit2=`trim_obj_id 28 $new_commit2`
661 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
662 > $testroot/stdout.expected
663 echo "G epsilon/zeta" >> $testroot/stdout.expected
664 echo -n "$short_old_commit2 -> $short_new_commit2: " \
665 >> $testroot/stdout.expected
666 echo "committing to zeta on master" >> $testroot/stdout.expected
667 echo "Switching work tree to refs/heads/master" \
668 >> $testroot/stdout.expected
670 cmp -s $testroot/stdout.expected $testroot/stdout
671 ret=$?
672 if [ $ret -ne 0 ]; then
673 diff -u $testroot/stdout.expected $testroot/stdout
674 test_done "$testroot" "$ret"
675 return 1
676 fi
678 echo "edited modified alpha on master" > $testroot/content.expected
679 cat $testroot/wt/alpha > $testroot/content
680 cmp -s $testroot/content.expected $testroot/content
681 ret=$?
682 if [ $ret -ne 0 ]; then
683 diff -u $testroot/content.expected $testroot/content
684 test_done "$testroot" "$ret"
685 return 1
686 fi
688 if [ -e $testroot/wt/beta ]; then
689 echo "removed file beta still exists on disk" >&2
690 test_done "$testroot" "1"
691 return 1
692 fi
694 echo "new file on master" > $testroot/content.expected
695 cat $testroot/wt/epsilon/new > $testroot/content
696 cmp -s $testroot/content.expected $testroot/content
697 ret=$?
698 if [ $ret -ne 0 ]; then
699 diff -u $testroot/content.expected $testroot/content
700 test_done "$testroot" "$ret"
701 return 1
702 fi
704 (cd $testroot/wt && got status > $testroot/stdout)
706 echo -n > $testroot/stdout.expected
707 cmp -s $testroot/stdout.expected $testroot/stdout
708 ret=$?
709 if [ $ret -ne 0 ]; then
710 diff -u $testroot/stdout.expected $testroot/stdout
711 test_done "$testroot" "$ret"
712 return 1
713 fi
715 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
716 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
717 echo "commit $new_commit1" >> $testroot/stdout.expected
718 echo "commit $orig_commit" >> $testroot/stdout.expected
719 cmp -s $testroot/stdout.expected $testroot/stdout
720 ret=$?
721 if [ $ret -ne 0 ]; then
722 diff -u $testroot/stdout.expected $testroot/stdout
723 fi
724 test_done "$testroot" "$ret"
727 test_histedit_fold_last_commit() {
728 local testroot=`test_init histedit_fold_last_commit`
730 local orig_commit=`git_show_head $testroot/repo`
732 echo "modified alpha on master" > $testroot/repo/alpha
733 (cd $testroot/repo && git rm -q beta)
734 echo "new file on master" > $testroot/repo/epsilon/new
735 (cd $testroot/repo && git add epsilon/new)
736 git_commit $testroot/repo -m "committing changes"
737 local old_commit1=`git_show_head $testroot/repo`
739 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
740 git_commit $testroot/repo -m "committing to zeta on master"
741 local old_commit2=`git_show_head $testroot/repo`
743 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
744 ret=$?
745 if [ $ret -ne 0 ]; then
746 test_done "$testroot" "$ret"
747 return 1
748 fi
750 echo "pick $old_commit1" > $testroot/histedit-script
751 echo "fold $old_commit2" >> $testroot/histedit-script
753 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
754 > $testroot/stdout 2> $testroot/stderr)
756 ret=$?
757 if [ $ret -eq 0 ]; then
758 echo "histedit succeeded unexpectedly" >&2
759 test_done "$testroot" "1"
760 return 1
761 fi
763 echo "got: last commit in histedit script cannot be folded" \
764 > $testroot/stderr.expected
766 cmp -s $testroot/stderr.expected $testroot/stderr
767 ret=$?
768 if [ $ret -ne 0 ]; then
769 diff -u $testroot/stderr.expected $testroot/stderr
770 fi
771 test_done "$testroot" "$ret"
774 test_histedit_missing_commit() {
775 local testroot=`test_init histedit_missing_commit`
777 local orig_commit=`git_show_head $testroot/repo`
779 echo "modified alpha on master" > $testroot/repo/alpha
780 (cd $testroot/repo && git rm -q beta)
781 echo "new file on master" > $testroot/repo/epsilon/new
782 (cd $testroot/repo && git add epsilon/new)
783 git_commit $testroot/repo -m "committing changes"
784 local old_commit1=`git_show_head $testroot/repo`
786 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
787 git_commit $testroot/repo -m "committing to zeta on master"
788 local old_commit2=`git_show_head $testroot/repo`
790 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
791 ret=$?
792 if [ $ret -ne 0 ]; then
793 test_done "$testroot" "$ret"
794 return 1
795 fi
797 echo "pick $old_commit1" > $testroot/histedit-script
798 echo "mesg committing changes" >> $testroot/histedit-script
800 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
801 > $testroot/stdout 2> $testroot/stderr)
803 ret=$?
804 if [ $ret -eq 0 ]; then
805 echo "histedit succeeded unexpectedly" >&2
806 test_done "$testroot" "1"
807 return 1
808 fi
810 echo "got: commit $old_commit2 missing from histedit script" \
811 > $testroot/stderr.expected
813 cmp -s $testroot/stderr.expected $testroot/stderr
814 ret=$?
815 if [ $ret -ne 0 ]; then
816 diff -u $testroot/stderr.expected $testroot/stderr
817 fi
818 test_done "$testroot" "$ret"
821 test_histedit_abort() {
822 local testroot=`test_init histedit_abort`
824 local orig_commit=`git_show_head $testroot/repo`
826 echo "modified alpha on master" > $testroot/repo/alpha
827 (cd $testroot/repo && git rm -q beta)
828 echo "new file on master" > $testroot/repo/epsilon/new
829 (cd $testroot/repo && git add epsilon/new)
830 git_commit $testroot/repo -m "committing changes"
831 local old_commit1=`git_show_head $testroot/repo`
833 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
834 git_commit $testroot/repo -m "committing to zeta on master"
835 local old_commit2=`git_show_head $testroot/repo`
837 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
838 ret=$?
839 if [ $ret -ne 0 ]; then
840 test_done "$testroot" "$ret"
841 return 1
842 fi
844 # unrelated unversioned file in work tree
845 touch $testroot/wt/unversioned-file
847 echo "edit $old_commit1" > $testroot/histedit-script
848 echo "mesg committing changes" >> $testroot/histedit-script
849 echo "pick $old_commit2" >> $testroot/histedit-script
851 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
852 > $testroot/stdout)
854 local short_old_commit1=`trim_obj_id 28 $old_commit1`
855 local short_old_commit2=`trim_obj_id 28 $old_commit2`
857 echo "G alpha" > $testroot/stdout.expected
858 echo "D beta" >> $testroot/stdout.expected
859 echo "A epsilon/new" >> $testroot/stdout.expected
860 echo "Stopping histedit for amending commit $old_commit1" \
861 >> $testroot/stdout.expected
862 cmp -s $testroot/stdout.expected $testroot/stdout
863 ret=$?
864 if [ $ret -ne 0 ]; then
865 diff -u $testroot/stdout.expected $testroot/stdout
866 test_done "$testroot" "$ret"
867 return 1
868 fi
870 echo "edited modified alpha on master" > $testroot/wt/alpha
872 (cd $testroot/wt && got histedit -a > $testroot/stdout)
874 local new_commit1=`git_show_parent_commit $testroot/repo`
875 local new_commit2=`git_show_head $testroot/repo`
877 echo "Switching work tree to refs/heads/master" \
878 > $testroot/stdout.expected
879 echo "R alpha" >> $testroot/stdout.expected
880 echo "R beta" >> $testroot/stdout.expected
881 echo "R epsilon/new" >> $testroot/stdout.expected
882 echo "Histedit of refs/heads/master aborted" \
883 >> $testroot/stdout.expected
885 cmp -s $testroot/stdout.expected $testroot/stdout
886 ret=$?
887 if [ $ret -ne 0 ]; then
888 diff -u $testroot/stdout.expected $testroot/stdout
889 test_done "$testroot" "$ret"
890 return 1
891 fi
893 for f in alpha beta; do
894 echo "$f" > $testroot/content.expected
895 cat $testroot/wt/$f > $testroot/content
896 cmp -s $testroot/content.expected $testroot/content
897 ret=$?
898 if [ $ret -ne 0 ]; then
899 diff -u $testroot/content.expected $testroot/content
900 test_done "$testroot" "$ret"
901 return 1
902 fi
903 done
905 if [ -e $testroot/wt/epsilon/new ]; then
906 echo "removed file new still exists on disk" >&2
907 test_done "$testroot" "1"
908 return 1
909 fi
911 (cd $testroot/wt && got status > $testroot/stdout)
913 echo "? unversioned-file" > $testroot/stdout.expected
914 cmp -s $testroot/stdout.expected $testroot/stdout
915 ret=$?
916 if [ $ret -ne 0 ]; then
917 diff -u $testroot/stdout.expected $testroot/stdout
918 test_done "$testroot" "$ret"
919 return 1
920 fi
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
927 ret=$?
928 if [ $ret -ne 0 ]; then
929 diff -u $testroot/stdout.expected $testroot/stdout
930 fi
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
944 ret=$?
945 if [ $ret -ne 0 ]; then
946 test_done "$testroot" "$ret"
947 return 1
948 fi
950 echo "drop $old_commit1" > $testroot/histedit-script
952 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
953 > $testroot/stdout 2> $testroot/stderr)
955 ret=$?
956 if [ $ret -eq 0 ]; then
957 echo "histedit succeeded unexpectedly" >&2
958 test_done "$testroot" "1"
959 return 1
960 fi
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
968 ret=$?
969 if [ $ret -ne 0 ]; then
970 diff -u $testroot/stderr.expected $testroot/stderr
971 test_done "$testroot" "$ret"
972 return 1
973 fi
975 rm -rf $testroot/wt
976 got checkout -c $orig_commit -p epsilon $testroot/repo \
977 $testroot/wt > /dev/null
978 ret=$?
979 if [ $ret -ne 0 ]; then
980 test_done "$testroot" "$ret"
981 return 1
982 fi
983 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
984 > $testroot/stdout)
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
995 ret=$?
996 if [ $ret -ne 0 ]; then
997 diff -u $testroot/stdout.expected $testroot/stdout
998 test_done "$testroot" "$ret"
999 return 1
1002 echo "zeta" > $testroot/content.expected
1003 cat $testroot/wt/zeta > $testroot/content
1004 cmp -s $testroot/content.expected $testroot/content
1005 ret=$?
1006 if [ $ret -ne 0 ]; then
1007 diff -u $testroot/content.expected $testroot/content
1008 test_done "$testroot" "$ret"
1009 return 1
1013 (cd $testroot/wt && got status > $testroot/stdout)
1015 echo -n > $testroot/stdout.expected
1016 cmp -s $testroot/stdout.expected $testroot/stdout
1017 ret=$?
1018 if [ $ret -ne 0 ]; then
1019 diff -u $testroot/stdout.expected $testroot/stdout
1020 test_done "$testroot" "$ret"
1021 return 1
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
1027 ret=$?
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
1047 ret=$?
1048 if [ $ret -ne 0 ]; then
1049 test_done "$testroot" "$ret"
1050 return 1
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)
1059 ret=$?
1060 if [ $ret -eq 0 ]; then
1061 echo "histedit succeeded unexpectedly" >&2
1062 test_done "$testroot" "1"
1063 return 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
1072 ret=$?
1073 if [ $ret -ne 0 ]; then
1074 diff -u $testroot/stderr.expected $testroot/stderr
1075 test_done "$testroot" "$ret"
1076 return 1
1079 rm -rf $testroot/wt
1080 got checkout -c $orig_commit -p epsilon $testroot/repo \
1081 $testroot/wt > /dev/null
1082 ret=$?
1083 if [ $ret -ne 0 ]; then
1084 test_done "$testroot" "$ret"
1085 return 1
1087 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1088 > $testroot/stdout)
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
1096 ret=$?
1097 if [ $ret -ne 0 ]; then
1098 diff -u $testroot/stdout.expected $testroot/stdout
1099 test_done "$testroot" "$ret"
1100 return 1
1103 echo "modified zeta" > $testroot/content.expected
1104 cat $testroot/wt/zeta > $testroot/content
1105 cmp -s $testroot/content.expected $testroot/content
1106 ret=$?
1107 if [ $ret -ne 0 ]; then
1108 diff -u $testroot/content.expected $testroot/content
1109 test_done "$testroot" "$ret"
1110 return 1
1113 (cd $testroot/wt && got status > $testroot/stdout)
1115 echo "M zeta"> $testroot/stdout.expected
1116 cmp -s $testroot/stdout.expected $testroot/stdout
1117 ret=$?
1118 if [ $ret -ne 0 ]; then
1119 diff -u $testroot/stdout.expected $testroot/stdout
1120 test_done "$testroot" "$ret"
1121 return 1
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
1136 ret=$?
1137 if [ $ret -ne 0 ]; then
1138 diff -u $testroot/stdout.expected $testroot/stdout
1139 test_done "$testroot" "$ret"
1140 return 1
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
1147 ret=$?
1148 if [ $ret -ne 0 ]; then
1149 diff -u $testroot/stdout.expected $testroot/stdout
1150 test_done "$testroot" "$ret"
1151 return 1
1154 got diff -r $testroot/repo $orig_commit $new_commit1 \
1155 > $testroot/diff
1156 ed -s $testroot/diff.expected <<-EOF
1157 ,s/$old_commit1/$new_commit1/
1159 EOF
1160 cmp -s $testroot/diff.expected $testroot/diff
1161 ret=$?
1162 if [ $ret -ne 0 ]; then
1163 diff -u $testroot/diff.expected $testroot/diff
1165 test_done "$testroot" "$ret"
1168 test_histedit_outside_refs_heads() {
1169 local testroot=`test_init histedit_outside_refs_heads`
1170 local commit1=`git_show_head $testroot/repo`
1172 got checkout $testroot/repo $testroot/wt > /dev/null
1173 ret=$?
1174 if [ $ret -ne 0 ]; then
1175 echo "got checkout failed unexpectedly"
1176 test_done "$testroot" "$ret"
1177 return 1
1180 echo "modified alpha" > $testroot/wt/alpha
1182 (cd $testroot/wt && got commit -m 'change alpha' \
1183 > $testroot/stdout 2> $testroot/stderr)
1184 ret=$?
1185 if [ $ret -ne 0 ]; then
1186 echo "got commit failed unexpectedly" >&2
1187 test_done "$testroot" "1"
1188 return 1
1190 local commit2=`git_show_head $testroot/repo`
1192 got ref -r $testroot/repo -c master refs/remotes/origin/master
1193 ret=$?
1194 if [ $ret -ne 0 ]; then
1195 echo "got ref failed unexpectedly" >&2
1196 test_done "$testroot" "1"
1197 return 1
1200 (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1201 ret=$?
1202 if [ $ret -ne 0 ]; then
1203 echo "got update failed unexpectedly"
1204 test_done "$testroot" "$ret"
1205 return 1
1208 echo "edit $commit2" > $testroot/histedit-script
1209 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1210 2> $testroot/stderr)
1212 echo -n "got: will not edit commit history of a branch outside the " \
1213 > $testroot/stderr.expected
1214 echo '"refs/heads/" reference namespace' \
1215 >> $testroot/stderr.expected
1216 cmp -s $testroot/stderr.expected $testroot/stderr
1217 ret=$?
1218 if [ $ret -ne 0 ]; then
1219 diff -u $testroot/stderr.expected $testroot/stderr
1221 test_done "$testroot" "$ret"
1224 test_histedit_fold_last_commit_swap() {
1225 local testroot=`test_init histedit_fold_last_commit_swap`
1227 local orig_commit=`git_show_head $testroot/repo`
1229 echo "modified alpha on master" > $testroot/repo/alpha
1230 (cd $testroot/repo && git rm -q beta)
1231 echo "new file on master" > $testroot/repo/epsilon/new
1232 (cd $testroot/repo && git add epsilon/new)
1233 git_commit $testroot/repo -m "committing changes"
1234 local old_commit1=`git_show_head $testroot/repo`
1236 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1237 git_commit $testroot/repo -m "committing to zeta on master"
1238 local old_commit2=`git_show_head $testroot/repo`
1240 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1241 ret=$?
1242 if [ $ret -ne 0 ]; then
1243 test_done "$testroot" "$ret"
1244 return 1
1247 # fold commit2 into commit1 (requires swapping commits)
1248 echo "fold $old_commit2" > $testroot/histedit-script
1249 echo "pick $old_commit1" >> $testroot/histedit-script
1250 echo "mesg committing folded changes" >> $testroot/histedit-script
1252 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1253 > $testroot/stdout 2> $testroot/stderr)
1255 ret=$?
1256 if [ $ret -ne 0 ]; then
1257 echo "histedit failed unexpectedly" >&2
1258 test_done "$testroot" "$ret"
1259 return 1
1262 local new_commit=`git_show_head $testroot/repo`
1264 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1265 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1266 local short_new_commit=`trim_obj_id 28 $new_commit`
1268 echo "G epsilon/zeta" >> $testroot/stdout.expected
1269 echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1270 >> $testroot/stdout.expected
1271 echo "on master" >> $testroot/stdout.expected
1272 echo "G alpha" >> $testroot/stdout.expected
1273 echo "D beta" >> $testroot/stdout.expected
1274 echo "A epsilon/new" >> $testroot/stdout.expected
1275 echo -n "$short_old_commit1 -> $short_new_commit: " \
1276 >> $testroot/stdout.expected
1277 echo "committing folded changes" >> $testroot/stdout.expected
1278 echo "Switching work tree to refs/heads/master" \
1279 >> $testroot/stdout.expected
1281 cmp -s $testroot/stdout.expected $testroot/stdout
1282 ret=$?
1283 if [ $ret -ne 0 ]; then
1284 diff -u $testroot/stdout.expected $testroot/stdout
1286 test_done "$testroot" "$ret"
1289 test_histedit_split_commit() {
1290 local testroot=`test_init histedit_split_commit`
1292 local orig_commit=`git_show_head $testroot/repo`
1294 echo "modified alpha on master" > $testroot/repo/alpha
1295 (cd $testroot/repo && git rm -q beta)
1296 echo "new file on master" > $testroot/repo/epsilon/new
1297 (cd $testroot/repo && git add epsilon/new)
1298 git_commit $testroot/repo -m "committing changes 1"
1299 local old_commit1=`git_show_head $testroot/repo`
1300 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1302 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1303 git_commit $testroot/repo -m "committing changes 2"
1304 local old_commit2=`git_show_head $testroot/repo`
1305 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1307 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1308 ret=$?
1309 if [ $ret -ne 0 ]; then
1310 test_done "$testroot" "$ret"
1311 return 1
1314 # split commit1 into commitA and commitB and commitC
1315 echo "e $old_commit1" > $testroot/histedit-script
1316 echo "p $old_commit2" >> $testroot/histedit-script
1318 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1319 > $testroot/stdout 2> $testroot/stderr)
1320 ret=$?
1321 if [ $ret -ne 0 ]; then
1322 echo "histedit failed unexpectedly:" >&2
1323 cat $testroot/stderr >&2
1324 test_done "$testroot" "$ret"
1325 return 1
1328 echo "G alpha" > $testroot/stdout.expected
1329 echo "D beta" >> $testroot/stdout.expected
1330 echo "A epsilon/new" >> $testroot/stdout.expected
1331 echo "Stopping histedit for amending commit $old_commit1" \
1332 >> $testroot/stdout.expected
1334 cmp -s $testroot/stdout.expected $testroot/stdout
1335 ret=$?
1336 if [ $ret -ne 0 ]; then
1337 diff -u $testroot/stdout.expected $testroot/stdout
1338 test_done "$testroot" "$ret"
1339 return 1
1342 (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1343 ret=$?
1344 if [ $ret -ne 0 ]; then
1345 echo "commit failed unexpectedly" >&2
1346 test_done "$testroot" "$ret"
1347 return 1
1350 (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1351 ret=$?
1352 if [ $ret -ne 0 ]; then
1353 echo "commit failed unexpectedly" >&2
1354 test_done "$testroot" "$ret"
1355 return 1
1358 (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1359 ret=$?
1360 if [ $ret -ne 0 ]; then
1361 echo "commit failed unexpectedly" >&2
1362 test_done "$testroot" "$ret"
1363 return 1
1366 (cd $testroot/wt && got histedit -c \
1367 > $testroot/stdout 2> $testroot/stderr)
1368 ret=$?
1369 if [ $ret -ne 0 ]; then
1370 echo "histedit failed unexpectedly:" >&2
1371 cat $testroot/stderr >&2
1372 test_done "$testroot" "$ret"
1373 return 1
1375 local new_commit2=`git_show_head $testroot/repo`
1376 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1378 echo "$short_old_commit1 -> no-op change: committing changes 1" \
1379 > $testroot/stdout.expected
1380 echo "G epsilon/zeta" >> $testroot/stdout.expected
1381 echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1382 >> $testroot/stdout.expected
1383 echo "Switching work tree to refs/heads/master" \
1384 >> $testroot/stdout.expected
1386 cmp -s $testroot/stdout.expected $testroot/stdout
1387 ret=$?
1388 if [ $ret -ne 0 ]; then
1389 diff -u $testroot/stdout.expected $testroot/stdout
1391 test_done "$testroot" "$ret"
1395 test_histedit_duplicate_commit_in_script() {
1396 local testroot=`test_init histedit_duplicate_commit_in_script`
1398 local orig_commit=`git_show_head $testroot/repo`
1400 echo "modified alpha on master" > $testroot/repo/alpha
1401 (cd $testroot/repo && git rm -q beta)
1402 echo "new file on master" > $testroot/repo/epsilon/new
1403 (cd $testroot/repo && git add epsilon/new)
1404 git_commit $testroot/repo -m "committing changes 1"
1405 local old_commit1=`git_show_head $testroot/repo`
1407 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1408 git_commit $testroot/repo -m "committing changes 2"
1409 local old_commit2=`git_show_head $testroot/repo`
1411 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1412 ret=$?
1413 if [ $ret -ne 0 ]; then
1414 test_done "$testroot" "$ret"
1415 return 1
1418 # This histedit script lists commit1 more than once
1419 echo "p $old_commit1" > $testroot/histedit-script
1420 echo "p $old_commit1" >> $testroot/histedit-script
1421 echo "p $old_commit2" >> $testroot/histedit-script
1423 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1424 > $testroot/stdout 2> $testroot/stderr)
1425 ret=$?
1426 if [ $ret -eq 0 ]; then
1427 echo "histedit succeeded unexpectedly:" >&2
1428 cat $testroot/stdout >&2
1429 test_done "$testroot" 1
1430 return 1
1433 echo -n "got: commit $old_commit1 is listed more than once " \
1434 > $testroot/stderr.expected
1435 echo "in histedit script" >> $testroot/stderr.expected
1437 cmp -s $testroot/stderr.expected $testroot/stderr
1438 ret=$?
1439 if [ $ret -ne 0 ]; then
1440 diff -u $testroot/stderr.expected $testroot/stderr
1442 test_done "$testroot" "$ret"
1446 # if a previous commit introduces a new file, and it is folded into a commit
1447 # that deletes the same file, the file still exists after the histedit
1448 test_histedit_fold_add_delete() {
1449 local testroot=`test_init histedit_fold_add_delete`
1451 local orig_commit=`git_show_head $testroot/repo`
1453 echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1454 (cd $testroot/repo && git add epsilon/psi)
1455 git_commit $testroot/repo -m "committing changes"
1456 local old_commit1=`git_show_head $testroot/repo`
1458 echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1459 git_commit $testroot/repo -m "editing psi"
1460 local old_commit2=`git_show_head $testroot/repo`
1462 (cd $testroot/repo && git rm -q epsilon/psi)
1463 git_commit $testroot/repo -m "removing psi"
1464 local old_commit3=`git_show_head $testroot/repo`
1466 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1467 ret=$?
1468 if [ $ret -ne 0 ]; then
1469 test_done "$testroot" "$ret"
1470 return 1
1473 echo "fold $old_commit1" > $testroot/histedit-script
1474 echo "fold $old_commit2" >> $testroot/histedit-script
1475 echo "pick $old_commit3" >> $testroot/histedit-script
1476 echo "mesg folded changes" >> $testroot/histedit-script
1478 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1479 > $testroot/stdout)
1481 local new_commit1=`git_show_head $testroot/repo`
1483 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1484 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1485 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1486 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1488 echo "A epsilon/psi" >> $testroot/stdout.expected
1489 echo "$short_old_commit1 -> fold commit: committing changes" \
1490 >> $testroot/stdout.expected
1491 echo "G epsilon/psi" >> $testroot/stdout.expected
1492 echo "$short_old_commit2 -> fold commit: editing psi" \
1493 >> $testroot/stdout.expected
1494 echo "D epsilon/psi" >> $testroot/stdout.expected
1495 echo "$short_old_commit3 -> no-op change: folded changes" \
1496 >> $testroot/stdout.expected
1497 echo "Switching work tree to refs/heads/master" \
1498 >> $testroot/stdout.expected
1500 cmp -s $testroot/stdout.expected $testroot/stdout
1501 ret=$?
1502 if [ $ret -ne 0 ]; then
1503 diff -u $testroot/stdout.expected $testroot/stdout
1504 test_done "$testroot" "$ret"
1505 return 1
1508 if [ -e $testroot/wt/epsilon/psi ]; then
1509 echo "removed file psi still exists on disk" >&2
1510 test_done "$testroot" "1"
1511 return 1
1514 (cd $testroot/wt && got status > $testroot/stdout)
1516 echo -n > $testroot/stdout.expected
1517 cmp -s $testroot/stdout.expected $testroot/stdout
1518 ret=$?
1519 if [ $ret -ne 0 ]; then
1520 diff -u $testroot/stdout.expected $testroot/stdout
1521 test_done "$testroot" "$ret"
1522 return 1
1525 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1526 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1527 cmp -s $testroot/stdout.expected $testroot/stdout
1528 ret=$?
1529 if [ $ret -ne 0 ]; then
1530 diff -u $testroot/stdout.expected $testroot/stdout
1531 test_done "$testroot" "$ret"
1532 return 1
1535 got tree -r $testroot/repo epsilon > $testroot/stdout
1536 echo "zeta" > $testroot/stdout.expected
1537 cmp -s $testroot/stdout.expected $testroot/stdout
1538 ret=$?
1539 if [ $ret -ne 0 ]; then
1540 diff -u $testroot/stdout.expected $testroot/stdout
1542 test_done "$testroot" "$ret"
1545 # if a previous commit edits a file, and it is folded into a commit
1546 # that deletes the same file, the file will be deleted by histedit
1547 test_histedit_fold_edit_delete() {
1548 local testroot=`test_init histedit_fold_edit_delete`
1550 local orig_commit=`git_show_head $testroot/repo`
1552 echo "modify alpha" > $testroot/repo/alpha
1553 (cd $testroot/repo && git add alpha)
1554 git_commit $testroot/repo -m "modified alpha"
1555 local old_commit1=`git_show_head $testroot/repo`
1557 git_rm $testroot/repo alpha
1558 git_commit $testroot/repo -m "deleted alpha"
1559 local old_commit2=`git_show_head $testroot/repo`
1561 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1562 ret=$?
1563 if [ $ret -ne 0 ]; then
1564 test_done "$testroot" "$ret"
1565 return 1
1568 echo "fold $old_commit1" > $testroot/histedit-script
1569 echo "pick $old_commit2" >> $testroot/histedit-script
1570 echo "mesg folded changes" >> $testroot/histedit-script
1572 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1573 > $testroot/stdout)
1575 local new_commit1=`git_show_head $testroot/repo`
1577 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1578 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1579 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1581 echo "G alpha" >> $testroot/stdout.expected
1582 echo "$short_old_commit1 -> fold commit: modified alpha" \
1583 >> $testroot/stdout.expected
1584 echo "D alpha" >> $testroot/stdout.expected
1585 echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1586 >> $testroot/stdout.expected
1587 echo "Switching work tree to refs/heads/master" \
1588 >> $testroot/stdout.expected
1590 cmp -s $testroot/stdout.expected $testroot/stdout
1591 ret=$?
1592 if [ $ret -ne 0 ]; then
1593 diff -u $testroot/stdout.expected $testroot/stdout
1594 test_done "$testroot" "$ret"
1595 return 1
1598 if [ -e $testroot/wt/alpha ]; then
1599 echo "removed file alpha still exists on disk" >&2
1600 test_done "$testroot" "1"
1601 return 1
1604 (cd $testroot/wt && got status > $testroot/stdout)
1606 echo -n > $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 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
1616 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1617 echo "commit $orig_commit" >> $testroot/stdout.expected
1618 cmp -s $testroot/stdout.expected $testroot/stdout
1619 ret=$?
1620 if [ $ret -ne 0 ]; then
1621 diff -u $testroot/stdout.expected $testroot/stdout
1624 test_done "$testroot" "$ret"
1627 test_histedit_fold_delete_add() {
1628 local testroot=`test_init histedit_fold_delete_add`
1630 local orig_commit=`git_show_head $testroot/repo`
1632 (cd $testroot/repo && git rm -q alpha)
1633 git_commit $testroot/repo -m "removing alpha"
1634 local old_commit1=`git_show_head $testroot/repo`
1636 echo "modified alpha" >$testroot/repo/alpha
1637 (cd $testroot/repo && git add alpha)
1638 git_commit $testroot/repo -m "add back modified alpha"
1639 local old_commit2=`git_show_head $testroot/repo`
1641 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1642 ret=$?
1643 if [ $ret -ne 0 ]; then
1644 test_done "$testroot" "$ret"
1645 return 1
1648 echo "fold $old_commit1" > $testroot/histedit-script
1649 echo "pick $old_commit2" >> $testroot/histedit-script
1650 echo "mesg folded changes" >> $testroot/histedit-script
1652 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1653 > $testroot/stdout)
1655 local new_commit1=`git_show_head $testroot/repo`
1657 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1658 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1659 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1661 echo "D alpha" > $testroot/stdout.expected
1662 echo "$short_old_commit1 -> fold commit: removing alpha" \
1663 >> $testroot/stdout.expected
1664 echo "A alpha" >> $testroot/stdout.expected
1665 echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1666 >> $testroot/stdout.expected
1667 echo "Switching work tree to refs/heads/master" \
1668 >> $testroot/stdout.expected
1670 cmp -s $testroot/stdout.expected $testroot/stdout
1671 ret=$?
1672 if [ $ret -ne 0 ]; then
1673 diff -u $testroot/stdout.expected $testroot/stdout
1674 test_done "$testroot" "$ret"
1675 return 1
1678 if [ ! -e $testroot/wt/alpha ]; then
1679 echo "file alpha is missing on disk" >&2
1680 test_done "$testroot" "1"
1681 return 1
1684 echo "modified alpha" > $testroot/content.expected
1685 cat $testroot/wt/alpha > $testroot/content
1686 cmp -s $testroot/content.expected $testroot/content
1687 ret=$?
1688 if [ $ret -ne 0 ]; then
1689 diff -u $testroot/content.expected $testroot/content
1690 test_done "$testroot" "$ret"
1691 return 1
1693 test_done "$testroot" "0"
1696 test_histedit_fold_only() {
1697 local testroot=`test_init histedit_fold_only`
1699 local orig_commit=`git_show_head $testroot/repo`
1701 echo "modified alpha on master" > $testroot/repo/alpha
1702 (cd $testroot/repo && git rm -q beta)
1703 echo "new file on master" > $testroot/repo/epsilon/new
1704 (cd $testroot/repo && git add epsilon/new)
1705 git_commit $testroot/repo -m "committing changes"
1706 local old_commit1=`git_show_head $testroot/repo`
1708 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1709 git_commit $testroot/repo -m "committing to zeta on master"
1710 local old_commit2=`git_show_head $testroot/repo`
1712 echo "modified delta on master" > $testroot/repo/gamma/delta
1713 git_commit $testroot/repo -m "committing to delta on master"
1714 local old_commit3=`git_show_head $testroot/repo`
1716 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1717 ret=$?
1718 if [ $ret -ne 0 ]; then
1719 test_done "$testroot" "$ret"
1720 return 1
1723 cat > $testroot/editor.sh <<EOF
1724 #!/bin/sh
1725 ed -s "\$1" <<-EOF
1726 ,s/.*/committing folded changes/
1728 EOF
1729 EOF
1730 chmod +x $testroot/editor.sh
1732 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1733 VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1735 local new_commit1=`git_show_head $testroot/repo`
1737 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1738 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1739 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1740 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1741 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1743 echo "G alpha" > $testroot/stdout.expected
1744 echo "D beta" >> $testroot/stdout.expected
1745 echo "A epsilon/new" >> $testroot/stdout.expected
1746 echo "$short_old_commit1 -> fold commit: committing changes" \
1747 >> $testroot/stdout.expected
1748 echo "G epsilon/zeta" >> $testroot/stdout.expected
1749 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1750 echo "fold commit: committing to zeta on master" \
1751 >> $testroot/stdout.expected
1752 echo "G gamma/delta" >> $testroot/stdout.expected
1753 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1754 >> $testroot/stdout.expected
1755 echo "committing folded changes" >> $testroot/stdout.expected
1756 echo "Switching work tree to refs/heads/master" \
1757 >> $testroot/stdout.expected
1759 cmp -s $testroot/stdout.expected $testroot/stdout
1760 ret=$?
1761 if [ $ret -ne 0 ]; then
1762 diff -u $testroot/stdout.expected $testroot/stdout
1763 test_done "$testroot" "$ret"
1764 return 1
1767 echo "modified alpha on master" > $testroot/content.expected
1768 cat $testroot/wt/alpha > $testroot/content
1769 cmp -s $testroot/content.expected $testroot/content
1770 ret=$?
1771 if [ $ret -ne 0 ]; then
1772 diff -u $testroot/content.expected $testroot/content
1773 test_done "$testroot" "$ret"
1774 return 1
1777 if [ -e $testroot/wt/beta ]; then
1778 echo "removed file beta still exists on disk" >&2
1779 test_done "$testroot" "1"
1780 return 1
1783 echo "new file on master" > $testroot/content.expected
1784 cat $testroot/wt/epsilon/new > $testroot/content
1785 cmp -s $testroot/content.expected $testroot/content
1786 ret=$?
1787 if [ $ret -ne 0 ]; then
1788 diff -u $testroot/content.expected $testroot/content
1789 test_done "$testroot" "$ret"
1790 return 1
1793 (cd $testroot/wt && got status > $testroot/stdout)
1795 echo -n > $testroot/stdout.expected
1796 cmp -s $testroot/stdout.expected $testroot/stdout
1797 ret=$?
1798 if [ $ret -ne 0 ]; then
1799 diff -u $testroot/stdout.expected $testroot/stdout
1800 test_done "$testroot" "$ret"
1801 return 1
1804 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1805 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1806 echo "commit $orig_commit" >> $testroot/stdout.expected
1807 cmp -s $testroot/stdout.expected $testroot/stdout
1808 ret=$?
1809 if [ $ret -ne 0 ]; then
1810 diff -u $testroot/stdout.expected $testroot/stdout
1812 test_done "$testroot" "$ret"
1815 test_histedit_fold_only_empty_logmsg() {
1816 local testroot=`test_init histedit_fold_only_empty_logmsg`
1818 local orig_commit=`git_show_head $testroot/repo`
1820 echo "modified alpha on master" > $testroot/repo/alpha
1821 (cd $testroot/repo && git rm -q beta)
1822 echo "new file on master" > $testroot/repo/epsilon/new
1823 (cd $testroot/repo && git add epsilon/new)
1824 git_commit $testroot/repo -m "committing changes"
1825 local old_commit1=`git_show_head $testroot/repo`
1827 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1828 git_commit $testroot/repo -m "committing to zeta on master"
1829 local old_commit2=`git_show_head $testroot/repo`
1831 echo "modified delta on master" > $testroot/repo/gamma/delta
1832 git_commit $testroot/repo -m "committing to delta on master"
1833 local old_commit3=`git_show_head $testroot/repo`
1835 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1836 ret=$?
1837 if [ $ret -ne 0 ]; then
1838 test_done "$testroot" "$ret"
1839 return 1
1842 cat > $testroot/editor.sh <<EOF
1843 #!/bin/sh
1844 ed -s "\$1" <<-EOF
1847 EOF
1848 EOF
1849 chmod +x $testroot/editor.sh
1851 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1852 VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1854 local new_commit1=`git_show_head $testroot/repo`
1856 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1857 local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1858 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1859 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1860 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1861 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1863 echo "G alpha" > $testroot/stdout.expected
1864 echo "D beta" >> $testroot/stdout.expected
1865 echo "A epsilon/new" >> $testroot/stdout.expected
1866 echo "$short_old_commit1 -> fold commit: committing changes" \
1867 >> $testroot/stdout.expected
1868 echo "G epsilon/zeta" >> $testroot/stdout.expected
1869 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1870 echo "fold commit: committing to zeta on master" \
1871 >> $testroot/stdout.expected
1872 echo "G gamma/delta" >> $testroot/stdout.expected
1873 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1874 >> $testroot/stdout.expected
1875 echo "# log message of folded commit $very_short_old_commit1" \
1876 >> $testroot/stdout.expected
1877 echo "Switching work tree to refs/heads/master" \
1878 >> $testroot/stdout.expected
1880 cmp -s $testroot/stdout.expected $testroot/stdout
1881 ret=$?
1882 if [ $ret -ne 0 ]; then
1883 diff -u $testroot/stdout.expected $testroot/stdout
1884 test_done "$testroot" "$ret"
1885 return 1
1888 echo "modified alpha on master" > $testroot/content.expected
1889 cat $testroot/wt/alpha > $testroot/content
1890 cmp -s $testroot/content.expected $testroot/content
1891 ret=$?
1892 if [ $ret -ne 0 ]; then
1893 diff -u $testroot/content.expected $testroot/content
1894 test_done "$testroot" "$ret"
1895 return 1
1898 if [ -e $testroot/wt/beta ]; then
1899 echo "removed file beta still exists on disk" >&2
1900 test_done "$testroot" "1"
1901 return 1
1904 echo "new file on master" > $testroot/content.expected
1905 cat $testroot/wt/epsilon/new > $testroot/content
1906 cmp -s $testroot/content.expected $testroot/content
1907 ret=$?
1908 if [ $ret -ne 0 ]; then
1909 diff -u $testroot/content.expected $testroot/content
1910 test_done "$testroot" "$ret"
1911 return 1
1914 (cd $testroot/wt && got status > $testroot/stdout)
1916 echo -n > $testroot/stdout.expected
1917 cmp -s $testroot/stdout.expected $testroot/stdout
1918 ret=$?
1919 if [ $ret -ne 0 ]; then
1920 diff -u $testroot/stdout.expected $testroot/stdout
1921 test_done "$testroot" "$ret"
1922 return 1
1925 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1926 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1927 echo "commit $orig_commit" >> $testroot/stdout.expected
1928 cmp -s $testroot/stdout.expected $testroot/stdout
1929 ret=$?
1930 if [ $ret -ne 0 ]; then
1931 diff -u $testroot/stdout.expected $testroot/stdout
1933 test_done "$testroot" "$ret"
1936 test_histedit_edit_only() {
1937 local testroot=`test_init histedit_edit_only`
1939 local orig_commit=`git_show_head $testroot/repo`
1941 echo "modified alpha on master" > $testroot/repo/alpha
1942 (cd $testroot/repo && git rm -q beta)
1943 echo "new file on master" > $testroot/repo/epsilon/new
1944 (cd $testroot/repo && git add epsilon/new)
1945 git_commit $testroot/repo -m "committing changes"
1946 local old_commit1=`git_show_head $testroot/repo`
1948 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1949 git_commit $testroot/repo -m "committing to zeta on master"
1950 local old_commit2=`git_show_head $testroot/repo`
1952 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1953 ret=$?
1954 if [ $ret -ne 0 ]; then
1955 test_done "$testroot" "$ret"
1956 return 1
1959 (cd $testroot/wt && got histedit -e > $testroot/stdout)
1961 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1962 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1964 echo "G alpha" > $testroot/stdout.expected
1965 echo "D beta" >> $testroot/stdout.expected
1966 echo "A epsilon/new" >> $testroot/stdout.expected
1967 echo "Stopping histedit for amending commit $old_commit1" \
1968 >> $testroot/stdout.expected
1969 cmp -s $testroot/stdout.expected $testroot/stdout
1970 ret=$?
1971 if [ $ret -ne 0 ]; then
1972 diff -u $testroot/stdout.expected $testroot/stdout
1973 test_done "$testroot" "$ret"
1974 return 1
1977 echo "edited modified alpha on master" > $testroot/wt/alpha
1979 cat > $testroot/editor.sh <<EOF
1980 #!/bin/sh
1981 ed -s "\$1" <<-EOF
1982 ,s/.*/committing edited changes 1/
1984 EOF
1985 EOF
1986 chmod +x $testroot/editor.sh
1988 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1989 VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
1991 local new_commit1=$(cd $testroot/wt && got info | \
1992 grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1993 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1995 echo -n "$short_old_commit1 -> $short_new_commit1: " \
1996 > $testroot/stdout.expected
1997 echo "committing edited changes 1" >> $testroot/stdout.expected
1998 echo "G epsilon/zeta" >> $testroot/stdout.expected
1999 echo "Stopping histedit for amending commit $old_commit2" \
2000 >> $testroot/stdout.expected
2001 cmp -s $testroot/stdout.expected $testroot/stdout
2002 ret=$?
2003 if [ $ret -ne 0 ]; then
2004 diff -u $testroot/stdout.expected $testroot/stdout
2005 test_done "$testroot" "$ret"
2006 return 1
2009 echo "edited zeta on master" > $testroot/wt/epsilon/zeta
2011 cat > $testroot/editor.sh <<EOF
2012 #!/bin/sh
2013 ed -s "\$1" <<-EOF
2014 ,s/.*/committing edited changes 2/
2016 EOF
2017 EOF
2018 chmod +x $testroot/editor.sh
2020 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2021 VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2023 local new_commit2=`git_show_head $testroot/repo`
2024 local short_new_commit2=`trim_obj_id 28 $new_commit2`
2026 echo -n "$short_old_commit2 -> $short_new_commit2: " \
2027 > $testroot/stdout.expected
2028 echo "committing edited changes 2" >> $testroot/stdout.expected
2029 echo "Switching work tree to refs/heads/master" \
2030 >> $testroot/stdout.expected
2032 cmp -s $testroot/stdout.expected $testroot/stdout
2033 ret=$?
2034 if [ $ret -ne 0 ]; then
2035 diff -u $testroot/stdout.expected $testroot/stdout
2036 test_done "$testroot" "$ret"
2037 return 1
2040 echo "edited modified alpha on master" > $testroot/content.expected
2041 cat $testroot/wt/alpha > $testroot/content
2042 cmp -s $testroot/content.expected $testroot/content
2043 ret=$?
2044 if [ $ret -ne 0 ]; then
2045 diff -u $testroot/content.expected $testroot/content
2046 test_done "$testroot" "$ret"
2047 return 1
2050 if [ -e $testroot/wt/beta ]; then
2051 echo "removed file beta still exists on disk" >&2
2052 test_done "$testroot" "1"
2053 return 1
2056 echo "new file on master" > $testroot/content.expected
2057 cat $testroot/wt/epsilon/new > $testroot/content
2058 cmp -s $testroot/content.expected $testroot/content
2059 ret=$?
2060 if [ $ret -ne 0 ]; then
2061 diff -u $testroot/content.expected $testroot/content
2062 test_done "$testroot" "$ret"
2063 return 1
2066 (cd $testroot/wt && got status > $testroot/stdout)
2068 echo -n > $testroot/stdout.expected
2069 cmp -s $testroot/stdout.expected $testroot/stdout
2070 ret=$?
2071 if [ $ret -ne 0 ]; then
2072 diff -u $testroot/stdout.expected $testroot/stdout
2073 test_done "$testroot" "$ret"
2074 return 1
2077 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
2078 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
2079 echo "commit $new_commit1" >> $testroot/stdout.expected
2080 echo "commit $orig_commit" >> $testroot/stdout.expected
2081 cmp -s $testroot/stdout.expected $testroot/stdout
2082 ret=$?
2083 if [ $ret -ne 0 ]; then
2084 diff -u $testroot/stdout.expected $testroot/stdout
2086 test_done "$testroot" "$ret"
2089 test_histedit_prepend_line() {
2090 local testroot=`test_init histedit_prepend_line`
2091 local orig_commit=`git_show_head $testroot/repo`
2093 got checkout $testroot/repo $testroot/wt > /dev/null
2095 ed -s "$testroot/wt/alpha" <<EOF
2097 first line
2100 EOF
2102 cp $testroot/wt/alpha $testroot/content.expected
2104 (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2105 alpha > /dev/null)
2106 ret=$?
2107 if [ "$?" != 0 ]; then
2108 echo "got commit failed unexpectedly" >&2
2109 test_done "$testroot" "$ret"
2110 return 1
2113 local top_commit=`git_show_head $testroot/repo`
2114 echo "pick $top_commit" > "$testroot/histedit-script"
2116 (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2117 ret=$?
2118 if [ "$?" != 0 ]; then
2119 echo "got update failed unexpectedly" >&2
2120 test_done "$testroot" "$ret"
2121 return 1
2124 (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
2125 > /dev/null)
2126 ret=$?
2127 if [ "$?" != 0 ]; then
2128 echo "got histedit failed unexpectedly" >&2
2129 test_done "$testroot" "$ret"
2130 return 1
2133 cp $testroot/wt/alpha $testroot/content
2134 cmp -s $testroot/content.expected $testroot/content
2135 ret=$?
2136 if [ $ret -ne 0 ]; then
2137 diff -u $testroot/content.expected $testroot/content
2138 test_done "$testroot" "$ret"
2139 return 1
2142 test_done "$testroot" $ret
2145 test_histedit_mesg_invalid() {
2146 local testroot=`test_init mesg_invalid`
2148 local orig_commit=`git_show_head $testroot/repo`
2150 echo "modified alpha on master" > $testroot/repo/alpha
2151 (cd $testroot/repo && git rm -q beta)
2152 echo "new file on master" > $testroot/repo/epsilon/new
2153 (cd $testroot/repo && git add epsilon/new)
2154 git_commit $testroot/repo -m 'committing changes'
2155 local old_commit1=`git_show_head $testroot/repo`
2157 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2158 git_commit $testroot/repo -m 'committing to zeto on master'
2159 local old_commit2=`git_show_head $testroot/repo`
2161 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2162 ret=$?
2163 if [ $ret -ne 0 ]; then
2164 test_done "$testroot" $ret
2165 return 1
2168 # try with a leading mesg
2170 echo "mesg something something" > $testroot/histedit-script
2171 echo "pick $old_commit1" >> $testroot/histedit-script
2172 echo "pick $old_commit2" >> $testroot/histedit-script
2174 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2175 > $testroot/stdout 2> $testroot/stderr)
2176 ret=$?
2177 if [ $ret -eq 0 ]; then
2178 echo "histedit succeeded unexpectedly" >&2
2179 test_done "$testroot" 1
2180 return 1
2183 echo "got: bad histedit command" > $testroot/stderr.expected
2184 cmp -s $testroot/stderr.expected $testroot/stderr
2185 ret=$?
2186 if [ $ret -ne 0 ]; then
2187 diff -u $testroot/stderr.expected $testroot/stderr
2188 test_done "$testroot" $ret
2189 return 1
2192 # try again with mesg -> mesg
2194 echo "pick $old_commit1" > $testroot/histedit-script
2195 echo "mesg something something" >> $testroot/histedit-script
2196 echo "mesg something something else" >> $testroot/histedit-script
2197 echo "pick $old_commit2" >> $testroot/histedit-script
2199 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2200 > $testroot/stdout 2> $testroot/stderr)
2201 ret=$?
2202 if [ $ret -eq 0 ]; then
2203 echo "histedit succeeded unexpectedly" >&2
2204 test_done "$testroot" 1
2205 return 1
2208 echo "got: bad histedit command" > $testroot/stderr.expected
2209 cmp -s $testroot/stderr.expected $testroot/stderr
2210 ret=$?
2211 if [ $ret -ne 0 ]; then
2212 diff -u $testroot/stderr.expected $testroot/stderr
2213 test_done "$testroot" $ret
2214 return 1
2217 # try again with drop -> mesg
2219 echo "drop $old_commit1" > $testroot/histedit-script
2220 echo "mesg something something" >> $testroot/histedit-script
2221 echo "pick $old_commit2" >> $testroot/histedit-script
2223 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2224 > $testroot/stdout 2> $testroot/stderr)
2225 ret=$?
2226 if [ $ret -eq 0 ]; then
2227 echo "histedit succeeded unexpectedly" >&2
2228 test_done "$testroot" 1
2229 return 1
2232 echo "got: bad histedit command" > $testroot/stderr.expected
2233 cmp -s $testroot/stderr.expected $testroot/stderr
2234 ret=$?
2235 if [ $ret -ne 0 ]; then
2236 diff -u $testroot/stderr.expected $testroot/stderr
2237 test_done "$testroot" $ret
2238 return 1
2241 # try again with fold -> mesg
2243 echo "fold $old_commit1" > $testroot/histedit-script
2244 echo "mesg something something" >> $testroot/histedit-script
2245 echo "pick $old_commit2" >> $testroot/histedit-script
2247 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2248 > $testroot/stdout 2> $testroot/stderr)
2249 ret=$?
2250 if [ $ret -eq 0 ]; then
2251 echo "histedit succeeded unexpectedly" >&2
2252 test_done "$testroot" 1
2253 return 1
2256 echo "got: bad histedit command" > $testroot/stderr.expected
2257 cmp -s $testroot/stderr.expected $testroot/stderr
2258 ret=$?
2259 if [ $ret -ne 0 ]; then
2260 diff -u $testroot/stderr.expected $testroot/stderr
2262 test_done "$testroot" $ret
2265 test_histedit_resets_committer() {
2266 local testroot=`test_init histedit_resets_committer`
2267 local orig_commit=`git_show_head $testroot/repo`
2268 local committer="Flan Luck <flan_luck@openbsd.org>"
2270 got checkout $testroot/repo $testroot/wt > /dev/null
2272 echo "modified alpha" > $testroot/wt/alpha
2274 (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2275 alpha > /dev/null)
2276 ret=$?
2277 if [ "$?" != 0 ]; then
2278 echo "got commit failed unexpectedly" >&2
2279 test_done "$testroot" "$ret"
2280 return 1
2283 local top_commit=`git_show_head $testroot/repo`
2284 echo "pick $top_commit" > "$testroot/histedit-script"
2286 (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2287 ret=$?
2288 if [ "$?" != 0 ]; then
2289 echo "got update failed unexpectedly" >&2
2290 test_done "$testroot" "$ret"
2291 return 1
2294 (cd $testroot/wt && env GOT_AUTHOR="$committer" \
2295 got histedit -F "$testroot/histedit-script" > /dev/null)
2296 ret=$?
2297 if [ "$?" != 0 ]; then
2298 echo "got histedit failed unexpectedly" >&2
2299 test_done "$testroot" "$ret"
2300 return 1
2302 local edited_commit=`git_show_head $testroot/repo`
2304 # Original commit only had one author
2305 (cd $testroot/repo && got log -l1 -c $top_commit | \
2306 egrep '^(from|via):' > $testroot/stdout)
2307 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2308 cmp -s $testroot/stdout.expected $testroot/stdout
2309 ret=$?
2310 if [ $ret -ne 0 ]; then
2311 diff -u $testroot/stdout.expected $testroot/stdout
2312 test_done "$testroot" "$ret"
2313 return 1
2316 # Edited commit should have new committer name added
2317 (cd $testroot/repo && got log -l1 -c $edited_commit | \
2318 egrep '^(from|via):' > $testroot/stdout)
2319 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2320 echo "via: $committer" >> $testroot/stdout.expected
2322 cmp -s $testroot/stdout.expected $testroot/stdout
2323 ret=$?
2324 if [ $ret -ne 0 ]; then
2325 diff -u $testroot/stdout.expected $testroot/stdout
2327 test_done "$testroot" "$ret"
2330 test_histedit_umask() {
2331 local testroot=`test_init histedit_umask`
2332 local orig_commit=`git_show_head "$testroot/repo"`
2334 got checkout "$testroot/repo" "$testroot/wt" >/dev/null
2336 echo "modified alpha" > $testroot/wt/alpha
2337 (cd "$testroot/wt" && got commit -m 'edit #1') >/dev/null
2338 local commit1=`git_show_head "$testroot/repo"`
2340 echo "modified again" > $testroot/wt/alpha
2341 (cd "$testroot/wt" && got commit -m 'edit #2') >/dev/null
2342 local commit2=`git_show_head "$testroot/repo"`
2344 echo "modified again!" > $testroot/wt/alpha
2345 echo "modify beta too!" > $testroot/wt/beta
2346 (cd "$testroot/wt" && got commit -m 'edit #3') >/dev/null
2347 local commit3=`git_show_head "$testroot/repo"`
2349 (cd "$testroot/wt" && got update -c "$orig_commit") >/dev/null
2350 ret=$?
2351 if [ $ret -ne 0 ]; then
2352 echo "update to $orig_commit failed!" >&2
2353 test_done "$testroot" 1
2354 return 1
2357 echo fold $commit1 >$testroot/histedit-script
2358 echo fold $commit2 >>$testroot/histedit-script
2359 echo pick $commit3 >>$testroot/histedit-script
2360 echo mesg folding changes >>$testroot/histedit-script
2362 # using a subshell to avoid clobbering global umask
2363 (umask 077 && cd "$testroot/wt" && \
2364 got histedit -F "$testroot/histedit-script") >/dev/null
2365 ret=$?
2367 if [ $ret -ne 0 ]; then
2368 echo "histedit operation failed" >&2
2369 test_done "$testroot" $ret
2370 return 1
2373 for f in alpha beta; do
2374 ls -l "$testroot/wt/$f" | grep -q ^-rw-------
2375 if [ $? -ne 0 ]; then
2376 echo "$f is not 0600 after histedi" >&2
2377 ls -l "$testroot/wt/$f" >&2
2378 test_done "$testroot" 1
2379 return 1
2381 done
2383 test_done "$testroot" 0
2386 test_histedit_mesg_filemode_change() {
2387 local testroot=`test_init histedit_mode_change`
2389 local orig_commit=`git_show_head $testroot/repo`
2390 local orig_author_time=`git_show_author_time $testroot/repo`
2392 chmod +x $testroot/repo/alpha
2393 git_commit $testroot/repo -m "set x bit on alpha"
2394 local old_commit1=`git_show_head $testroot/repo`
2395 local old_author_time1=`git_show_author_time $testroot/repo`
2397 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2398 ret=$?
2399 if [ $ret -ne 0 ]; then
2400 test_done "$testroot" "$ret"
2401 return 1
2404 if [ -x $testroot/wt/alpha ]; then
2405 echo "file alpha has unexpected executable bit" >&2
2406 test_done "$testroot" "1"
2407 return 1
2410 cat > $testroot/editor.sh <<EOF
2411 #!/bin/sh
2412 ed -s "\$1" <<-EOF
2413 ,s/ x bit / executable bit /
2415 EOF
2416 EOF
2418 chmod +x $testroot/editor.sh
2420 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2421 got histedit -m > $testroot/stdout)
2423 local new_commit1=`git_show_head $testroot/repo`
2424 local new_author_time1=`git_show_author_time $testroot/repo`
2426 local short_old_commit1=`trim_obj_id 28 $old_commit1`
2427 local short_new_commit1=`trim_obj_id 28 $new_commit1`
2429 echo "G alpha" > $testroot/stdout.expected
2430 echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \
2431 >> $testroot/stdout.expected
2432 echo "Switching work tree to refs/heads/master" \
2433 >> $testroot/stdout.expected
2435 cmp -s $testroot/stdout.expected $testroot/stdout
2436 ret=$?
2437 if [ $ret -ne 0 ]; then
2438 diff -u $testroot/stdout.expected $testroot/stdout
2439 test_done "$testroot" "$ret"
2440 return 1
2443 echo "alpha" > $testroot/content.expected
2444 cmp -s $testroot/content.expected $testroot/wt/alpha
2445 ret=$?
2446 if [ $ret -ne 0 ]; then
2447 diff -u $testroot/content.expected $testroot/wt/alpha
2448 test_done "$testroot" "$ret"
2449 return 1
2452 if [ ! -x $testroot/wt/alpha ]; then
2453 echo "file alpha lost its executable bit" >&2
2454 test_done "$testroot" "1"
2455 return 1
2458 (cd $testroot/wt && got status > $testroot/stdout)
2460 echo -n > $testroot/stdout.expected
2461 cmp -s $testroot/stdout.expected $testroot/stdout
2462 ret=$?
2463 if [ $ret -ne 0 ]; then
2464 diff -u $testroot/stdout.expected $testroot/stdout
2465 test_done "$testroot" "$ret"
2466 return 1
2469 (cd $testroot/wt && got log -l1 | grep ' set executable bit on alpha' \
2470 > $testroot/stdout)
2472 echo ' set executable bit on alpha' > $testroot/stdout.expected
2473 cmp -s $testroot/stdout.expected $testroot/stdout
2474 ret=$?
2475 if [ $ret -ne 0 ]; then
2476 diff -u $testroot/stdout.expected $testroot/stdout
2477 test_done "$testroot" "$ret"
2478 return 1
2481 test_done "$testroot" "$ret"
2484 test_histedit_drop_only() {
2485 local testroot=`test_init histedit_drop_only`
2487 local orig_commit=`git_show_head $testroot/repo`
2488 local drop="-> drop commit:"
2489 local dropmsg="commit changes to drop"
2491 echo "modified alpha on master" > $testroot/repo/alpha
2492 (cd $testroot/repo && git rm -q beta)
2493 echo "new file on master" > $testroot/repo/epsilon/new
2494 (cd $testroot/repo && git add epsilon/new)
2496 git_commit $testroot/repo -m "$dropmsg 1"
2497 local drop_commit1=`git_show_head $testroot/repo`
2499 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2501 git_commit $testroot/repo -m "$dropmsg 2"
2502 local drop_commit2=`git_show_head $testroot/repo`
2504 echo "modified delta on master" > $testroot/repo/gamma/delta
2506 git_commit $testroot/repo -m "$dropmsg 3"
2507 local drop_commit3=`git_show_head $testroot/repo`
2509 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2510 ret=$?
2511 if [ $ret -ne 0 ]; then
2512 test_done "$testroot" "$ret"
2513 return 1
2516 (cd $testroot/wt && got histedit -d > $testroot/stdout)
2517 local new_commit1=`git_show_head $testroot/repo`
2519 local short_commit1=`trim_obj_id 28 $drop_commit1`
2520 local short_commit2=`trim_obj_id 28 $drop_commit2`
2521 local short_commit3=`trim_obj_id 28 $drop_commit3`
2523 echo "$short_commit1 $drop $dropmsg 1" > $testroot/stdout.expected
2524 echo "$short_commit2 $drop $dropmsg 2" >> $testroot/stdout.expected
2525 echo "$short_commit3 $drop $dropmsg 3" >> $testroot/stdout.expected
2526 echo "Switching work tree to refs/heads/master" \
2527 >> $testroot/stdout.expected
2529 cmp -s $testroot/stdout.expected $testroot/stdout
2530 ret=$?
2531 if [ $ret -ne 0 ]; then
2532 diff -u $testroot/stdout.expected $testroot/stdout
2533 test_done "$testroot" "$ret"
2534 return 1
2537 echo "alpha" > $testroot/content.expected
2538 cat $testroot/wt/alpha > $testroot/content
2539 cmp -s $testroot/content.expected $testroot/content
2540 ret=$?
2541 if [ $ret -ne 0 ]; then
2542 diff -u $testroot/content.expected $testroot/content
2543 test_done "$testroot" "$ret"
2544 return 1
2547 echo "zeta" > $testroot/content.expected
2548 cat $testroot/wt/epsilon/zeta > $testroot/content
2549 cmp -s $testroot/content.expected $testroot/content
2550 ret=$?
2551 if [ $ret -ne 0 ]; then
2552 diff -u $testroot/content.expected $testroot/content
2553 test_done "$testroot" "$ret"
2554 return 1
2557 echo "delta" > $testroot/content.expected
2558 cat $testroot/wt/gamma/delta > $testroot/content
2559 cmp -s $testroot/content.expected $testroot/content
2560 ret=$?
2561 if [ $ret -ne 0 ]; then
2562 diff -u $testroot/content.expected $testroot/content
2563 test_done "$testroot" "$ret"
2564 return 1
2567 if [ ! -e $testroot/wt/beta ]; then
2568 echo "removed file beta should be restored" >&2
2569 test_done "$testroot" "1"
2570 return 1
2573 if [ -e $testroot/wt/new ]; then
2574 echo "new file should no longer exist" >&2
2575 test_done "$testroot" "$ret"
2576 return 1
2579 (cd $testroot/wt && got status > $testroot/stdout)
2581 echo -n > $testroot/stdout.expected
2582 cmp -s $testroot/stdout.expected $testroot/stdout
2583 ret=$?
2584 if [ $ret -ne 0 ]; then
2585 diff -u $testroot/stdout.expected $testroot/stdout
2586 test_done "$testroot" "$ret"
2587 return 1
2590 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2591 echo "commit $orig_commit (master)" > $testroot/stdout.expected
2592 cmp -s $testroot/stdout.expected $testroot/stdout
2593 ret=$?
2594 if [ $ret -ne 0 ]; then
2595 diff -u $testroot/stdout.expected $testroot/stdout
2597 test_done "$testroot" "$ret"
2600 test_parseargs "$@"
2601 run_test test_histedit_no_op
2602 run_test test_histedit_swap
2603 run_test test_histedit_drop
2604 run_test test_histedit_fold
2605 run_test test_histedit_edit
2606 run_test test_histedit_fold_last_commit
2607 run_test test_histedit_missing_commit
2608 run_test test_histedit_abort
2609 run_test test_histedit_path_prefix_drop
2610 run_test test_histedit_path_prefix_edit
2611 run_test test_histedit_outside_refs_heads
2612 run_test test_histedit_fold_last_commit_swap
2613 run_test test_histedit_split_commit
2614 run_test test_histedit_duplicate_commit_in_script
2615 run_test test_histedit_fold_add_delete
2616 run_test test_histedit_fold_edit_delete
2617 run_test test_histedit_fold_delete_add
2618 run_test test_histedit_fold_only
2619 run_test test_histedit_fold_only_empty_logmsg
2620 run_test test_histedit_edit_only
2621 run_test test_histedit_prepend_line
2622 run_test test_histedit_mesg_invalid
2623 run_test test_histedit_resets_committer
2624 run_test test_histedit_umask
2625 run_test test_histedit_mesg_filemode_change
2626 run_test test_histedit_drop_only