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 +"%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 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 echo "M zeta"> $testroot/stdout.expected
1190 cmp -s $testroot/stdout.expected $testroot/stdout
1191 ret=$?
1192 if [ $ret -ne 0 ]; then
1193 diff -u $testroot/stdout.expected $testroot/stdout
1194 test_done "$testroot" "$ret"
1195 return 1
1198 cat > $testroot/editor.sh <<EOF
1199 #!/bin/sh
1200 ed -s "\$1" <<-EOF
1201 ,s/.*/modified zeta/
1203 EOF
1204 EOF
1205 chmod +x $testroot/editor.sh
1207 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1208 VISUAL="$testroot/editor.sh" \
1209 got histedit -c > $testroot/stdout)
1211 local new_commit1=`git_show_head $testroot/repo`
1212 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1214 echo -n "$short_old_commit1 -> $short_new_commit1: " \
1215 > $testroot/stdout.expected
1216 echo "modified zeta" >> $testroot/stdout.expected
1217 echo "Switching work tree to refs/heads/master" \
1218 >> $testroot/stdout.expected
1220 cmp -s $testroot/stdout.expected $testroot/stdout
1221 ret=$?
1222 if [ $ret -ne 0 ]; then
1223 diff -u $testroot/stdout.expected $testroot/stdout
1224 test_done "$testroot" "$ret"
1225 return 1
1228 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1229 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1230 echo "commit $orig_commit" >> $testroot/stdout.expected
1231 cmp -s $testroot/stdout.expected $testroot/stdout
1232 ret=$?
1233 if [ $ret -ne 0 ]; then
1234 diff -u $testroot/stdout.expected $testroot/stdout
1235 test_done "$testroot" "$ret"
1236 return 1
1239 got diff -r $testroot/repo $orig_commit $new_commit1 \
1240 > $testroot/diff
1241 ed -s $testroot/diff.expected <<-EOF
1242 ,s/$old_commit1/$new_commit1/
1244 EOF
1245 cmp -s $testroot/diff.expected $testroot/diff
1246 ret=$?
1247 if [ $ret -ne 0 ]; then
1248 diff -u $testroot/diff.expected $testroot/diff
1250 test_done "$testroot" "$ret"
1253 test_histedit_outside_refs_heads() {
1254 local testroot=`test_init histedit_outside_refs_heads`
1255 local commit1=`git_show_head $testroot/repo`
1257 got checkout $testroot/repo $testroot/wt > /dev/null
1258 ret=$?
1259 if [ $ret -ne 0 ]; then
1260 echo "got checkout failed unexpectedly"
1261 test_done "$testroot" "$ret"
1262 return 1
1265 echo "modified alpha" > $testroot/wt/alpha
1267 (cd $testroot/wt && got commit -m 'change alpha' \
1268 > $testroot/stdout 2> $testroot/stderr)
1269 ret=$?
1270 if [ $ret -ne 0 ]; then
1271 echo "got commit failed unexpectedly" >&2
1272 test_done "$testroot" "1"
1273 return 1
1275 local commit2=`git_show_head $testroot/repo`
1277 got ref -r $testroot/repo -c master refs/remotes/origin/master
1278 ret=$?
1279 if [ $ret -ne 0 ]; then
1280 echo "got ref failed unexpectedly" >&2
1281 test_done "$testroot" "1"
1282 return 1
1285 (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1286 ret=$?
1287 if [ $ret -ne 0 ]; then
1288 echo "got update failed unexpectedly"
1289 test_done "$testroot" "$ret"
1290 return 1
1293 echo "edit $commit2" > $testroot/histedit-script
1294 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1295 2> $testroot/stderr)
1297 echo -n "got: will not edit commit history of a branch outside the " \
1298 > $testroot/stderr.expected
1299 echo '"refs/heads/" reference namespace' \
1300 >> $testroot/stderr.expected
1301 cmp -s $testroot/stderr.expected $testroot/stderr
1302 ret=$?
1303 if [ $ret -ne 0 ]; then
1304 diff -u $testroot/stderr.expected $testroot/stderr
1306 test_done "$testroot" "$ret"
1309 test_histedit_fold_last_commit_swap() {
1310 local testroot=`test_init histedit_fold_last_commit_swap`
1312 local orig_commit=`git_show_head $testroot/repo`
1314 echo "modified alpha on master" > $testroot/repo/alpha
1315 git -C $testroot/repo rm -q beta
1316 echo "new file on master" > $testroot/repo/epsilon/new
1317 git -C $testroot/repo add epsilon/new
1318 git_commit $testroot/repo -m "committing changes"
1319 local old_commit1=`git_show_head $testroot/repo`
1321 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1322 git_commit $testroot/repo -m "committing to zeta on master"
1323 local old_commit2=`git_show_head $testroot/repo`
1325 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1326 ret=$?
1327 if [ $ret -ne 0 ]; then
1328 test_done "$testroot" "$ret"
1329 return 1
1332 cat > $testroot/editor.sh <<EOF
1333 #!/bin/sh
1334 ed -s "\$1" <<-EOF
1335 ,s/.*/committing folded changes/
1337 EOF
1338 EOF
1339 chmod +x $testroot/editor.sh
1341 # fold commit2 into commit1 (requires swapping commits)
1342 echo "fold $old_commit2" > $testroot/histedit-script
1343 echo "mesg $old_commit1" >> $testroot/histedit-script
1345 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1346 VISUAL="$testroot/editor.sh" \
1347 got histedit -F $testroot/histedit-script > $testroot/stdout \
1348 2> $testroot/stderr)
1350 ret=$?
1351 if [ $ret -ne 0 ]; then
1352 echo "histedit failed unexpectedly" >&2
1353 test_done "$testroot" "$ret"
1354 return 1
1357 local new_commit=`git_show_head $testroot/repo`
1359 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1360 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1361 local short_new_commit=`trim_obj_id 28 $new_commit`
1363 echo "G epsilon/zeta" >> $testroot/stdout.expected
1364 echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1365 >> $testroot/stdout.expected
1366 echo "on master" >> $testroot/stdout.expected
1367 echo "G alpha" >> $testroot/stdout.expected
1368 echo "D beta" >> $testroot/stdout.expected
1369 echo "A epsilon/new" >> $testroot/stdout.expected
1370 echo -n "$short_old_commit1 -> $short_new_commit: " \
1371 >> $testroot/stdout.expected
1372 echo "committing folded changes" >> $testroot/stdout.expected
1373 echo "Switching work tree to refs/heads/master" \
1374 >> $testroot/stdout.expected
1376 cmp -s $testroot/stdout.expected $testroot/stdout
1377 ret=$?
1378 if [ $ret -ne 0 ]; then
1379 diff -u $testroot/stdout.expected $testroot/stdout
1381 test_done "$testroot" "$ret"
1384 test_histedit_split_commit() {
1385 local testroot=`test_init histedit_split_commit`
1387 local orig_commit=`git_show_head $testroot/repo`
1389 echo "modified alpha on master" > $testroot/repo/alpha
1390 git -C $testroot/repo rm -q beta
1391 echo "new file on master" > $testroot/repo/epsilon/new
1392 git -C $testroot/repo add epsilon/new
1393 git_commit $testroot/repo -m "committing changes 1"
1394 local old_commit1=`git_show_head $testroot/repo`
1395 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1397 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1398 git_commit $testroot/repo -m "committing changes 2"
1399 local old_commit2=`git_show_head $testroot/repo`
1400 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1402 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1403 ret=$?
1404 if [ $ret -ne 0 ]; then
1405 test_done "$testroot" "$ret"
1406 return 1
1409 # split commit1 into commitA and commitB and commitC
1410 echo "e $old_commit1" > $testroot/histedit-script
1411 echo "p $old_commit2" >> $testroot/histedit-script
1413 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1414 > $testroot/stdout 2> $testroot/stderr)
1415 ret=$?
1416 if [ $ret -ne 0 ]; then
1417 echo "histedit failed unexpectedly:" >&2
1418 cat $testroot/stderr >&2
1419 test_done "$testroot" "$ret"
1420 return 1
1423 echo "G alpha" > $testroot/stdout.expected
1424 echo "D beta" >> $testroot/stdout.expected
1425 echo "A epsilon/new" >> $testroot/stdout.expected
1426 echo "Stopping histedit for amending commit $old_commit1" \
1427 >> $testroot/stdout.expected
1429 cmp -s $testroot/stdout.expected $testroot/stdout
1430 ret=$?
1431 if [ $ret -ne 0 ]; then
1432 diff -u $testroot/stdout.expected $testroot/stdout
1433 test_done "$testroot" "$ret"
1434 return 1
1437 (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1438 ret=$?
1439 if [ $ret -ne 0 ]; then
1440 echo "commit failed unexpectedly" >&2
1441 test_done "$testroot" "$ret"
1442 return 1
1445 (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1446 ret=$?
1447 if [ $ret -ne 0 ]; then
1448 echo "commit failed unexpectedly" >&2
1449 test_done "$testroot" "$ret"
1450 return 1
1453 (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1454 ret=$?
1455 if [ $ret -ne 0 ]; then
1456 echo "commit failed unexpectedly" >&2
1457 test_done "$testroot" "$ret"
1458 return 1
1461 (cd $testroot/wt && got histedit -c \
1462 > $testroot/stdout 2> $testroot/stderr)
1463 ret=$?
1464 if [ $ret -ne 0 ]; then
1465 echo "histedit failed unexpectedly:" >&2
1466 cat $testroot/stderr >&2
1467 test_done "$testroot" "$ret"
1468 return 1
1470 local new_commit2=`git_show_head $testroot/repo`
1471 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1473 echo "$short_old_commit1 -> no-op change: committing changes 1" \
1474 > $testroot/stdout.expected
1475 echo "G epsilon/zeta" >> $testroot/stdout.expected
1476 echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1477 >> $testroot/stdout.expected
1478 echo "Switching work tree to refs/heads/master" \
1479 >> $testroot/stdout.expected
1481 cmp -s $testroot/stdout.expected $testroot/stdout
1482 ret=$?
1483 if [ $ret -ne 0 ]; then
1484 diff -u $testroot/stdout.expected $testroot/stdout
1486 test_done "$testroot" "$ret"
1490 test_histedit_duplicate_commit_in_script() {
1491 local testroot=`test_init histedit_duplicate_commit_in_script`
1493 local orig_commit=`git_show_head $testroot/repo`
1495 echo "modified alpha on master" > $testroot/repo/alpha
1496 git -C $testroot/repo rm -q beta
1497 echo "new file on master" > $testroot/repo/epsilon/new
1498 git -C $testroot/repo add epsilon/new
1499 git_commit $testroot/repo -m "committing changes 1"
1500 local old_commit1=`git_show_head $testroot/repo`
1502 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1503 git_commit $testroot/repo -m "committing changes 2"
1504 local old_commit2=`git_show_head $testroot/repo`
1506 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1507 ret=$?
1508 if [ $ret -ne 0 ]; then
1509 test_done "$testroot" "$ret"
1510 return 1
1513 # This histedit script lists commit1 more than once
1514 echo "p $old_commit1" > $testroot/histedit-script
1515 echo "p $old_commit1" >> $testroot/histedit-script
1516 echo "p $old_commit2" >> $testroot/histedit-script
1518 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1519 > $testroot/stdout 2> $testroot/stderr)
1520 ret=$?
1521 if [ $ret -eq 0 ]; then
1522 echo "histedit succeeded unexpectedly:" >&2
1523 cat $testroot/stdout >&2
1524 test_done "$testroot" 1
1525 return 1
1528 echo -n "got: commit $old_commit1 is listed more than once " \
1529 > $testroot/stderr.expected
1530 echo "in histedit script" >> $testroot/stderr.expected
1532 cmp -s $testroot/stderr.expected $testroot/stderr
1533 ret=$?
1534 if [ $ret -ne 0 ]; then
1535 diff -u $testroot/stderr.expected $testroot/stderr
1537 test_done "$testroot" "$ret"
1541 # if a previous commit introduces a new file, and it is folded into a commit
1542 # that deletes the same file, the file still exists after the histedit
1543 test_histedit_fold_add_delete() {
1544 local testroot=`test_init histedit_fold_add_delete`
1546 local orig_commit=`git_show_head $testroot/repo`
1548 echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1549 git -C $testroot/repo add epsilon/psi
1550 git_commit $testroot/repo -m "committing changes"
1551 local old_commit1=`git_show_head $testroot/repo`
1553 echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1554 git_commit $testroot/repo -m "editing psi"
1555 local old_commit2=`git_show_head $testroot/repo`
1557 git -C $testroot/repo rm -q epsilon/psi
1558 git_commit $testroot/repo -m "removing psi"
1559 local old_commit3=`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 cat > $testroot/editor.sh <<EOF
1569 #!/bin/sh
1570 ed -s "\$1" <<-EOF
1571 ,s/.*/folded changes/
1573 EOF
1574 EOF
1575 chmod +x $testroot/editor.sh
1577 echo "fold $old_commit1" > $testroot/histedit-script
1578 echo "fold $old_commit2" >> $testroot/histedit-script
1579 echo "pick $old_commit3" >> $testroot/histedit-script
1581 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1582 VISUAL="$testroot/editor.sh" \
1583 got histedit -F $testroot/histedit-script > $testroot/stdout)
1585 local new_commit1=`git_show_head $testroot/repo`
1587 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1588 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1589 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1590 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1592 echo "A epsilon/psi" >> $testroot/stdout.expected
1593 echo "$short_old_commit1 -> fold commit: committing changes" \
1594 >> $testroot/stdout.expected
1595 echo "G epsilon/psi" >> $testroot/stdout.expected
1596 echo "$short_old_commit2 -> fold commit: editing psi" \
1597 >> $testroot/stdout.expected
1598 echo "D epsilon/psi" >> $testroot/stdout.expected
1599 echo "$short_old_commit3 -> no-op change: folded changes" \
1600 >> $testroot/stdout.expected
1601 echo "Switching work tree to refs/heads/master" \
1602 >> $testroot/stdout.expected
1604 cmp -s $testroot/stdout.expected $testroot/stdout
1605 ret=$?
1606 if [ $ret -ne 0 ]; then
1607 diff -u $testroot/stdout.expected $testroot/stdout
1608 test_done "$testroot" "$ret"
1609 return 1
1612 if [ -e $testroot/wt/epsilon/psi ]; then
1613 echo "removed file psi still exists on disk" >&2
1614 test_done "$testroot" "1"
1615 return 1
1618 (cd $testroot/wt && got status > $testroot/stdout)
1620 echo -n > $testroot/stdout.expected
1621 cmp -s $testroot/stdout.expected $testroot/stdout
1622 ret=$?
1623 if [ $ret -ne 0 ]; then
1624 diff -u $testroot/stdout.expected $testroot/stdout
1625 test_done "$testroot" "$ret"
1626 return 1
1629 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1630 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1631 cmp -s $testroot/stdout.expected $testroot/stdout
1632 ret=$?
1633 if [ $ret -ne 0 ]; then
1634 diff -u $testroot/stdout.expected $testroot/stdout
1635 test_done "$testroot" "$ret"
1636 return 1
1639 got tree -r $testroot/repo epsilon > $testroot/stdout
1640 echo "zeta" > $testroot/stdout.expected
1641 cmp -s $testroot/stdout.expected $testroot/stdout
1642 ret=$?
1643 if [ $ret -ne 0 ]; then
1644 diff -u $testroot/stdout.expected $testroot/stdout
1646 test_done "$testroot" "$ret"
1649 # if a previous commit edits a file, and it is folded into a commit
1650 # that deletes the same file, the file will be deleted by histedit
1651 test_histedit_fold_edit_delete() {
1652 local testroot=`test_init histedit_fold_edit_delete`
1654 local orig_commit=`git_show_head $testroot/repo`
1656 echo "modify alpha" > $testroot/repo/alpha
1657 git -C $testroot/repo add alpha
1658 git_commit $testroot/repo -m "modified alpha"
1659 local old_commit1=`git_show_head $testroot/repo`
1661 git_rm $testroot/repo alpha
1662 git_commit $testroot/repo -m "deleted alpha"
1663 local old_commit2=`git_show_head $testroot/repo`
1665 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1666 ret=$?
1667 if [ $ret -ne 0 ]; then
1668 test_done "$testroot" "$ret"
1669 return 1
1672 cat > $testroot/editor.sh <<EOF
1673 #!/bin/sh
1674 ed -s "\$1" <<-EOF
1675 ,s/.*/folded changes/
1677 EOF
1678 EOF
1679 chmod +x $testroot/editor.sh
1681 echo "fold $old_commit1" > $testroot/histedit-script
1682 echo "pick $old_commit2" >> $testroot/histedit-script
1684 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1685 VISUAL="$testroot/editor.sh" \
1686 got histedit -F $testroot/histedit-script > $testroot/stdout)
1688 local new_commit1=`git_show_head $testroot/repo`
1690 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1691 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1692 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1694 echo "G alpha" >> $testroot/stdout.expected
1695 echo "$short_old_commit1 -> fold commit: modified alpha" \
1696 >> $testroot/stdout.expected
1697 echo "D alpha" >> $testroot/stdout.expected
1698 echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1699 >> $testroot/stdout.expected
1700 echo "Switching work tree to refs/heads/master" \
1701 >> $testroot/stdout.expected
1703 cmp -s $testroot/stdout.expected $testroot/stdout
1704 ret=$?
1705 if [ $ret -ne 0 ]; then
1706 diff -u $testroot/stdout.expected $testroot/stdout
1707 test_done "$testroot" "$ret"
1708 return 1
1711 if [ -e $testroot/wt/alpha ]; then
1712 echo "removed file alpha still exists on disk" >&2
1713 test_done "$testroot" "1"
1714 return 1
1717 (cd $testroot/wt && got status > $testroot/stdout)
1719 echo -n > $testroot/stdout.expected
1720 cmp -s $testroot/stdout.expected $testroot/stdout
1721 ret=$?
1722 if [ $ret -ne 0 ]; then
1723 diff -u $testroot/stdout.expected $testroot/stdout
1724 test_done "$testroot" "$ret"
1725 return 1
1728 (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
1729 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1730 echo "commit $orig_commit" >> $testroot/stdout.expected
1731 cmp -s $testroot/stdout.expected $testroot/stdout
1732 ret=$?
1733 if [ $ret -ne 0 ]; then
1734 diff -u $testroot/stdout.expected $testroot/stdout
1737 test_done "$testroot" "$ret"
1740 test_histedit_fold_delete_add() {
1741 local testroot=`test_init histedit_fold_delete_add`
1743 local orig_commit=`git_show_head $testroot/repo`
1745 git -C $testroot/repo rm -q alpha
1746 git_commit $testroot/repo -m "removing alpha"
1747 local old_commit1=`git_show_head $testroot/repo`
1749 echo "modified alpha" >$testroot/repo/alpha
1750 git -C $testroot/repo add alpha
1751 git_commit $testroot/repo -m "add back modified alpha"
1752 local old_commit2=`git_show_head $testroot/repo`
1754 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1755 ret=$?
1756 if [ $ret -ne 0 ]; then
1757 test_done "$testroot" "$ret"
1758 return 1
1761 cat > $testroot/editor.sh <<EOF
1762 #!/bin/sh
1763 ed -s "\$1" <<-EOF
1764 ,s/.*/folded changes/
1766 EOF
1767 EOF
1768 chmod +x $testroot/editor.sh
1770 echo "fold $old_commit1" > $testroot/histedit-script
1771 echo "pick $old_commit2" >> $testroot/histedit-script
1773 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1774 VISUAL="$testroot/editor.sh" \
1775 got histedit -F $testroot/histedit-script > $testroot/stdout)
1777 local new_commit1=`git_show_head $testroot/repo`
1779 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1780 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1781 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1783 echo "D alpha" > $testroot/stdout.expected
1784 echo "$short_old_commit1 -> fold commit: removing alpha" \
1785 >> $testroot/stdout.expected
1786 echo "A alpha" >> $testroot/stdout.expected
1787 echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1788 >> $testroot/stdout.expected
1789 echo "Switching work tree to refs/heads/master" \
1790 >> $testroot/stdout.expected
1792 cmp -s $testroot/stdout.expected $testroot/stdout
1793 ret=$?
1794 if [ $ret -ne 0 ]; then
1795 diff -u $testroot/stdout.expected $testroot/stdout
1796 test_done "$testroot" "$ret"
1797 return 1
1800 if [ ! -e $testroot/wt/alpha ]; then
1801 echo "file alpha is missing on disk" >&2
1802 test_done "$testroot" "1"
1803 return 1
1806 echo "modified alpha" > $testroot/content.expected
1807 cat $testroot/wt/alpha > $testroot/content
1808 cmp -s $testroot/content.expected $testroot/content
1809 ret=$?
1810 if [ $ret -ne 0 ]; then
1811 diff -u $testroot/content.expected $testroot/content
1812 test_done "$testroot" "$ret"
1813 return 1
1815 test_done "$testroot" "0"
1818 test_histedit_fold_only() {
1819 local testroot=`test_init histedit_fold_only`
1821 local orig_commit=`git_show_head $testroot/repo`
1823 echo "modified alpha on master" > $testroot/repo/alpha
1824 git -C $testroot/repo rm -q beta
1825 echo "new file on master" > $testroot/repo/epsilon/new
1826 git -C $testroot/repo add epsilon/new
1827 git_commit $testroot/repo -m "committing changes"
1828 local old_commit1=`git_show_head $testroot/repo`
1830 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1831 git_commit $testroot/repo -m "committing to zeta on master"
1832 local old_commit2=`git_show_head $testroot/repo`
1834 echo "modified delta on master" > $testroot/repo/gamma/delta
1835 git_commit $testroot/repo -m "committing to delta on master"
1836 local old_commit3=`git_show_head $testroot/repo`
1838 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1839 ret=$?
1840 if [ $ret -ne 0 ]; then
1841 test_done "$testroot" "$ret"
1842 return 1
1845 cat > $testroot/editor.sh <<EOF
1846 #!/bin/sh
1847 ed -s "\$1" <<-EOF
1848 ,s/.*/committing folded changes/
1850 EOF
1851 EOF
1852 chmod +x $testroot/editor.sh
1854 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1855 VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1857 local new_commit1=`git_show_head $testroot/repo`
1859 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1860 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1861 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1862 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1863 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1865 echo "G alpha" > $testroot/stdout.expected
1866 echo "D beta" >> $testroot/stdout.expected
1867 echo "A epsilon/new" >> $testroot/stdout.expected
1868 echo "$short_old_commit1 -> fold commit: committing changes" \
1869 >> $testroot/stdout.expected
1870 echo "G epsilon/zeta" >> $testroot/stdout.expected
1871 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1872 echo "fold commit: committing to zeta on master" \
1873 >> $testroot/stdout.expected
1874 echo "G gamma/delta" >> $testroot/stdout.expected
1875 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1876 >> $testroot/stdout.expected
1877 echo "committing folded changes" >> $testroot/stdout.expected
1878 echo "Switching work tree to refs/heads/master" \
1879 >> $testroot/stdout.expected
1881 cmp -s $testroot/stdout.expected $testroot/stdout
1882 ret=$?
1883 if [ $ret -ne 0 ]; then
1884 diff -u $testroot/stdout.expected $testroot/stdout
1885 test_done "$testroot" "$ret"
1886 return 1
1889 echo "modified alpha on master" > $testroot/content.expected
1890 cat $testroot/wt/alpha > $testroot/content
1891 cmp -s $testroot/content.expected $testroot/content
1892 ret=$?
1893 if [ $ret -ne 0 ]; then
1894 diff -u $testroot/content.expected $testroot/content
1895 test_done "$testroot" "$ret"
1896 return 1
1899 if [ -e $testroot/wt/beta ]; then
1900 echo "removed file beta still exists on disk" >&2
1901 test_done "$testroot" "1"
1902 return 1
1905 echo "new file on master" > $testroot/content.expected
1906 cat $testroot/wt/epsilon/new > $testroot/content
1907 cmp -s $testroot/content.expected $testroot/content
1908 ret=$?
1909 if [ $ret -ne 0 ]; then
1910 diff -u $testroot/content.expected $testroot/content
1911 test_done "$testroot" "$ret"
1912 return 1
1915 (cd $testroot/wt && got status > $testroot/stdout)
1917 echo -n > $testroot/stdout.expected
1918 cmp -s $testroot/stdout.expected $testroot/stdout
1919 ret=$?
1920 if [ $ret -ne 0 ]; then
1921 diff -u $testroot/stdout.expected $testroot/stdout
1922 test_done "$testroot" "$ret"
1923 return 1
1926 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1927 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1928 echo "commit $orig_commit" >> $testroot/stdout.expected
1929 cmp -s $testroot/stdout.expected $testroot/stdout
1930 ret=$?
1931 if [ $ret -ne 0 ]; then
1932 diff -u $testroot/stdout.expected $testroot/stdout
1934 test_done "$testroot" "$ret"
1937 test_histedit_fold_only_empty_logmsg() {
1938 local testroot=`test_init histedit_fold_only_empty_logmsg`
1940 local orig_commit=`git_show_head $testroot/repo`
1942 echo "modified alpha on master" > $testroot/repo/alpha
1943 git -C $testroot/repo rm -q beta
1944 echo "new file on master" > $testroot/repo/epsilon/new
1945 git -C $testroot/repo add epsilon/new
1946 git_commit $testroot/repo -m "committing changes"
1947 local old_commit1=`git_show_head $testroot/repo`
1949 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1950 git_commit $testroot/repo -m "committing to zeta on master"
1951 local old_commit2=`git_show_head $testroot/repo`
1953 echo "modified delta on master" > $testroot/repo/gamma/delta
1954 git_commit $testroot/repo -m "committing to delta on master"
1955 local old_commit3=`git_show_head $testroot/repo`
1957 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1958 ret=$?
1959 if [ $ret -ne 0 ]; then
1960 test_done "$testroot" "$ret"
1961 return 1
1964 cat > $testroot/editor.sh <<EOF
1965 #!/bin/sh
1966 ed -s "\$1" <<-EOF
1969 EOF
1970 EOF
1971 chmod +x $testroot/editor.sh
1973 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1974 VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1976 local new_commit1=`git_show_head $testroot/repo`
1978 local short_old_commit1=`trim_obj_id 28 $old_commit1`
1979 local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1980 local short_old_commit2=`trim_obj_id 28 $old_commit2`
1981 local short_old_commit3=`trim_obj_id 28 $old_commit3`
1982 local short_new_commit1=`trim_obj_id 28 $new_commit1`
1983 local short_new_commit2=`trim_obj_id 28 $new_commit2`
1985 echo "G alpha" > $testroot/stdout.expected
1986 echo "D beta" >> $testroot/stdout.expected
1987 echo "A epsilon/new" >> $testroot/stdout.expected
1988 echo "$short_old_commit1 -> fold commit: committing changes" \
1989 >> $testroot/stdout.expected
1990 echo "G epsilon/zeta" >> $testroot/stdout.expected
1991 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1992 echo "fold commit: committing to zeta on master" \
1993 >> $testroot/stdout.expected
1994 echo "G gamma/delta" >> $testroot/stdout.expected
1995 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1996 >> $testroot/stdout.expected
1997 echo "# log message of folded commit $very_short_old_commit1" \
1998 >> $testroot/stdout.expected
1999 echo "Switching work tree to refs/heads/master" \
2000 >> $testroot/stdout.expected
2002 cmp -s $testroot/stdout.expected $testroot/stdout
2003 ret=$?
2004 if [ $ret -ne 0 ]; then
2005 diff -u $testroot/stdout.expected $testroot/stdout
2006 test_done "$testroot" "$ret"
2007 return 1
2010 echo "modified alpha on master" > $testroot/content.expected
2011 cat $testroot/wt/alpha > $testroot/content
2012 cmp -s $testroot/content.expected $testroot/content
2013 ret=$?
2014 if [ $ret -ne 0 ]; then
2015 diff -u $testroot/content.expected $testroot/content
2016 test_done "$testroot" "$ret"
2017 return 1
2020 if [ -e $testroot/wt/beta ]; then
2021 echo "removed file beta still exists on disk" >&2
2022 test_done "$testroot" "1"
2023 return 1
2026 echo "new file on master" > $testroot/content.expected
2027 cat $testroot/wt/epsilon/new > $testroot/content
2028 cmp -s $testroot/content.expected $testroot/content
2029 ret=$?
2030 if [ $ret -ne 0 ]; then
2031 diff -u $testroot/content.expected $testroot/content
2032 test_done "$testroot" "$ret"
2033 return 1
2036 (cd $testroot/wt && got status > $testroot/stdout)
2038 echo -n > $testroot/stdout.expected
2039 cmp -s $testroot/stdout.expected $testroot/stdout
2040 ret=$?
2041 if [ $ret -ne 0 ]; then
2042 diff -u $testroot/stdout.expected $testroot/stdout
2043 test_done "$testroot" "$ret"
2044 return 1
2047 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2048 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
2049 echo "commit $orig_commit" >> $testroot/stdout.expected
2050 cmp -s $testroot/stdout.expected $testroot/stdout
2051 ret=$?
2052 if [ $ret -ne 0 ]; then
2053 diff -u $testroot/stdout.expected $testroot/stdout
2055 test_done "$testroot" "$ret"
2058 test_histedit_edit_only() {
2059 local testroot=`test_init histedit_edit_only`
2061 local orig_commit=`git_show_head $testroot/repo`
2063 echo "modified alpha on master" > $testroot/repo/alpha
2064 git -C $testroot/repo rm -q beta
2065 echo "new file on master" > $testroot/repo/epsilon/new
2066 git -C $testroot/repo add epsilon/new
2067 git_commit $testroot/repo -m "committing changes"
2068 local old_commit1=`git_show_head $testroot/repo`
2070 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2071 git_commit $testroot/repo -m "committing to zeta on master"
2072 local old_commit2=`git_show_head $testroot/repo`
2074 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2075 ret=$?
2076 if [ $ret -ne 0 ]; then
2077 test_done "$testroot" "$ret"
2078 return 1
2081 (cd $testroot/wt && got histedit -e > $testroot/stdout)
2083 local short_old_commit1=`trim_obj_id 28 $old_commit1`
2084 local short_old_commit2=`trim_obj_id 28 $old_commit2`
2086 echo "G alpha" > $testroot/stdout.expected
2087 echo "D beta" >> $testroot/stdout.expected
2088 echo "A epsilon/new" >> $testroot/stdout.expected
2089 echo "Stopping histedit for amending commit $old_commit1" \
2090 >> $testroot/stdout.expected
2091 cmp -s $testroot/stdout.expected $testroot/stdout
2092 ret=$?
2093 if [ $ret -ne 0 ]; then
2094 diff -u $testroot/stdout.expected $testroot/stdout
2095 test_done "$testroot" "$ret"
2096 return 1
2099 echo "edited modified alpha on master" > $testroot/wt/alpha
2101 cat > $testroot/editor.sh <<EOF
2102 #!/bin/sh
2103 ed -s "\$1" <<-EOF
2104 ,s/.*/committing edited changes 1/
2106 EOF
2107 EOF
2108 chmod +x $testroot/editor.sh
2110 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2111 VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2113 local new_commit1=$(cd $testroot/wt && got info | \
2114 grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
2115 local short_new_commit1=`trim_obj_id 28 $new_commit1`
2117 echo -n "$short_old_commit1 -> $short_new_commit1: " \
2118 > $testroot/stdout.expected
2119 echo "committing edited changes 1" >> $testroot/stdout.expected
2120 echo "G epsilon/zeta" >> $testroot/stdout.expected
2121 echo "Stopping histedit for amending commit $old_commit2" \
2122 >> $testroot/stdout.expected
2123 cmp -s $testroot/stdout.expected $testroot/stdout
2124 ret=$?
2125 if [ $ret -ne 0 ]; then
2126 diff -u $testroot/stdout.expected $testroot/stdout
2127 test_done "$testroot" "$ret"
2128 return 1
2131 echo "edited zeta on master" > $testroot/wt/epsilon/zeta
2133 cat > $testroot/editor.sh <<EOF
2134 #!/bin/sh
2135 ed -s "\$1" <<-EOF
2136 ,s/.*/committing edited changes 2/
2138 EOF
2139 EOF
2140 chmod +x $testroot/editor.sh
2142 (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2143 VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2145 local new_commit2=`git_show_head $testroot/repo`
2146 local short_new_commit2=`trim_obj_id 28 $new_commit2`
2148 echo -n "$short_old_commit2 -> $short_new_commit2: " \
2149 > $testroot/stdout.expected
2150 echo "committing edited changes 2" >> $testroot/stdout.expected
2151 echo "Switching work tree to refs/heads/master" \
2152 >> $testroot/stdout.expected
2154 cmp -s $testroot/stdout.expected $testroot/stdout
2155 ret=$?
2156 if [ $ret -ne 0 ]; then
2157 diff -u $testroot/stdout.expected $testroot/stdout
2158 test_done "$testroot" "$ret"
2159 return 1
2162 echo "edited modified alpha on master" > $testroot/content.expected
2163 cat $testroot/wt/alpha > $testroot/content
2164 cmp -s $testroot/content.expected $testroot/content
2165 ret=$?
2166 if [ $ret -ne 0 ]; then
2167 diff -u $testroot/content.expected $testroot/content
2168 test_done "$testroot" "$ret"
2169 return 1
2172 if [ -e $testroot/wt/beta ]; then
2173 echo "removed file beta still exists on disk" >&2
2174 test_done "$testroot" "1"
2175 return 1
2178 echo "new file on master" > $testroot/content.expected
2179 cat $testroot/wt/epsilon/new > $testroot/content
2180 cmp -s $testroot/content.expected $testroot/content
2181 ret=$?
2182 if [ $ret -ne 0 ]; then
2183 diff -u $testroot/content.expected $testroot/content
2184 test_done "$testroot" "$ret"
2185 return 1
2188 (cd $testroot/wt && got status > $testroot/stdout)
2190 echo -n > $testroot/stdout.expected
2191 cmp -s $testroot/stdout.expected $testroot/stdout
2192 ret=$?
2193 if [ $ret -ne 0 ]; then
2194 diff -u $testroot/stdout.expected $testroot/stdout
2195 test_done "$testroot" "$ret"
2196 return 1
2199 (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
2200 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
2201 echo "commit $new_commit1" >> $testroot/stdout.expected
2202 echo "commit $orig_commit" >> $testroot/stdout.expected
2203 cmp -s $testroot/stdout.expected $testroot/stdout
2204 ret=$?
2205 if [ $ret -ne 0 ]; then
2206 diff -u $testroot/stdout.expected $testroot/stdout
2208 test_done "$testroot" "$ret"
2211 test_histedit_prepend_line() {
2212 local testroot=`test_init histedit_prepend_line`
2213 local orig_commit=`git_show_head $testroot/repo`
2215 got checkout $testroot/repo $testroot/wt > /dev/null
2217 ed -s "$testroot/wt/alpha" <<EOF
2219 first line
2222 EOF
2224 cp $testroot/wt/alpha $testroot/content.expected
2226 (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2227 alpha > /dev/null)
2228 ret=$?
2229 if [ "$?" != 0 ]; then
2230 echo "got commit failed unexpectedly" >&2
2231 test_done "$testroot" "$ret"
2232 return 1
2235 local top_commit=`git_show_head $testroot/repo`
2236 echo "pick $top_commit" > "$testroot/histedit-script"
2238 (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2239 ret=$?
2240 if [ "$?" != 0 ]; then
2241 echo "got update failed unexpectedly" >&2
2242 test_done "$testroot" "$ret"
2243 return 1
2246 (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
2247 > /dev/null)
2248 ret=$?
2249 if [ "$?" != 0 ]; then
2250 echo "got histedit failed unexpectedly" >&2
2251 test_done "$testroot" "$ret"
2252 return 1
2255 cp $testroot/wt/alpha $testroot/content
2256 cmp -s $testroot/content.expected $testroot/content
2257 ret=$?
2258 if [ $ret -ne 0 ]; then
2259 diff -u $testroot/content.expected $testroot/content
2260 test_done "$testroot" "$ret"
2261 return 1
2264 test_done "$testroot" $ret
2267 test_histedit_resets_committer() {
2268 local testroot=`test_init histedit_resets_committer`
2269 local orig_commit=`git_show_head $testroot/repo`
2270 local committer="Flan Luck <flan_luck@openbsd.org>"
2272 got checkout $testroot/repo $testroot/wt > /dev/null
2274 echo "modified alpha" > $testroot/wt/alpha
2276 (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2277 alpha > /dev/null)
2278 ret=$?
2279 if [ "$?" != 0 ]; then
2280 echo "got commit failed unexpectedly" >&2
2281 test_done "$testroot" "$ret"
2282 return 1
2285 local top_commit=`git_show_head $testroot/repo`
2286 echo "pick $top_commit" > "$testroot/histedit-script"
2288 (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2289 ret=$?
2290 if [ "$?" != 0 ]; then
2291 echo "got update failed unexpectedly" >&2
2292 test_done "$testroot" "$ret"
2293 return 1
2296 (cd $testroot/wt && env GOT_AUTHOR="$committer" \
2297 got histedit -F "$testroot/histedit-script" > /dev/null)
2298 ret=$?
2299 if [ "$?" != 0 ]; then
2300 echo "got histedit failed unexpectedly" >&2
2301 test_done "$testroot" "$ret"
2302 return 1
2304 local edited_commit=`git_show_head $testroot/repo`
2306 # Original commit only had one author
2307 (cd $testroot/repo && got log -l1 -c $top_commit | \
2308 egrep '^(from|via):' > $testroot/stdout)
2309 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2310 cmp -s $testroot/stdout.expected $testroot/stdout
2311 ret=$?
2312 if [ $ret -ne 0 ]; then
2313 diff -u $testroot/stdout.expected $testroot/stdout
2314 test_done "$testroot" "$ret"
2315 return 1
2318 # Edited commit should have new committer name added
2319 (cd $testroot/repo && got log -l1 -c $edited_commit | \
2320 egrep '^(from|via):' > $testroot/stdout)
2321 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2322 echo "via: $committer" >> $testroot/stdout.expected
2324 cmp -s $testroot/stdout.expected $testroot/stdout
2325 ret=$?
2326 if [ $ret -ne 0 ]; then
2327 diff -u $testroot/stdout.expected $testroot/stdout
2329 test_done "$testroot" "$ret"
2332 test_histedit_umask() {
2333 local testroot=`test_init histedit_umask`
2334 local orig_commit=`git_show_head "$testroot/repo"`
2336 got checkout "$testroot/repo" "$testroot/wt" >/dev/null
2338 echo "modified alpha" > $testroot/wt/alpha
2339 (cd "$testroot/wt" && got commit -m 'edit #1') >/dev/null
2340 local commit1=`git_show_head "$testroot/repo"`
2342 echo "modified again" > $testroot/wt/alpha
2343 (cd "$testroot/wt" && got commit -m 'edit #2') >/dev/null
2344 local commit2=`git_show_head "$testroot/repo"`
2346 echo "modified again!" > $testroot/wt/alpha
2347 echo "modify beta too!" > $testroot/wt/beta
2348 (cd "$testroot/wt" && got commit -m 'edit #3') >/dev/null
2349 local commit3=`git_show_head "$testroot/repo"`
2351 (cd "$testroot/wt" && got update -c "$orig_commit") >/dev/null
2352 ret=$?
2353 if [ $ret -ne 0 ]; then
2354 echo "update to $orig_commit failed!" >&2
2355 test_done "$testroot" 1
2356 return 1
2359 cat > $testroot/editor.sh <<EOF
2360 #!/bin/sh
2361 ed -s "\$1" <<-EOF
2362 ,s/.*/folding changes/
2364 EOF
2365 EOF
2366 chmod +x $testroot/editor.sh
2368 echo fold $commit1 >$testroot/histedit-script
2369 echo fold $commit2 >>$testroot/histedit-script
2370 echo pick $commit3 >>$testroot/histedit-script
2372 # using a subshell to avoid clobbering global umask
2373 (umask 077 && cd "$testroot/wt" && \
2374 env EDITOR="$testroot/editor.sh" VISUAL="$testroot/editor.sh" \
2375 got histedit -F "$testroot/histedit-script") >/dev/null
2376 ret=$?
2378 if [ $ret -ne 0 ]; then
2379 echo "histedit operation failed" >&2
2380 test_done "$testroot" $ret
2381 return 1
2384 for f in alpha beta; do
2385 ls -l "$testroot/wt/$f" | grep -q ^-rw-------
2386 if [ $? -ne 0 ]; then
2387 echo "$f is not 0600 after histedi" >&2
2388 ls -l "$testroot/wt/$f" >&2
2389 test_done "$testroot" 1
2390 return 1
2392 done
2394 test_done "$testroot" 0
2397 test_histedit_mesg_filemode_change() {
2398 local testroot=`test_init histedit_mode_change`
2400 local orig_commit=`git_show_head $testroot/repo`
2401 local orig_author_time=`git_show_author_time $testroot/repo`
2403 chmod +x $testroot/repo/alpha
2404 git_commit $testroot/repo -m "set x bit on alpha"
2405 local old_commit1=`git_show_head $testroot/repo`
2406 local old_author_time1=`git_show_author_time $testroot/repo`
2408 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2409 ret=$?
2410 if [ $ret -ne 0 ]; then
2411 test_done "$testroot" "$ret"
2412 return 1
2415 if [ -x $testroot/wt/alpha ]; then
2416 echo "file alpha has unexpected executable bit" >&2
2417 test_done "$testroot" "1"
2418 return 1
2421 cat > $testroot/editor.sh <<EOF
2422 #!/bin/sh
2423 ed -s "\$1" <<-EOF
2424 ,s/ x bit / executable bit /
2426 EOF
2427 EOF
2429 chmod +x $testroot/editor.sh
2431 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2432 got histedit -m > $testroot/stdout)
2434 local new_commit1=`git_show_head $testroot/repo`
2435 local new_author_time1=`git_show_author_time $testroot/repo`
2437 local short_old_commit1=`trim_obj_id 28 $old_commit1`
2438 local short_new_commit1=`trim_obj_id 28 $new_commit1`
2440 echo "G alpha" > $testroot/stdout.expected
2441 echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \
2442 >> $testroot/stdout.expected
2443 echo "Switching work tree to refs/heads/master" \
2444 >> $testroot/stdout.expected
2446 cmp -s $testroot/stdout.expected $testroot/stdout
2447 ret=$?
2448 if [ $ret -ne 0 ]; then
2449 diff -u $testroot/stdout.expected $testroot/stdout
2450 test_done "$testroot" "$ret"
2451 return 1
2454 echo "alpha" > $testroot/content.expected
2455 cmp -s $testroot/content.expected $testroot/wt/alpha
2456 ret=$?
2457 if [ $ret -ne 0 ]; then
2458 diff -u $testroot/content.expected $testroot/wt/alpha
2459 test_done "$testroot" "$ret"
2460 return 1
2463 if [ ! -x $testroot/wt/alpha ]; then
2464 echo "file alpha lost its executable bit" >&2
2465 test_done "$testroot" "1"
2466 return 1
2469 (cd $testroot/wt && got status > $testroot/stdout)
2471 echo -n > $testroot/stdout.expected
2472 cmp -s $testroot/stdout.expected $testroot/stdout
2473 ret=$?
2474 if [ $ret -ne 0 ]; then
2475 diff -u $testroot/stdout.expected $testroot/stdout
2476 test_done "$testroot" "$ret"
2477 return 1
2480 (cd $testroot/wt && got log -l1 | grep ' set executable bit on alpha' \
2481 > $testroot/stdout)
2483 echo ' set executable bit on alpha' > $testroot/stdout.expected
2484 cmp -s $testroot/stdout.expected $testroot/stdout
2485 ret=$?
2486 if [ $ret -ne 0 ]; then
2487 diff -u $testroot/stdout.expected $testroot/stdout
2488 test_done "$testroot" "$ret"
2489 return 1
2492 test_done "$testroot" "$ret"
2495 test_histedit_drop_only() {
2496 local testroot=`test_init histedit_drop_only`
2498 local orig_commit=`git_show_head $testroot/repo`
2499 local drop="-> drop commit:"
2500 local dropmsg="commit changes to drop"
2502 echo "modified alpha on master" > $testroot/repo/alpha
2503 git -C $testroot/repo rm -q beta
2504 echo "new file on master" > $testroot/repo/epsilon/new
2505 git -C $testroot/repo add epsilon/new
2507 git_commit $testroot/repo -m "$dropmsg 1"
2508 local drop_commit1=`git_show_head $testroot/repo`
2510 echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2512 git_commit $testroot/repo -m "$dropmsg 2"
2513 local drop_commit2=`git_show_head $testroot/repo`
2515 echo "modified delta on master" > $testroot/repo/gamma/delta
2517 git_commit $testroot/repo -m "$dropmsg 3"
2518 local drop_commit3=`git_show_head $testroot/repo`
2520 got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2521 ret=$?
2522 if [ $ret -ne 0 ]; then
2523 test_done "$testroot" "$ret"
2524 return 1
2527 (cd $testroot/wt && got histedit -d > $testroot/stdout)
2528 local new_commit1=`git_show_head $testroot/repo`
2530 local short_commit1=`trim_obj_id 28 $drop_commit1`
2531 local short_commit2=`trim_obj_id 28 $drop_commit2`
2532 local short_commit3=`trim_obj_id 28 $drop_commit3`
2534 echo "$short_commit1 $drop $dropmsg 1" > $testroot/stdout.expected
2535 echo "$short_commit2 $drop $dropmsg 2" >> $testroot/stdout.expected
2536 echo "$short_commit3 $drop $dropmsg 3" >> $testroot/stdout.expected
2537 echo "Switching work tree to refs/heads/master" \
2538 >> $testroot/stdout.expected
2540 cmp -s $testroot/stdout.expected $testroot/stdout
2541 ret=$?
2542 if [ $ret -ne 0 ]; then
2543 diff -u $testroot/stdout.expected $testroot/stdout
2544 test_done "$testroot" "$ret"
2545 return 1
2548 echo "alpha" > $testroot/content.expected
2549 cat $testroot/wt/alpha > $testroot/content
2550 cmp -s $testroot/content.expected $testroot/content
2551 ret=$?
2552 if [ $ret -ne 0 ]; then
2553 diff -u $testroot/content.expected $testroot/content
2554 test_done "$testroot" "$ret"
2555 return 1
2558 echo "zeta" > $testroot/content.expected
2559 cat $testroot/wt/epsilon/zeta > $testroot/content
2560 cmp -s $testroot/content.expected $testroot/content
2561 ret=$?
2562 if [ $ret -ne 0 ]; then
2563 diff -u $testroot/content.expected $testroot/content
2564 test_done "$testroot" "$ret"
2565 return 1
2568 echo "delta" > $testroot/content.expected
2569 cat $testroot/wt/gamma/delta > $testroot/content
2570 cmp -s $testroot/content.expected $testroot/content
2571 ret=$?
2572 if [ $ret -ne 0 ]; then
2573 diff -u $testroot/content.expected $testroot/content
2574 test_done "$testroot" "$ret"
2575 return 1
2578 if [ ! -e $testroot/wt/beta ]; then
2579 echo "removed file beta should be restored" >&2
2580 test_done "$testroot" "1"
2581 return 1
2584 if [ -e $testroot/wt/new ]; then
2585 echo "new file should no longer exist" >&2
2586 test_done "$testroot" "$ret"
2587 return 1
2590 (cd $testroot/wt && got status > $testroot/stdout)
2592 echo -n > $testroot/stdout.expected
2593 cmp -s $testroot/stdout.expected $testroot/stdout
2594 ret=$?
2595 if [ $ret -ne 0 ]; then
2596 diff -u $testroot/stdout.expected $testroot/stdout
2597 test_done "$testroot" "$ret"
2598 return 1
2601 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2602 echo "commit $orig_commit (master)" > $testroot/stdout.expected
2603 cmp -s $testroot/stdout.expected $testroot/stdout
2604 ret=$?
2605 if [ $ret -ne 0 ]; then
2606 diff -u $testroot/stdout.expected $testroot/stdout
2608 test_done "$testroot" "$ret"
2611 test_parseargs "$@"
2612 run_test test_histedit_no_op
2613 run_test test_histedit_swap
2614 run_test test_histedit_drop
2615 run_test test_histedit_fold
2616 run_test test_histedit_edit
2617 run_test test_histedit_fold_last_commit
2618 run_test test_histedit_missing_commit_pick
2619 run_test test_histedit_missing_commit_mesg
2620 run_test test_histedit_abort
2621 run_test test_histedit_path_prefix_drop
2622 run_test test_histedit_path_prefix_edit
2623 run_test test_histedit_outside_refs_heads
2624 run_test test_histedit_fold_last_commit_swap
2625 run_test test_histedit_split_commit
2626 run_test test_histedit_duplicate_commit_in_script
2627 run_test test_histedit_fold_add_delete
2628 run_test test_histedit_fold_edit_delete
2629 run_test test_histedit_fold_delete_add
2630 run_test test_histedit_fold_only
2631 run_test test_histedit_fold_only_empty_logmsg
2632 run_test test_histedit_edit_only
2633 run_test test_histedit_prepend_line
2634 run_test test_histedit_resets_committer
2635 run_test test_histedit_umask
2636 run_test test_histedit_mesg_filemode_change
2637 run_test test_histedit_drop_only