3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 test_histedit_no_op
() {
20 local testroot
=`test_init histedit_no_op`
22 local orig_commit
=`git_show_head $testroot/repo`
23 local orig_author_time
=`git_show_author_time $testroot/repo`
25 echo "modified alpha on master" > $testroot/repo
/alpha
26 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
43 if [ $ret -ne 0 ]; then
44 test_done
"$testroot" "$ret"
48 echo "pick $old_commit1" > $testroot/histedit-script
49 echo "pick $old_commit2" >> $testroot/histedit-script
51 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
54 local new_commit1
=`git_show_parent_commit $testroot/repo`
55 local new_commit2
=`git_show_head $testroot/repo`
56 local new_author_time2
=`git_show_author_time $testroot/repo`
58 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
59 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
60 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
61 local short_new_commit2
=`trim_obj_id 12 $new_commit2`
63 echo "G alpha" > $testroot/stdout.expected
64 echo "D beta" >> $testroot/stdout.expected
65 echo "A epsilon/new" >> $testroot/stdout.expected
66 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
67 >> $testroot/stdout.expected
68 echo "G epsilon/zeta" >> $testroot/stdout.expected
69 echo -n "$short_old_commit2 -> $short_new_commit2: " \
70 >> $testroot/stdout.expected
71 echo "committing to zeta on master" >> $testroot/stdout.expected
72 echo "Switching work tree to refs/heads/master" \
73 >> $testroot/stdout.expected
75 cmp -s $testroot/stdout.expected
$testroot/stdout
77 if [ $ret -ne 0 ]; then
78 diff -u $testroot/stdout.expected
$testroot/stdout
79 test_done
"$testroot" "$ret"
83 echo "modified alpha on master" > $testroot/content.expected
84 cat $testroot/wt
/alpha
> $testroot/content
85 cmp -s $testroot/content.expected
$testroot/content
87 if [ $ret -ne 0 ]; then
88 diff -u $testroot/content.expected
$testroot/content
89 test_done
"$testroot" "$ret"
93 if [ -e $testroot/wt
/beta
]; then
94 echo "removed file beta still exists on disk" >&2
95 test_done
"$testroot" "1"
99 echo "new file on master" > $testroot/content.expected
100 cat $testroot/wt
/epsilon
/new
> $testroot/content
101 cmp -s $testroot/content.expected
$testroot/content
103 if [ $ret -ne 0 ]; then
104 diff -u $testroot/content.expected
$testroot/content
105 test_done
"$testroot" "$ret"
109 (cd $testroot/wt
&& got status
> $testroot/stdout
)
111 echo -n > $testroot/stdout.expected
112 cmp -s $testroot/stdout.expected
$testroot/stdout
114 if [ $ret -ne 0 ]; then
115 diff -u $testroot/stdout.expected
$testroot/stdout
116 test_done
"$testroot" "$ret"
120 (cd $testroot/wt
&& got log
-l3 |
grep ^commit
> $testroot/stdout
)
121 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
122 echo "commit $new_commit1" >> $testroot/stdout.expected
123 echo "commit $orig_commit" >> $testroot/stdout.expected
124 cmp -s $testroot/stdout.expected
$testroot/stdout
126 if [ $ret -ne 0 ]; then
127 diff -u $testroot/stdout.expected
$testroot/stdout
128 test_done
"$testroot" "$ret"
132 got
diff -r $testroot/repo
$orig_commit $new_commit2 \
134 ed
-s $testroot/diff.expected
<<-EOF
135 ,s/$old_commit2/$new_commit2/
138 cmp -s $testroot/diff.expected
$testroot/diff
140 if [ $ret -ne 0 ]; then
141 diff -u $testroot/diff.expected
$testroot/diff
142 test_done
"$testroot" "$ret"
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
151 if [ $ret -ne 0 ]; then
152 diff -u $testroot/stdout.expected
$testroot/stdout
153 test_done
"$testroot" "$ret"
157 # We should have a backup of old commits
158 (cd $testroot/repo
&& got histedit
-l > $testroot/stdout
)
159 d_orig1
=`date -u -r $old_author_time1 +"%F"`
160 d_orig2
=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"`
161 d_new2
=`date -u -r $new_author_time2 +"%F"`
162 d_orig
=`date -u -r $orig_author_time +"%F"`
163 cat > $testroot/stdout.expected
<<EOF
164 -----------------------------------------------
165 commit $old_commit2 (formerly master)
169 committing to zeta on master
171 has become commit $new_commit2 (master)
172 $d_new2 $GOT_AUTHOR_11 committing to zeta on master
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
182 fork_commit
=$new_commit1
183 fork_commit_msg
="committing changes"
187 fork_commit
=$orig_commit
188 fork_commit_msg
="adding the test tree"
191 $is_forked && cat >> $testroot/stdout.expected
<<EOF
192 history forked at $fork_commit
193 $d_fork $GOT_AUTHOR_11 $fork_commit_msg
196 cmp -s $testroot/stdout.expected
$testroot/stdout
198 if [ $ret -ne 0 ]; then
199 diff -u $testroot/stdout.expected
$testroot/stdout
200 test_done
"$testroot" "$ret"
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
212 if [ $ret -ne 0 ]; then
213 diff -u $testroot/stdout.expected
$testroot/stdout
214 test_done
"$testroot" "$ret"
217 cmp -s $testroot/stderr.expected
$testroot/stderr
219 if [ $ret -ne 0 ]; then
220 diff -u $testroot/stderr.expected
$testroot/stderr
221 test_done
"$testroot" "$ret"
225 (cd $testroot/repo
&& got histedit
-l > $testroot/stdout
)
226 echo -n > $testroot/stdout.expected
227 cmp -s $testroot/stdout.expected
$testroot/stdout
229 if [ $ret -ne 0 ]; then
230 diff -u $testroot/stdout.expected
$testroot/stdout
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
256 if [ $ret -ne 0 ]; then
257 test_done
"$testroot" "$ret"
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 \
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 12 $old_commit1`
271 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
272 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
273 local short_new_commit2
=`trim_obj_id 12 $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
289 if [ $ret -ne 0 ]; then
290 diff -u $testroot/stdout.expected
$testroot/stdout
291 test_done
"$testroot" "$ret"
295 echo "modified alpha on master" > $testroot/content.expected
296 cat $testroot/wt
/alpha
> $testroot/content
297 cmp -s $testroot/content.expected
$testroot/content
299 if [ $ret -ne 0 ]; then
300 diff -u $testroot/content.expected
$testroot/content
301 test_done
"$testroot" "$ret"
305 if [ -e $testroot/wt
/beta
]; then
306 echo "removed file beta still exists on disk" >&2
307 test_done
"$testroot" "1"
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
315 if [ $ret -ne 0 ]; then
316 diff -u $testroot/content.expected
$testroot/content
317 test_done
"$testroot" "$ret"
321 (cd $testroot/wt
&& got status
> $testroot/stdout
)
323 echo -n > $testroot/stdout.expected
324 cmp -s $testroot/stdout.expected
$testroot/stdout
326 if [ $ret -ne 0 ]; then
327 diff -u $testroot/stdout.expected
$testroot/stdout
328 test_done
"$testroot" "$ret"
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
338 if [ $ret -ne 0 ]; then
339 diff -u $testroot/stdout.expected
$testroot/stdout
340 test_done
"$testroot" "$ret"
344 got
diff -r $testroot/repo
$orig_commit $new_commit1 \
346 ed
-s $testroot/diff.expected
<<-EOF
347 ,s/$old_commit2/$new_commit1/
350 cmp -s $testroot/diff.expected
$testroot/diff
352 if [ $ret -ne 0 ]; then
353 diff -u $testroot/diff.expected
$testroot/diff
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
378 if [ $ret -ne 0 ]; then
379 test_done
"$testroot" "$ret"
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 \
389 local new_commit2
=`git_show_head $testroot/repo`
391 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
392 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
393 local short_new_commit2
=`trim_obj_id 12 $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
406 if [ $ret -ne 0 ]; then
407 diff -u $testroot/stdout.expected
$testroot/stdout
408 test_done
"$testroot" "$ret"
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
417 if [ $ret -ne 0 ]; then
418 diff -u $testroot/content.expected
$testroot/content
419 test_done
"$testroot" "$ret"
424 if [ -e $testroot/wt
/new
]; then
425 echo "file new exists on disk but should not" >&2
426 test_done
"$testroot" "1"
430 (cd $testroot/wt
&& got status
> $testroot/stdout
)
432 echo -n > $testroot/stdout.expected
433 cmp -s $testroot/stdout.expected
$testroot/stdout
435 if [ $ret -ne 0 ]; then
436 diff -u $testroot/stdout.expected
$testroot/stdout
437 test_done
"$testroot" "$ret"
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
446 if [ $ret -ne 0 ]; then
447 diff -u $testroot/stdout.expected
$testroot/stdout
448 test_done
"$testroot" "$ret"
452 got
diff -r $testroot/repo
$orig_commit $new_commit2 \
454 ed
-s $testroot/diff.expected
<<-EOF
455 ,s/$old_commit1/$orig_commit/
456 ,s/$old_commit2/$new_commit2/
459 cmp -s $testroot/diff.expected
$testroot/diff
461 if [ $ret -ne 0 ]; then
462 diff -u $testroot/diff.expected
$testroot/diff
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
489 if [ $ret -ne 0 ]; then
490 test_done
"$testroot" "$ret"
494 cat > $testroot/editor.sh
<<EOF
497 ,s/.*/committing folded changes/
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 12 $old_commit1`
515 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
516 local short_old_commit3
=`trim_obj_id 12 $old_commit3`
517 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
518 local short_new_commit2
=`trim_obj_id 12 $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
537 if [ $ret -ne 0 ]; then
538 diff -u $testroot/stdout.expected
$testroot/stdout
539 test_done
"$testroot" "$ret"
543 echo "modified alpha on master" > $testroot/content.expected
544 cat $testroot/wt
/alpha
> $testroot/content
545 cmp -s $testroot/content.expected
$testroot/content
547 if [ $ret -ne 0 ]; then
548 diff -u $testroot/content.expected
$testroot/content
549 test_done
"$testroot" "$ret"
553 if [ -e $testroot/wt
/beta
]; then
554 echo "removed file beta still exists on disk" >&2
555 test_done
"$testroot" "1"
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
563 if [ $ret -ne 0 ]; then
564 diff -u $testroot/content.expected
$testroot/content
565 test_done
"$testroot" "$ret"
569 (cd $testroot/wt
&& got status
> $testroot/stdout
)
571 echo -n > $testroot/stdout.expected
572 cmp -s $testroot/stdout.expected
$testroot/stdout
574 if [ $ret -ne 0 ]; then
575 diff -u $testroot/stdout.expected
$testroot/stdout
576 test_done
"$testroot" "$ret"
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
585 if [ $ret -ne 0 ]; then
586 diff -u $testroot/stdout.expected
$testroot/stdout
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
609 if [ $ret -ne 0 ]; then
610 test_done
"$testroot" "$ret"
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 \
620 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
621 local short_old_commit2
=`trim_obj_id 12 $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
630 if [ $ret -ne 0 ]; then
631 diff -u $testroot/stdout.expected
$testroot/stdout
632 test_done
"$testroot" "$ret"
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 \
643 if [ $ret -eq 0 ]; then
644 echo "histedit succeeded unexpectedly" >&2
645 test_done
"$testroot" "1"
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
654 if [ $ret -ne 0 ]; then
655 diff -u $testroot/stderr.expected
$testroot/stderr
656 test_done
"$testroot" "$ret"
660 (cd $testroot/wt
&& got unstage alpha
> /dev
/null
)
662 cat > $testroot/editor.sh
<<EOF
665 ,s/.*/committing changes/
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 12 $new_commit1`
679 local short_new_commit2
=`trim_obj_id 12 $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
692 if [ $ret -ne 0 ]; then
693 diff -u $testroot/stdout.expected
$testroot/stdout
694 test_done
"$testroot" "$ret"
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
702 if [ $ret -ne 0 ]; then
703 diff -u $testroot/content.expected
$testroot/content
704 test_done
"$testroot" "$ret"
708 if [ -e $testroot/wt
/beta
]; then
709 echo "removed file beta still exists on disk" >&2
710 test_done
"$testroot" "1"
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
718 if [ $ret -ne 0 ]; then
719 diff -u $testroot/content.expected
$testroot/content
720 test_done
"$testroot" "$ret"
724 (cd $testroot/wt
&& got status
> $testroot/stdout
)
726 echo -n > $testroot/stdout.expected
727 cmp -s $testroot/stdout.expected
$testroot/stdout
729 if [ $ret -ne 0 ]; then
730 diff -u $testroot/stdout.expected
$testroot/stdout
731 test_done
"$testroot" "$ret"
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
741 if [ $ret -ne 0 ]; then
742 diff -u $testroot/stdout.expected
$testroot/stdout
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
765 if [ $ret -ne 0 ]; then
766 test_done
"$testroot" "$ret"
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
)
777 if [ $ret -eq 0 ]; then
778 echo "histedit succeeded unexpectedly" >&2
779 test_done
"$testroot" "1"
783 echo "got: last commit in histedit script cannot be folded" \
784 > $testroot/stderr.expected
786 cmp -s $testroot/stderr.expected
$testroot/stderr
788 if [ $ret -ne 0 ]; then
789 diff -u $testroot/stderr.expected
$testroot/stderr
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
812 if [ $ret -ne 0 ]; then
813 test_done
"$testroot" "$ret"
817 echo "pick $old_commit1" > $testroot/histedit-script
819 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
820 > $testroot/stdout
2> $testroot/stderr
)
823 if [ $ret -eq 0 ]; then
824 echo "histedit succeeded unexpectedly" >&2
825 test_done
"$testroot" "1"
829 echo "got: commit $old_commit2 missing from histedit script" \
830 > $testroot/stderr.expected
832 cmp -s $testroot/stderr.expected
$testroot/stderr
834 if [ $ret -ne 0 ]; then
835 diff -u $testroot/stderr.expected
$testroot/stderr
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
858 if [ $ret -ne 0 ]; then
859 test_done
"$testroot" "$ret"
863 cat > $testroot/editor.sh
<<EOF
866 ,s/.*/committing folded changes/
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 \
880 if [ $ret -eq 0 ]; then
881 echo "histedit succeeded unexpectedly" >&2
882 test_done
"$testroot" "1"
886 echo "got: commit $old_commit2 missing from histedit script" \
887 > $testroot/stderr.expected
889 cmp -s $testroot/stderr.expected
$testroot/stderr
891 if [ $ret -ne 0 ]; then
892 diff -u $testroot/stderr.expected
$testroot/stderr
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
915 if [ $ret -ne 0 ]; then
916 test_done
"$testroot" "$ret"
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 \
929 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
930 local short_old_commit2
=`trim_obj_id 12 $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
939 if [ $ret -ne 0 ]; then
940 diff -u $testroot/stdout.expected
$testroot/stdout
941 test_done
"$testroot" "$ret"
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
962 if [ $ret -ne 0 ]; then
963 diff -u $testroot/stdout.expected
$testroot/stdout
964 test_done
"$testroot" "$ret"
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
973 if [ $ret -ne 0 ]; then
974 diff -u $testroot/content.expected
$testroot/content
975 test_done
"$testroot" "$ret"
980 if [ -e $testroot/wt
/epsilon
/new
]; then
981 echo "removed file new still exists on disk" >&2
982 test_done
"$testroot" "1"
986 (cd $testroot/wt
&& got status
> $testroot/stdout
)
988 echo "? unversioned-file" > $testroot/stdout.expected
989 cmp -s $testroot/stdout.expected
$testroot/stdout
991 if [ $ret -ne 0 ]; then
992 diff -u $testroot/stdout.expected
$testroot/stdout
993 test_done
"$testroot" "$ret"
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
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
1020 if [ $ret -ne 0 ]; then
1021 test_done
"$testroot" "$ret"
1025 echo "drop $old_commit1" > $testroot/histedit-script
1027 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
1028 > $testroot/stdout
2> $testroot/stderr
)
1031 if [ $ret -eq 0 ]; then
1032 echo "histedit succeeded unexpectedly" >&2
1033 test_done
"$testroot" "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
1044 if [ $ret -ne 0 ]; then
1045 diff -u $testroot/stderr.expected
$testroot/stderr
1046 test_done
"$testroot" "$ret"
1051 got checkout
-c $orig_commit -p epsilon
$testroot/repo \
1052 $testroot/wt
> /dev
/null
1054 if [ $ret -ne 0 ]; then
1055 test_done
"$testroot" "$ret"
1058 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
1061 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
1062 local short_old_commit2
=`trim_obj_id 12 $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
1071 if [ $ret -ne 0 ]; then
1072 diff -u $testroot/stdout.expected
$testroot/stdout
1073 test_done
"$testroot" "$ret"
1077 echo "zeta" > $testroot/content.expected
1078 cat $testroot/wt
/zeta
> $testroot/content
1079 cmp -s $testroot/content.expected
$testroot/content
1081 if [ $ret -ne 0 ]; then
1082 diff -u $testroot/content.expected
$testroot/content
1083 test_done
"$testroot" "$ret"
1088 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1090 echo -n > $testroot/stdout.expected
1091 cmp -s $testroot/stdout.expected
$testroot/stdout
1093 if [ $ret -ne 0 ]; then
1094 diff -u $testroot/stdout.expected
$testroot/stdout
1095 test_done
"$testroot" "$ret"
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
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
1123 if [ $ret -ne 0 ]; then
1124 test_done
"$testroot" "$ret"
1128 echo "edit $old_commit1" > $testroot/histedit-script
1130 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
1131 > $testroot/stdout
2> $testroot/stderr
)
1134 if [ $ret -eq 0 ]; then
1135 echo "histedit succeeded unexpectedly" >&2
1136 test_done
"$testroot" "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
1147 if [ $ret -ne 0 ]; then
1148 diff -u $testroot/stderr.expected
$testroot/stderr
1149 test_done
"$testroot" "$ret"
1154 got checkout
-c $orig_commit -p epsilon
$testroot/repo \
1155 $testroot/wt
> /dev
/null
1157 if [ $ret -ne 0 ]; then
1158 test_done
"$testroot" "$ret"
1161 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
1164 local short_old_commit1
=`trim_obj_id 12 $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
1171 if [ $ret -ne 0 ]; then
1172 diff -u $testroot/stdout.expected
$testroot/stdout
1173 test_done
"$testroot" "$ret"
1177 echo "modified zeta" > $testroot/content.expected
1178 cat $testroot/wt
/zeta
> $testroot/content
1179 cmp -s $testroot/content.expected
$testroot/content
1181 if [ $ret -ne 0 ]; then
1182 diff -u $testroot/content.expected
$testroot/content
1183 test_done
"$testroot" "$ret"
1187 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1189 cat > $testroot/stdout.expected
<<EOF
1191 Work tree is editing the history of refs/heads/master
1193 cmp -s $testroot/stdout.expected
$testroot/stdout
1195 if [ $ret -ne 0 ]; then
1196 diff -u $testroot/stdout.expected
$testroot/stdout
1197 test_done
"$testroot" "$ret"
1201 cat > $testroot/editor.sh
<<EOF
1204 ,s/.*/modified zeta/
1208 chmod +x
$testroot/editor.sh
1210 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
1211 VISUAL
="$testroot/editor.sh" \
1212 got histedit
-c > $testroot/stdout
)
1214 local new_commit1
=`git_show_head $testroot/repo`
1215 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
1217 echo -n "$short_old_commit1 -> $short_new_commit1: " \
1218 > $testroot/stdout.expected
1219 echo "modified zeta" >> $testroot/stdout.expected
1220 echo "Switching work tree to refs/heads/master" \
1221 >> $testroot/stdout.expected
1223 cmp -s $testroot/stdout.expected
$testroot/stdout
1225 if [ $ret -ne 0 ]; then
1226 diff -u $testroot/stdout.expected
$testroot/stdout
1227 test_done
"$testroot" "$ret"
1231 (cd $testroot/wt
&& got log
-l3 |
grep ^commit
> $testroot/stdout
)
1232 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1233 echo "commit $orig_commit" >> $testroot/stdout.expected
1234 cmp -s $testroot/stdout.expected
$testroot/stdout
1236 if [ $ret -ne 0 ]; then
1237 diff -u $testroot/stdout.expected
$testroot/stdout
1238 test_done
"$testroot" "$ret"
1242 got
diff -r $testroot/repo
$orig_commit $new_commit1 \
1244 ed
-s $testroot/diff.expected
<<-EOF
1245 ,s/$old_commit1/$new_commit1/
1248 cmp -s $testroot/diff.expected
$testroot/diff
1250 if [ $ret -ne 0 ]; then
1251 diff -u $testroot/diff.expected
$testroot/diff
1253 test_done
"$testroot" "$ret"
1256 test_histedit_outside_refs_heads
() {
1257 local testroot
=`test_init histedit_outside_refs_heads`
1258 local commit1
=`git_show_head $testroot/repo`
1260 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
1262 if [ $ret -ne 0 ]; then
1263 echo "got checkout failed unexpectedly"
1264 test_done
"$testroot" "$ret"
1268 echo "modified alpha" > $testroot/wt
/alpha
1270 (cd $testroot/wt
&& got commit
-m 'change alpha' \
1271 > $testroot/stdout
2> $testroot/stderr
)
1273 if [ $ret -ne 0 ]; then
1274 echo "got commit failed unexpectedly" >&2
1275 test_done
"$testroot" "1"
1278 local commit2
=`git_show_head $testroot/repo`
1280 got ref
-r $testroot/repo
-c master refs
/remotes
/origin
/master
1282 if [ $ret -ne 0 ]; then
1283 echo "got ref failed unexpectedly" >&2
1284 test_done
"$testroot" "1"
1288 (cd $testroot/wt
&& got update
-b origin
/master
-c $commit1 >/dev
/null
)
1290 if [ $ret -ne 0 ]; then
1291 echo "got update failed unexpectedly"
1292 test_done
"$testroot" "$ret"
1296 echo "edit $commit2" > $testroot/histedit-script
1297 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
1298 2> $testroot/stderr
)
1300 echo -n "got: will not edit commit history of a branch outside the " \
1301 > $testroot/stderr.expected
1302 echo '"refs/heads/" reference namespace' \
1303 >> $testroot/stderr.expected
1304 cmp -s $testroot/stderr.expected
$testroot/stderr
1306 if [ $ret -ne 0 ]; then
1307 diff -u $testroot/stderr.expected
$testroot/stderr
1309 test_done
"$testroot" "$ret"
1312 test_histedit_fold_last_commit_swap
() {
1313 local testroot
=`test_init histedit_fold_last_commit_swap`
1315 local orig_commit
=`git_show_head $testroot/repo`
1317 echo "modified alpha on master" > $testroot/repo
/alpha
1318 git
-C $testroot/repo
rm -q beta
1319 echo "new file on master" > $testroot/repo
/epsilon
/new
1320 git
-C $testroot/repo add epsilon
/new
1321 git_commit
$testroot/repo
-m "committing changes"
1322 local old_commit1
=`git_show_head $testroot/repo`
1324 echo "modified zeta on master" > $testroot/repo
/epsilon
/zeta
1325 git_commit
$testroot/repo
-m "committing to zeta on master"
1326 local old_commit2
=`git_show_head $testroot/repo`
1328 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
1330 if [ $ret -ne 0 ]; then
1331 test_done
"$testroot" "$ret"
1335 cat > $testroot/editor.sh
<<EOF
1338 ,s/.*/committing folded changes/
1342 chmod +x
$testroot/editor.sh
1344 # fold commit2 into commit1 (requires swapping commits)
1345 echo "fold $old_commit2" > $testroot/histedit-script
1346 echo "mesg $old_commit1" >> $testroot/histedit-script
1348 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
1349 VISUAL
="$testroot/editor.sh" \
1350 got histedit
-F $testroot/histedit-script
> $testroot/stdout \
1351 2> $testroot/stderr
)
1354 if [ $ret -ne 0 ]; then
1355 echo "histedit failed unexpectedly" >&2
1356 test_done
"$testroot" "$ret"
1360 local new_commit
=`git_show_head $testroot/repo`
1362 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
1363 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
1364 local short_new_commit
=`trim_obj_id 12 $new_commit`
1366 echo "G epsilon/zeta" >> $testroot/stdout.expected
1367 echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1368 >> $testroot/stdout.expected
1369 echo "on master" >> $testroot/stdout.expected
1370 echo "G alpha" >> $testroot/stdout.expected
1371 echo "D beta" >> $testroot/stdout.expected
1372 echo "A epsilon/new" >> $testroot/stdout.expected
1373 echo -n "$short_old_commit1 -> $short_new_commit: " \
1374 >> $testroot/stdout.expected
1375 echo "committing folded changes" >> $testroot/stdout.expected
1376 echo "Switching work tree to refs/heads/master" \
1377 >> $testroot/stdout.expected
1379 cmp -s $testroot/stdout.expected
$testroot/stdout
1381 if [ $ret -ne 0 ]; then
1382 diff -u $testroot/stdout.expected
$testroot/stdout
1384 test_done
"$testroot" "$ret"
1387 test_histedit_split_commit
() {
1388 local testroot
=`test_init histedit_split_commit`
1390 local orig_commit
=`git_show_head $testroot/repo`
1392 echo "modified alpha on master" > $testroot/repo
/alpha
1393 git
-C $testroot/repo
rm -q beta
1394 echo "new file on master" > $testroot/repo
/epsilon
/new
1395 git
-C $testroot/repo add epsilon
/new
1396 git_commit
$testroot/repo
-m "committing changes 1"
1397 local old_commit1
=`git_show_head $testroot/repo`
1398 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
1400 echo "modified zeta on master" > $testroot/repo
/epsilon
/zeta
1401 git_commit
$testroot/repo
-m "committing changes 2"
1402 local old_commit2
=`git_show_head $testroot/repo`
1403 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
1405 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
1407 if [ $ret -ne 0 ]; then
1408 test_done
"$testroot" "$ret"
1412 # split commit1 into commitA and commitB and commitC
1413 echo "e $old_commit1" > $testroot/histedit-script
1414 echo "p $old_commit2" >> $testroot/histedit-script
1416 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
1417 > $testroot/stdout
2> $testroot/stderr
)
1419 if [ $ret -ne 0 ]; then
1420 echo "histedit failed unexpectedly:" >&2
1421 cat $testroot/stderr
>&2
1422 test_done
"$testroot" "$ret"
1426 echo "G alpha" > $testroot/stdout.expected
1427 echo "D beta" >> $testroot/stdout.expected
1428 echo "A epsilon/new" >> $testroot/stdout.expected
1429 echo "Stopping histedit for amending commit $old_commit1" \
1430 >> $testroot/stdout.expected
1432 cmp -s $testroot/stdout.expected
$testroot/stdout
1434 if [ $ret -ne 0 ]; then
1435 diff -u $testroot/stdout.expected
$testroot/stdout
1436 test_done
"$testroot" "$ret"
1440 (cd $testroot/wt
&& got ci
-m "commitA" alpha
>/dev
/null
)
1442 if [ $ret -ne 0 ]; then
1443 echo "commit failed unexpectedly" >&2
1444 test_done
"$testroot" "$ret"
1448 (cd $testroot/wt
&& got ci
-m "commitB" beta
>/dev
/null
)
1450 if [ $ret -ne 0 ]; then
1451 echo "commit failed unexpectedly" >&2
1452 test_done
"$testroot" "$ret"
1456 (cd $testroot/wt
&& got ci
-m "commitC" epsilon
/new
>/dev
/null
)
1458 if [ $ret -ne 0 ]; then
1459 echo "commit failed unexpectedly" >&2
1460 test_done
"$testroot" "$ret"
1464 (cd $testroot/wt
&& got histedit
-c \
1465 > $testroot/stdout
2> $testroot/stderr
)
1467 if [ $ret -ne 0 ]; then
1468 echo "histedit failed unexpectedly:" >&2
1469 cat $testroot/stderr
>&2
1470 test_done
"$testroot" "$ret"
1473 local new_commit2
=`git_show_head $testroot/repo`
1474 local short_new_commit2
=`trim_obj_id 12 $new_commit2`
1476 echo "$short_old_commit1 -> no-op change: committing changes 1" \
1477 > $testroot/stdout.expected
1478 echo "G epsilon/zeta" >> $testroot/stdout.expected
1479 echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1480 >> $testroot/stdout.expected
1481 echo "Switching work tree to refs/heads/master" \
1482 >> $testroot/stdout.expected
1484 cmp -s $testroot/stdout.expected
$testroot/stdout
1486 if [ $ret -ne 0 ]; then
1487 diff -u $testroot/stdout.expected
$testroot/stdout
1489 test_done
"$testroot" "$ret"
1493 test_histedit_duplicate_commit_in_script
() {
1494 local testroot
=`test_init histedit_duplicate_commit_in_script`
1496 local orig_commit
=`git_show_head $testroot/repo`
1498 echo "modified alpha on master" > $testroot/repo
/alpha
1499 git
-C $testroot/repo
rm -q beta
1500 echo "new file on master" > $testroot/repo
/epsilon
/new
1501 git
-C $testroot/repo add epsilon
/new
1502 git_commit
$testroot/repo
-m "committing changes 1"
1503 local old_commit1
=`git_show_head $testroot/repo`
1505 echo "modified zeta on master" > $testroot/repo
/epsilon
/zeta
1506 git_commit
$testroot/repo
-m "committing changes 2"
1507 local old_commit2
=`git_show_head $testroot/repo`
1509 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
1511 if [ $ret -ne 0 ]; then
1512 test_done
"$testroot" "$ret"
1516 # This histedit script lists commit1 more than once
1517 echo "p $old_commit1" > $testroot/histedit-script
1518 echo "p $old_commit1" >> $testroot/histedit-script
1519 echo "p $old_commit2" >> $testroot/histedit-script
1521 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
1522 > $testroot/stdout
2> $testroot/stderr
)
1524 if [ $ret -eq 0 ]; then
1525 echo "histedit succeeded unexpectedly:" >&2
1526 cat $testroot/stdout
>&2
1527 test_done
"$testroot" 1
1531 echo -n "got: commit $old_commit1 is listed more than once " \
1532 > $testroot/stderr.expected
1533 echo "in histedit script" >> $testroot/stderr.expected
1535 cmp -s $testroot/stderr.expected
$testroot/stderr
1537 if [ $ret -ne 0 ]; then
1538 diff -u $testroot/stderr.expected
$testroot/stderr
1540 test_done
"$testroot" "$ret"
1544 # if a previous commit introduces a new file, and it is folded into a commit
1545 # that deletes the same file, the file still exists after the histedit
1546 test_histedit_fold_add_delete
() {
1547 local testroot
=`test_init histedit_fold_add_delete`
1549 local orig_commit
=`git_show_head $testroot/repo`
1551 echo "added new file epsilon/psi" > $testroot/repo
/epsilon
/psi
1552 git
-C $testroot/repo add epsilon
/psi
1553 git_commit
$testroot/repo
-m "committing changes"
1554 local old_commit1
=`git_show_head $testroot/repo`
1556 echo "modified epsilon/psi" > $testroot/repo
/epsilon
/psi
1557 git_commit
$testroot/repo
-m "editing psi"
1558 local old_commit2
=`git_show_head $testroot/repo`
1560 git
-C $testroot/repo
rm -q epsilon
/psi
1561 git_commit
$testroot/repo
-m "removing psi"
1562 local old_commit3
=`git_show_head $testroot/repo`
1564 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
1566 if [ $ret -ne 0 ]; then
1567 test_done
"$testroot" "$ret"
1571 cat > $testroot/editor.sh
<<EOF
1574 ,s/.*/folded changes/
1578 chmod +x
$testroot/editor.sh
1580 echo "fold $old_commit1" > $testroot/histedit-script
1581 echo "fold $old_commit2" >> $testroot/histedit-script
1582 echo "pick $old_commit3" >> $testroot/histedit-script
1584 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
1585 VISUAL
="$testroot/editor.sh" \
1586 got histedit
-F $testroot/histedit-script
> $testroot/stdout
)
1588 local new_commit1
=`git_show_head $testroot/repo`
1590 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
1591 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
1592 local short_old_commit3
=`trim_obj_id 12 $old_commit3`
1593 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
1595 echo "A epsilon/psi" >> $testroot/stdout.expected
1596 echo "$short_old_commit1 -> fold commit: committing changes" \
1597 >> $testroot/stdout.expected
1598 echo "G epsilon/psi" >> $testroot/stdout.expected
1599 echo "$short_old_commit2 -> fold commit: editing psi" \
1600 >> $testroot/stdout.expected
1601 echo "D epsilon/psi" >> $testroot/stdout.expected
1602 echo "$short_old_commit3 -> no-op change: folded changes" \
1603 >> $testroot/stdout.expected
1604 echo "Switching work tree to refs/heads/master" \
1605 >> $testroot/stdout.expected
1607 cmp -s $testroot/stdout.expected
$testroot/stdout
1609 if [ $ret -ne 0 ]; then
1610 diff -u $testroot/stdout.expected
$testroot/stdout
1611 test_done
"$testroot" "$ret"
1615 if [ -e $testroot/wt
/epsilon
/psi
]; then
1616 echo "removed file psi still exists on disk" >&2
1617 test_done
"$testroot" "1"
1621 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1623 echo -n > $testroot/stdout.expected
1624 cmp -s $testroot/stdout.expected
$testroot/stdout
1626 if [ $ret -ne 0 ]; then
1627 diff -u $testroot/stdout.expected
$testroot/stdout
1628 test_done
"$testroot" "$ret"
1632 (cd $testroot/wt
&& got log
-l3 |
grep ^commit
> $testroot/stdout
)
1633 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1634 cmp -s $testroot/stdout.expected
$testroot/stdout
1636 if [ $ret -ne 0 ]; then
1637 diff -u $testroot/stdout.expected
$testroot/stdout
1638 test_done
"$testroot" "$ret"
1642 got tree
-r $testroot/repo epsilon
> $testroot/stdout
1643 echo "zeta" > $testroot/stdout.expected
1644 cmp -s $testroot/stdout.expected
$testroot/stdout
1646 if [ $ret -ne 0 ]; then
1647 diff -u $testroot/stdout.expected
$testroot/stdout
1649 test_done
"$testroot" "$ret"
1652 # if a previous commit edits a file, and it is folded into a commit
1653 # that deletes the same file, the file will be deleted by histedit
1654 test_histedit_fold_edit_delete
() {
1655 local testroot
=`test_init histedit_fold_edit_delete`
1657 local orig_commit
=`git_show_head $testroot/repo`
1659 echo "modify alpha" > $testroot/repo
/alpha
1660 git
-C $testroot/repo add alpha
1661 git_commit
$testroot/repo
-m "modified alpha"
1662 local old_commit1
=`git_show_head $testroot/repo`
1664 git_rm
$testroot/repo alpha
1665 git_commit
$testroot/repo
-m "deleted alpha"
1666 local old_commit2
=`git_show_head $testroot/repo`
1668 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
1670 if [ $ret -ne 0 ]; then
1671 test_done
"$testroot" "$ret"
1675 cat > $testroot/editor.sh
<<EOF
1678 ,s/.*/folded changes/
1682 chmod +x
$testroot/editor.sh
1684 echo "fold $old_commit1" > $testroot/histedit-script
1685 echo "pick $old_commit2" >> $testroot/histedit-script
1687 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
1688 VISUAL
="$testroot/editor.sh" \
1689 got histedit
-F $testroot/histedit-script
> $testroot/stdout
)
1691 local new_commit1
=`git_show_head $testroot/repo`
1693 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
1694 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
1695 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
1697 echo "G alpha" >> $testroot/stdout.expected
1698 echo "$short_old_commit1 -> fold commit: modified alpha" \
1699 >> $testroot/stdout.expected
1700 echo "D alpha" >> $testroot/stdout.expected
1701 echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1702 >> $testroot/stdout.expected
1703 echo "Switching work tree to refs/heads/master" \
1704 >> $testroot/stdout.expected
1706 cmp -s $testroot/stdout.expected
$testroot/stdout
1708 if [ $ret -ne 0 ]; then
1709 diff -u $testroot/stdout.expected
$testroot/stdout
1710 test_done
"$testroot" "$ret"
1714 if [ -e $testroot/wt
/alpha
]; then
1715 echo "removed file alpha still exists on disk" >&2
1716 test_done
"$testroot" "1"
1720 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1722 echo -n > $testroot/stdout.expected
1723 cmp -s $testroot/stdout.expected
$testroot/stdout
1725 if [ $ret -ne 0 ]; then
1726 diff -u $testroot/stdout.expected
$testroot/stdout
1727 test_done
"$testroot" "$ret"
1731 (cd $testroot/wt
&& got log
-l2 |
grep ^commit
> $testroot/stdout
)
1732 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1733 echo "commit $orig_commit" >> $testroot/stdout.expected
1734 cmp -s $testroot/stdout.expected
$testroot/stdout
1736 if [ $ret -ne 0 ]; then
1737 diff -u $testroot/stdout.expected
$testroot/stdout
1740 test_done
"$testroot" "$ret"
1743 test_histedit_fold_delete_add
() {
1744 local testroot
=`test_init histedit_fold_delete_add`
1746 local orig_commit
=`git_show_head $testroot/repo`
1748 git
-C $testroot/repo
rm -q alpha
1749 git_commit
$testroot/repo
-m "removing alpha"
1750 local old_commit1
=`git_show_head $testroot/repo`
1752 echo "modified alpha" >$testroot/repo
/alpha
1753 git
-C $testroot/repo add alpha
1754 git_commit
$testroot/repo
-m "add back modified alpha"
1755 local old_commit2
=`git_show_head $testroot/repo`
1757 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
1759 if [ $ret -ne 0 ]; then
1760 test_done
"$testroot" "$ret"
1764 cat > $testroot/editor.sh
<<EOF
1767 ,s/.*/folded changes/
1771 chmod +x
$testroot/editor.sh
1773 echo "fold $old_commit1" > $testroot/histedit-script
1774 echo "pick $old_commit2" >> $testroot/histedit-script
1776 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
1777 VISUAL
="$testroot/editor.sh" \
1778 got histedit
-F $testroot/histedit-script
> $testroot/stdout
)
1780 local new_commit1
=`git_show_head $testroot/repo`
1782 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
1783 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
1784 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
1786 echo "D alpha" > $testroot/stdout.expected
1787 echo "$short_old_commit1 -> fold commit: removing alpha" \
1788 >> $testroot/stdout.expected
1789 echo "A alpha" >> $testroot/stdout.expected
1790 echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1791 >> $testroot/stdout.expected
1792 echo "Switching work tree to refs/heads/master" \
1793 >> $testroot/stdout.expected
1795 cmp -s $testroot/stdout.expected
$testroot/stdout
1797 if [ $ret -ne 0 ]; then
1798 diff -u $testroot/stdout.expected
$testroot/stdout
1799 test_done
"$testroot" "$ret"
1803 if [ ! -e $testroot/wt
/alpha
]; then
1804 echo "file alpha is missing on disk" >&2
1805 test_done
"$testroot" "1"
1809 echo "modified alpha" > $testroot/content.expected
1810 cat $testroot/wt
/alpha
> $testroot/content
1811 cmp -s $testroot/content.expected
$testroot/content
1813 if [ $ret -ne 0 ]; then
1814 diff -u $testroot/content.expected
$testroot/content
1815 test_done
"$testroot" "$ret"
1818 test_done
"$testroot" "0"
1821 test_histedit_fold_only
() {
1822 local testroot
=`test_init histedit_fold_only`
1824 local orig_commit
=`git_show_head $testroot/repo`
1826 echo "modified alpha on master" > $testroot/repo
/alpha
1827 git
-C $testroot/repo
rm -q beta
1828 echo "new file on master" > $testroot/repo
/epsilon
/new
1829 git
-C $testroot/repo add epsilon
/new
1830 git_commit
$testroot/repo
-m "committing changes"
1831 local old_commit1
=`git_show_head $testroot/repo`
1833 echo "modified zeta on master" > $testroot/repo
/epsilon
/zeta
1834 git_commit
$testroot/repo
-m "committing to zeta on master"
1835 local old_commit2
=`git_show_head $testroot/repo`
1837 echo "modified delta on master" > $testroot/repo
/gamma
/delta
1838 git_commit
$testroot/repo
-m "committing to delta on master"
1839 local old_commit3
=`git_show_head $testroot/repo`
1841 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
1843 if [ $ret -ne 0 ]; then
1844 test_done
"$testroot" "$ret"
1848 cat > $testroot/editor.sh
<<EOF
1851 ,s/.*/committing folded changes/
1855 chmod +x
$testroot/editor.sh
1857 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
1858 VISUAL
="$testroot/editor.sh" got histedit
-f > $testroot/stdout
)
1860 local new_commit1
=`git_show_head $testroot/repo`
1862 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
1863 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
1864 local short_old_commit3
=`trim_obj_id 12 $old_commit3`
1865 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
1866 local short_new_commit2
=`trim_obj_id 12 $new_commit2`
1868 echo "G alpha" > $testroot/stdout.expected
1869 echo "D beta" >> $testroot/stdout.expected
1870 echo "A epsilon/new" >> $testroot/stdout.expected
1871 echo "$short_old_commit1 -> fold commit: committing changes" \
1872 >> $testroot/stdout.expected
1873 echo "G epsilon/zeta" >> $testroot/stdout.expected
1874 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1875 echo "fold commit: committing to zeta on master" \
1876 >> $testroot/stdout.expected
1877 echo "G gamma/delta" >> $testroot/stdout.expected
1878 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1879 >> $testroot/stdout.expected
1880 echo "committing folded changes" >> $testroot/stdout.expected
1881 echo "Switching work tree to refs/heads/master" \
1882 >> $testroot/stdout.expected
1884 cmp -s $testroot/stdout.expected
$testroot/stdout
1886 if [ $ret -ne 0 ]; then
1887 diff -u $testroot/stdout.expected
$testroot/stdout
1888 test_done
"$testroot" "$ret"
1892 echo "modified alpha on master" > $testroot/content.expected
1893 cat $testroot/wt
/alpha
> $testroot/content
1894 cmp -s $testroot/content.expected
$testroot/content
1896 if [ $ret -ne 0 ]; then
1897 diff -u $testroot/content.expected
$testroot/content
1898 test_done
"$testroot" "$ret"
1902 if [ -e $testroot/wt
/beta
]; then
1903 echo "removed file beta still exists on disk" >&2
1904 test_done
"$testroot" "1"
1908 echo "new file on master" > $testroot/content.expected
1909 cat $testroot/wt
/epsilon
/new
> $testroot/content
1910 cmp -s $testroot/content.expected
$testroot/content
1912 if [ $ret -ne 0 ]; then
1913 diff -u $testroot/content.expected
$testroot/content
1914 test_done
"$testroot" "$ret"
1918 (cd $testroot/wt
&& got status
> $testroot/stdout
)
1920 echo -n > $testroot/stdout.expected
1921 cmp -s $testroot/stdout.expected
$testroot/stdout
1923 if [ $ret -ne 0 ]; then
1924 diff -u $testroot/stdout.expected
$testroot/stdout
1925 test_done
"$testroot" "$ret"
1929 (cd $testroot/wt
&& got log |
grep ^commit
> $testroot/stdout
)
1930 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1931 echo "commit $orig_commit" >> $testroot/stdout.expected
1932 cmp -s $testroot/stdout.expected
$testroot/stdout
1934 if [ $ret -ne 0 ]; then
1935 diff -u $testroot/stdout.expected
$testroot/stdout
1937 test_done
"$testroot" "$ret"
1940 test_histedit_fold_only_empty_logmsg
() {
1941 local testroot
=`test_init histedit_fold_only_empty_logmsg`
1943 local orig_commit
=`git_show_head $testroot/repo`
1945 echo "modified alpha on master" > $testroot/repo
/alpha
1946 git
-C $testroot/repo
rm -q beta
1947 echo "new file on master" > $testroot/repo
/epsilon
/new
1948 git
-C $testroot/repo add epsilon
/new
1949 git_commit
$testroot/repo
-m "committing changes"
1950 local old_commit1
=`git_show_head $testroot/repo`
1952 echo "modified zeta on master" > $testroot/repo
/epsilon
/zeta
1953 git_commit
$testroot/repo
-m "committing to zeta on master"
1954 local old_commit2
=`git_show_head $testroot/repo`
1956 echo "modified delta on master" > $testroot/repo
/gamma
/delta
1957 git_commit
$testroot/repo
-m "committing to delta on master"
1958 local old_commit3
=`git_show_head $testroot/repo`
1960 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
1962 if [ $ret -ne 0 ]; then
1963 test_done
"$testroot" "$ret"
1967 cat > $testroot/editor.sh
<<EOF
1974 chmod +x
$testroot/editor.sh
1976 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
1977 VISUAL
="$testroot/editor.sh" got histedit
-f > $testroot/stdout
)
1979 local new_commit1
=`git_show_head $testroot/repo`
1981 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
1982 local very_short_old_commit1
=`trim_obj_id 11 $old_commit1`
1983 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
1984 local short_old_commit3
=`trim_obj_id 12 $old_commit3`
1985 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
1986 local short_new_commit2
=`trim_obj_id 12 $new_commit2`
1988 echo "G alpha" > $testroot/stdout.expected
1989 echo "D beta" >> $testroot/stdout.expected
1990 echo "A epsilon/new" >> $testroot/stdout.expected
1991 echo "$short_old_commit1 -> fold commit: committing changes" \
1992 >> $testroot/stdout.expected
1993 echo "G epsilon/zeta" >> $testroot/stdout.expected
1994 echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1995 echo "fold commit: committing to zeta on master" \
1996 >> $testroot/stdout.expected
1997 echo "G gamma/delta" >> $testroot/stdout.expected
1998 echo -n "$short_old_commit3 -> $short_new_commit1: " \
1999 >> $testroot/stdout.expected
2000 echo "# log message of folded commit $very_short_old_commit1" \
2001 >> $testroot/stdout.expected
2002 echo "Switching work tree to refs/heads/master" \
2003 >> $testroot/stdout.expected
2005 cmp -s $testroot/stdout.expected
$testroot/stdout
2007 if [ $ret -ne 0 ]; then
2008 diff -u $testroot/stdout.expected
$testroot/stdout
2009 test_done
"$testroot" "$ret"
2013 echo "modified alpha on master" > $testroot/content.expected
2014 cat $testroot/wt
/alpha
> $testroot/content
2015 cmp -s $testroot/content.expected
$testroot/content
2017 if [ $ret -ne 0 ]; then
2018 diff -u $testroot/content.expected
$testroot/content
2019 test_done
"$testroot" "$ret"
2023 if [ -e $testroot/wt
/beta
]; then
2024 echo "removed file beta still exists on disk" >&2
2025 test_done
"$testroot" "1"
2029 echo "new file on master" > $testroot/content.expected
2030 cat $testroot/wt
/epsilon
/new
> $testroot/content
2031 cmp -s $testroot/content.expected
$testroot/content
2033 if [ $ret -ne 0 ]; then
2034 diff -u $testroot/content.expected
$testroot/content
2035 test_done
"$testroot" "$ret"
2039 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2041 echo -n > $testroot/stdout.expected
2042 cmp -s $testroot/stdout.expected
$testroot/stdout
2044 if [ $ret -ne 0 ]; then
2045 diff -u $testroot/stdout.expected
$testroot/stdout
2046 test_done
"$testroot" "$ret"
2050 (cd $testroot/wt
&& got log |
grep ^commit
> $testroot/stdout
)
2051 echo "commit $new_commit1 (master)" > $testroot/stdout.expected
2052 echo "commit $orig_commit" >> $testroot/stdout.expected
2053 cmp -s $testroot/stdout.expected
$testroot/stdout
2055 if [ $ret -ne 0 ]; then
2056 diff -u $testroot/stdout.expected
$testroot/stdout
2058 test_done
"$testroot" "$ret"
2061 test_histedit_edit_only
() {
2062 local testroot
=`test_init histedit_edit_only`
2064 local orig_commit
=`git_show_head $testroot/repo`
2066 echo "modified alpha on master" > $testroot/repo
/alpha
2067 git
-C $testroot/repo
rm -q beta
2068 echo "new file on master" > $testroot/repo
/epsilon
/new
2069 git
-C $testroot/repo add epsilon
/new
2070 git_commit
$testroot/repo
-m "committing changes"
2071 local old_commit1
=`git_show_head $testroot/repo`
2073 echo "modified zeta on master" > $testroot/repo
/epsilon
/zeta
2074 git_commit
$testroot/repo
-m "committing to zeta on master"
2075 local old_commit2
=`git_show_head $testroot/repo`
2077 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
2079 if [ $ret -ne 0 ]; then
2080 test_done
"$testroot" "$ret"
2084 (cd $testroot/wt
&& got histedit
-e > $testroot/stdout
)
2086 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
2087 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
2089 echo "G alpha" > $testroot/stdout.expected
2090 echo "D beta" >> $testroot/stdout.expected
2091 echo "A epsilon/new" >> $testroot/stdout.expected
2092 echo "Stopping histedit for amending commit $old_commit1" \
2093 >> $testroot/stdout.expected
2094 cmp -s $testroot/stdout.expected
$testroot/stdout
2096 if [ $ret -ne 0 ]; then
2097 diff -u $testroot/stdout.expected
$testroot/stdout
2098 test_done
"$testroot" "$ret"
2102 echo "edited modified alpha on master" > $testroot/wt
/alpha
2104 cat > $testroot/editor.sh
<<EOF
2107 ,s/.*/committing edited changes 1/
2111 chmod +x
$testroot/editor.sh
2113 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
2114 VISUAL
="$testroot/editor.sh" got histedit
-c > $testroot/stdout
)
2116 local new_commit1
=$
(cd $testroot/wt
&& got info | \
2117 grep '^work tree base commit: ' | cut
-d: -f2 |
tr -d ' ')
2118 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
2120 echo -n "$short_old_commit1 -> $short_new_commit1: " \
2121 > $testroot/stdout.expected
2122 echo "committing edited changes 1" >> $testroot/stdout.expected
2123 echo "G epsilon/zeta" >> $testroot/stdout.expected
2124 echo "Stopping histedit for amending commit $old_commit2" \
2125 >> $testroot/stdout.expected
2126 cmp -s $testroot/stdout.expected
$testroot/stdout
2128 if [ $ret -ne 0 ]; then
2129 diff -u $testroot/stdout.expected
$testroot/stdout
2130 test_done
"$testroot" "$ret"
2134 echo "edited zeta on master" > $testroot/wt
/epsilon
/zeta
2136 cat > $testroot/editor.sh
<<EOF
2139 ,s/.*/committing edited changes 2/
2143 chmod +x
$testroot/editor.sh
2145 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
2146 VISUAL
="$testroot/editor.sh" got histedit
-c > $testroot/stdout
)
2148 local new_commit2
=`git_show_head $testroot/repo`
2149 local short_new_commit2
=`trim_obj_id 12 $new_commit2`
2151 echo -n "$short_old_commit2 -> $short_new_commit2: " \
2152 > $testroot/stdout.expected
2153 echo "committing edited changes 2" >> $testroot/stdout.expected
2154 echo "Switching work tree to refs/heads/master" \
2155 >> $testroot/stdout.expected
2157 cmp -s $testroot/stdout.expected
$testroot/stdout
2159 if [ $ret -ne 0 ]; then
2160 diff -u $testroot/stdout.expected
$testroot/stdout
2161 test_done
"$testroot" "$ret"
2165 echo "edited modified alpha on master" > $testroot/content.expected
2166 cat $testroot/wt
/alpha
> $testroot/content
2167 cmp -s $testroot/content.expected
$testroot/content
2169 if [ $ret -ne 0 ]; then
2170 diff -u $testroot/content.expected
$testroot/content
2171 test_done
"$testroot" "$ret"
2175 if [ -e $testroot/wt
/beta
]; then
2176 echo "removed file beta still exists on disk" >&2
2177 test_done
"$testroot" "1"
2181 echo "new file on master" > $testroot/content.expected
2182 cat $testroot/wt
/epsilon
/new
> $testroot/content
2183 cmp -s $testroot/content.expected
$testroot/content
2185 if [ $ret -ne 0 ]; then
2186 diff -u $testroot/content.expected
$testroot/content
2187 test_done
"$testroot" "$ret"
2191 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2193 echo -n > $testroot/stdout.expected
2194 cmp -s $testroot/stdout.expected
$testroot/stdout
2196 if [ $ret -ne 0 ]; then
2197 diff -u $testroot/stdout.expected
$testroot/stdout
2198 test_done
"$testroot" "$ret"
2202 (cd $testroot/wt
&& got log
-l3 |
grep ^commit
> $testroot/stdout
)
2203 echo "commit $new_commit2 (master)" > $testroot/stdout.expected
2204 echo "commit $new_commit1" >> $testroot/stdout.expected
2205 echo "commit $orig_commit" >> $testroot/stdout.expected
2206 cmp -s $testroot/stdout.expected
$testroot/stdout
2208 if [ $ret -ne 0 ]; then
2209 diff -u $testroot/stdout.expected
$testroot/stdout
2211 test_done
"$testroot" "$ret"
2214 test_histedit_prepend_line
() {
2215 local testroot
=`test_init histedit_prepend_line`
2216 local orig_commit
=`git_show_head $testroot/repo`
2218 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2220 ed
-s "$testroot/wt/alpha" <<EOF
2227 cp $testroot/wt
/alpha
$testroot/content.expected
2229 (cd $testroot/wt
/ && got commit
-m 'modified alpha on master' \
2232 if [ $ret -ne 0 ]; then
2233 echo "got commit failed unexpectedly" >&2
2234 test_done
"$testroot" "$ret"
2238 local top_commit
=`git_show_head $testroot/repo`
2239 echo "pick $top_commit" > "$testroot/histedit-script"
2241 (cd $testroot/wt
/ && got update
-c $orig_commit > /dev
/null
)
2243 if [ $ret -ne 0 ]; then
2244 echo "got update failed unexpectedly" >&2
2245 test_done
"$testroot" "$ret"
2249 (cd $testroot/wt
&& got histedit
-F "$testroot/histedit-script" \
2252 if [ $ret -ne 0 ]; then
2253 echo "got histedit failed unexpectedly" >&2
2254 test_done
"$testroot" "$ret"
2258 cp $testroot/wt
/alpha
$testroot/content
2259 cmp -s $testroot/content.expected
$testroot/content
2261 if [ $ret -ne 0 ]; then
2262 diff -u $testroot/content.expected
$testroot/content
2263 test_done
"$testroot" "$ret"
2267 test_done
"$testroot" $ret
2270 test_histedit_resets_committer
() {
2271 local testroot
=`test_init histedit_resets_committer`
2272 local orig_commit
=`git_show_head $testroot/repo`
2273 local committer
="Flan Luck <flan_luck@openbsd.org>"
2275 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
2277 echo "modified alpha" > $testroot/wt
/alpha
2279 (cd $testroot/wt
/ && got commit
-m 'modified alpha on master' \
2282 if [ $ret -ne 0 ]; then
2283 echo "got commit failed unexpectedly" >&2
2284 test_done
"$testroot" "$ret"
2288 local top_commit
=`git_show_head $testroot/repo`
2289 echo "pick $top_commit" > "$testroot/histedit-script"
2291 (cd $testroot/wt
/ && got update
-c $orig_commit > /dev
/null
)
2293 if [ $ret -ne 0 ]; then
2294 echo "got update failed unexpectedly" >&2
2295 test_done
"$testroot" "$ret"
2299 (cd $testroot/wt
&& env GOT_AUTHOR
="$committer" \
2300 got histedit
-F "$testroot/histedit-script" > /dev
/null
)
2302 if [ $ret -ne 0 ]; then
2303 echo "got histedit failed unexpectedly" >&2
2304 test_done
"$testroot" "$ret"
2307 local edited_commit
=`git_show_head $testroot/repo`
2309 # Original commit only had one author
2310 (cd $testroot/repo
&& got log
-l1 -c $top_commit | \
2311 egrep '^(from|via):' > $testroot/stdout
)
2312 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2313 cmp -s $testroot/stdout.expected
$testroot/stdout
2315 if [ $ret -ne 0 ]; then
2316 diff -u $testroot/stdout.expected
$testroot/stdout
2317 test_done
"$testroot" "$ret"
2321 # Edited commit should have new committer name added
2322 (cd $testroot/repo
&& got log
-l1 -c $edited_commit | \
2323 egrep '^(from|via):' > $testroot/stdout
)
2324 echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2325 echo "via: $committer" >> $testroot/stdout.expected
2327 cmp -s $testroot/stdout.expected
$testroot/stdout
2329 if [ $ret -ne 0 ]; then
2330 diff -u $testroot/stdout.expected
$testroot/stdout
2332 test_done
"$testroot" "$ret"
2335 test_histedit_umask
() {
2336 local testroot
=`test_init histedit_umask`
2337 local orig_commit
=`git_show_head "$testroot/repo"`
2339 got checkout
"$testroot/repo" "$testroot/wt" >/dev
/null
2341 echo "modified alpha" > $testroot/wt
/alpha
2342 (cd "$testroot/wt" && got commit
-m 'edit #1') >/dev
/null
2343 local commit1
=`git_show_head "$testroot/repo"`
2345 echo "modified again" > $testroot/wt
/alpha
2346 (cd "$testroot/wt" && got commit
-m 'edit #2') >/dev
/null
2347 local commit2
=`git_show_head "$testroot/repo"`
2349 echo "modified again!" > $testroot/wt
/alpha
2350 echo "modify beta too!" > $testroot/wt
/beta
2351 (cd "$testroot/wt" && got commit
-m 'edit #3') >/dev
/null
2352 local commit3
=`git_show_head "$testroot/repo"`
2354 (cd "$testroot/wt" && got update
-c "$orig_commit") >/dev
/null
2356 if [ $ret -ne 0 ]; then
2357 echo "update to $orig_commit failed!" >&2
2358 test_done
"$testroot" 1
2362 cat > $testroot/editor.sh
<<EOF
2365 ,s/.*/folding changes/
2369 chmod +x
$testroot/editor.sh
2371 echo fold $commit1 >$testroot/histedit-script
2372 echo fold $commit2 >>$testroot/histedit-script
2373 echo pick
$commit3 >>$testroot/histedit-script
2375 # using a subshell to avoid clobbering global umask
2376 (umask 077 && cd "$testroot/wt" && \
2377 env EDITOR
="$testroot/editor.sh" VISUAL
="$testroot/editor.sh" \
2378 got histedit
-F "$testroot/histedit-script") >/dev
/null
2381 if [ $ret -ne 0 ]; then
2382 echo "histedit operation failed" >&2
2383 test_done
"$testroot" $ret
2387 for f
in alpha beta
; do
2388 ls -l "$testroot/wt/$f" |
grep -q ^
-rw-------
2389 if [ $?
-ne 0 ]; then
2390 echo "$f is not 0600 after histedi" >&2
2391 ls -l "$testroot/wt/$f" >&2
2392 test_done
"$testroot" 1
2397 test_done
"$testroot" 0
2400 test_histedit_mesg_filemode_change
() {
2401 local testroot
=`test_init histedit_mode_change`
2403 local orig_commit
=`git_show_head $testroot/repo`
2404 local orig_author_time
=`git_show_author_time $testroot/repo`
2406 chmod +x
$testroot/repo
/alpha
2407 git_commit
$testroot/repo
-m "set x bit on alpha"
2408 local old_commit1
=`git_show_head $testroot/repo`
2409 local old_author_time1
=`git_show_author_time $testroot/repo`
2411 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
2413 if [ $ret -ne 0 ]; then
2414 test_done
"$testroot" "$ret"
2418 if [ -x $testroot/wt
/alpha
]; then
2419 echo "file alpha has unexpected executable bit" >&2
2420 test_done
"$testroot" "1"
2424 cat > $testroot/editor.sh
<<EOF
2427 ,s/ x bit / executable bit /
2432 chmod +x
$testroot/editor.sh
2434 (cd $testroot/wt
&& env VISUAL
="$testroot/editor.sh" \
2435 got histedit
-m > $testroot/stdout
)
2437 local new_commit1
=`git_show_head $testroot/repo`
2438 local new_author_time1
=`git_show_author_time $testroot/repo`
2440 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
2441 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
2443 echo "G alpha" > $testroot/stdout.expected
2444 echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \
2445 >> $testroot/stdout.expected
2446 echo "Switching work tree to refs/heads/master" \
2447 >> $testroot/stdout.expected
2449 cmp -s $testroot/stdout.expected
$testroot/stdout
2451 if [ $ret -ne 0 ]; then
2452 diff -u $testroot/stdout.expected
$testroot/stdout
2453 test_done
"$testroot" "$ret"
2457 echo "alpha" > $testroot/content.expected
2458 cmp -s $testroot/content.expected
$testroot/wt
/alpha
2460 if [ $ret -ne 0 ]; then
2461 diff -u $testroot/content.expected
$testroot/wt
/alpha
2462 test_done
"$testroot" "$ret"
2466 if [ ! -x $testroot/wt
/alpha
]; then
2467 echo "file alpha lost its executable bit" >&2
2468 test_done
"$testroot" "1"
2472 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2474 echo -n > $testroot/stdout.expected
2475 cmp -s $testroot/stdout.expected
$testroot/stdout
2477 if [ $ret -ne 0 ]; then
2478 diff -u $testroot/stdout.expected
$testroot/stdout
2479 test_done
"$testroot" "$ret"
2483 (cd $testroot/wt
&& got log
-l1 |
grep ' set executable bit on alpha' \
2486 echo ' set executable bit on alpha' > $testroot/stdout.expected
2487 cmp -s $testroot/stdout.expected
$testroot/stdout
2489 if [ $ret -ne 0 ]; then
2490 diff -u $testroot/stdout.expected
$testroot/stdout
2491 test_done
"$testroot" "$ret"
2495 test_done
"$testroot" "$ret"
2498 test_histedit_drop_only
() {
2499 local testroot
=`test_init histedit_drop_only`
2501 local orig_commit
=`git_show_head $testroot/repo`
2502 local drop
="-> drop commit:"
2503 local dropmsg
="commit changes to drop"
2505 echo "modified alpha on master" > $testroot/repo
/alpha
2506 git
-C $testroot/repo
rm -q beta
2507 echo "new file on master" > $testroot/repo
/epsilon
/new
2508 git
-C $testroot/repo add epsilon
/new
2510 git_commit
$testroot/repo
-m "$dropmsg 1"
2511 local drop_commit1
=`git_show_head $testroot/repo`
2513 echo "modified zeta on master" > $testroot/repo
/epsilon
/zeta
2515 git_commit
$testroot/repo
-m "$dropmsg 2"
2516 local drop_commit2
=`git_show_head $testroot/repo`
2518 echo "modified delta on master" > $testroot/repo
/gamma
/delta
2520 git_commit
$testroot/repo
-m "$dropmsg 3"
2521 local drop_commit3
=`git_show_head $testroot/repo`
2523 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
2525 if [ $ret -ne 0 ]; then
2526 test_done
"$testroot" "$ret"
2530 (cd $testroot/wt
&& got histedit
-d > $testroot/stdout
)
2531 local new_commit1
=`git_show_head $testroot/repo`
2533 local short_commit1
=`trim_obj_id 12 $drop_commit1`
2534 local short_commit2
=`trim_obj_id 12 $drop_commit2`
2535 local short_commit3
=`trim_obj_id 12 $drop_commit3`
2537 echo "$short_commit1 $drop $dropmsg 1" > $testroot/stdout.expected
2538 echo "$short_commit2 $drop $dropmsg 2" >> $testroot/stdout.expected
2539 echo "$short_commit3 $drop $dropmsg 3" >> $testroot/stdout.expected
2540 echo "Switching work tree to refs/heads/master" \
2541 >> $testroot/stdout.expected
2543 cmp -s $testroot/stdout.expected
$testroot/stdout
2545 if [ $ret -ne 0 ]; then
2546 diff -u $testroot/stdout.expected
$testroot/stdout
2547 test_done
"$testroot" "$ret"
2551 echo "alpha" > $testroot/content.expected
2552 cat $testroot/wt
/alpha
> $testroot/content
2553 cmp -s $testroot/content.expected
$testroot/content
2555 if [ $ret -ne 0 ]; then
2556 diff -u $testroot/content.expected
$testroot/content
2557 test_done
"$testroot" "$ret"
2561 echo "zeta" > $testroot/content.expected
2562 cat $testroot/wt
/epsilon
/zeta
> $testroot/content
2563 cmp -s $testroot/content.expected
$testroot/content
2565 if [ $ret -ne 0 ]; then
2566 diff -u $testroot/content.expected
$testroot/content
2567 test_done
"$testroot" "$ret"
2571 echo "delta" > $testroot/content.expected
2572 cat $testroot/wt
/gamma
/delta
> $testroot/content
2573 cmp -s $testroot/content.expected
$testroot/content
2575 if [ $ret -ne 0 ]; then
2576 diff -u $testroot/content.expected
$testroot/content
2577 test_done
"$testroot" "$ret"
2581 if [ ! -e $testroot/wt
/beta
]; then
2582 echo "removed file beta should be restored" >&2
2583 test_done
"$testroot" "1"
2587 if [ -e $testroot/wt
/new
]; then
2588 echo "new file should no longer exist" >&2
2589 test_done
"$testroot" "$ret"
2593 (cd $testroot/wt
&& got status
> $testroot/stdout
)
2595 echo -n > $testroot/stdout.expected
2596 cmp -s $testroot/stdout.expected
$testroot/stdout
2598 if [ $ret -ne 0 ]; then
2599 diff -u $testroot/stdout.expected
$testroot/stdout
2600 test_done
"$testroot" "$ret"
2604 (cd $testroot/wt
&& got log |
grep ^commit
> $testroot/stdout
)
2605 echo "commit $orig_commit (master)" > $testroot/stdout.expected
2606 cmp -s $testroot/stdout.expected
$testroot/stdout
2608 if [ $ret -ne 0 ]; then
2609 diff -u $testroot/stdout.expected
$testroot/stdout
2611 test_done
"$testroot" "$ret"
2614 test_histedit_conflict_revert
() {
2615 local testroot
=`test_init histedit_conflict_revert`
2616 local orig_commit
=`git_show_head $testroot/repo`
2618 echo "first change of alpha" > $testroot/repo
/alpha
2619 git_commit
$testroot/repo
-m "committing changes"
2620 local old_commit1
=`git_show_head $testroot/repo`
2621 local short_old_commit1
=`trim_obj_id 12 $old_commit1`
2623 echo "second change of alpha" > $testroot/repo
/alpha
2624 git_commit
$testroot/repo
-m "committing changes"
2625 local old_commit2
=`git_show_head $testroot/repo`
2626 local short_old_commit2
=`trim_obj_id 12 $old_commit2`
2628 echo "third change of alpha" > $testroot/repo
/alpha
2629 git_commit
$testroot/repo
-m "committing changes"
2630 local old_commit3
=`git_show_head $testroot/repo`
2631 local short_old_commit3
=`trim_obj_id 12 $old_commit3`
2633 got checkout
-c $orig_commit $testroot/repo
$testroot/wt
> /dev
/null
2635 if [ $ret -ne 0 ]; then
2636 test_done
"$testroot" "$ret"
2640 echo "edit $old_commit1" > $testroot/histedit-script
2641 echo "edit $old_commit2" >> $testroot/histedit-script
2642 echo "pick $old_commit3" >> $testroot/histedit-script
2644 (cd $testroot/wt
&& got histedit
-F $testroot/histedit-script \
2647 echo "G alpha" > $testroot/stdout.expected
2648 echo "Stopping histedit for amending commit $old_commit1" \
2649 >> $testroot/stdout.expected
2650 cmp -s $testroot/stdout.expected
$testroot/stdout
2652 if [ $ret -ne 0 ]; then
2653 diff -u $testroot/stdout.expected
$testroot/stdout
2654 test_done
"$testroot" "$ret"
2658 echo "tweaked first change of alpha" > $testroot/wt
/alpha
2660 cat > $testroot/editor.sh
<<EOF
2663 ,s/.*/committing changes/
2667 chmod +x
$testroot/editor.sh
2669 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
2670 VISUAL
="$testroot/editor.sh" \
2671 got histedit
-c > $testroot/stdout
2> $testroot/stderr
)
2673 local new_commit1
=$
(cd $testroot/wt
&& got info | \
2674 grep 'work tree base commit:' | cut
-d ' ' -f5)
2675 local short_new_commit1
=`trim_obj_id 12 $new_commit1`
2677 echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
2678 > $testroot/stdout.expected
2679 echo "C alpha" >> $testroot/stdout.expected
2680 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2681 echo "$short_old_commit2 -> merge conflict: committing changes" \
2682 >> $testroot/stdout.expected
2684 echo "got: conflicts must be resolved before histedit can continue" \
2685 > $testroot/stderr.expected
2687 cmp -s $testroot/stdout.expected
$testroot/stdout
2689 if [ $ret -ne 0 ]; then
2690 diff -u $testroot/stdout.expected
$testroot/stdout
2691 test_done
"$testroot" "$ret"
2695 cmp -s $testroot/stderr.expected
$testroot/stderr
2697 if [ $ret -ne 0 ]; then
2698 diff -u $testroot/stderr.expected
$testroot/stderr
2699 test_done
"$testroot" "$ret"
2703 (cd $testroot/wt
&& got revert alpha
> /dev
/null
)
2704 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
2705 VISUAL
="$testroot/editor.sh" \
2706 got histedit
-c > $testroot/stdout
2> $testroot/stderr
)
2708 echo "$short_old_commit2 -> no-op change: committing changes" \
2709 > $testroot/stdout.expected
2710 echo "C alpha" >> $testroot/stdout.expected
2711 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2712 echo "$short_old_commit3 -> merge conflict: committing changes" \
2713 >> $testroot/stdout.expected
2715 cmp -s $testroot/stdout.expected
$testroot/stdout
2717 if [ $ret -ne 0 ]; then
2718 diff -u $testroot/stdout.expected
$testroot/stdout
2719 test_done
"$testroot" "$ret"
2723 cmp -s $testroot/stderr.expected
$testroot/stderr
2725 if [ $ret -ne 0 ]; then
2726 diff -u $testroot/stderr.expected
$testroot/stderr
2727 test_done
"$testroot" "$ret"
2731 (cd $testroot/wt
&& got revert alpha
> /dev
/null
)
2732 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
2733 VISUAL
="$testroot/editor.sh" \
2734 got histedit
-c > $testroot/stdout
2> $testroot/stderr
)
2736 echo "$short_old_commit3 -> no-op change: committing changes" \
2737 > $testroot/stdout.expected
2738 echo "Switching work tree to refs/heads/master" \
2739 >> $testroot/stdout.expected
2741 cmp -s $testroot/stdout.expected
$testroot/stdout
2743 if [ $ret -ne 0 ]; then
2744 diff -u $testroot/stdout.expected
$testroot/stdout
2745 test_done
"$testroot" "$ret"
2749 echo -n > $testroot/stderr.expected
2750 cmp -s $testroot/stderr.expected
$testroot/stderr
2752 if [ $ret -ne 0 ]; then
2753 diff -u $testroot/stderr.expected
$testroot/stderr
2754 test_done
"$testroot" "$ret"
2758 test_done
"$testroot" "$ret"
2761 test_histedit_no_eof_newline
() {
2762 local testroot
=$
(test_init histedit_no_eof_newline
)
2763 local id_root
=$
(git_show_head
"$testroot/repo")
2765 got checkout
"$testroot/repo" "$testroot/wt" > /dev
/null
2767 echo -n "fubar" >> $testroot/wt
/alpha
2769 (cd "$testroot/wt" && got commit
-m 'no eof newline' > /dev
/null
)
2771 if [ $ret -ne 0 ]; then
2772 echo "got commit failed unexpectedly" >&2
2773 test_done
"$testroot" "$ret"
2777 cp $testroot/wt
/alpha
$testroot/content.expected
2779 (cd $testroot/wt
&& got update
-c :base
:- > /dev
/null
)
2781 if [ $ret -ne 0 ]; then
2782 echo "update to $id_root failed" >&2
2783 test_done
"$testroot" 1
2787 cat > $testroot/editor.sh
<<EOF
2790 ,s/ eof / terminating /
2794 chmod +x
$testroot/editor.sh
2796 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
2797 VISUAL
="$testroot/editor.sh" got histedit
-m > /dev
/null
)
2800 if [ $ret -ne 0 ]; then
2801 echo "histedit -m failed" >&2
2802 test_done
"$testroot" $ret
2806 cp $testroot/wt
/alpha
$testroot/content
2808 cmp -s $testroot/content.expected
$testroot/content
2810 if [ $ret -ne 0 ]; then
2811 diff -u $testroot/content.expected
$testroot/content
2812 test_done
"$testroot" "$ret"
2816 cat > $testroot/wt
/beta
<<-EOF
2827 (cd "$testroot/wt" && got commit
-m 'padding beta' > /dev
/null
)
2829 if [ $ret -ne 0 ]; then
2830 echo "got commit failed unexpectedly" >&2
2831 test_done
"$testroot" "$ret"
2835 local id
=$
(git_show_head
"$testroot/repo")
2837 cat > $testroot/wt
/beta
<<-EOF
2862 echo -n "fubar" >> $testroot/wt
/beta
2864 (cd "$testroot/wt" && got commit
-m 'beta no eof newline' > /dev
/null
)
2866 if [ $ret -ne 0 ]; then
2867 echo "got commit failed unexpectedly" >&2
2868 test_done
"$testroot" "$ret"
2872 cp $testroot/wt
/beta
$testroot/content.expected
2874 (cd $testroot/wt
&& got update
-c :base
:- > /dev
/null
)
2876 if [ $ret -ne 0 ]; then
2877 echo "update to $id failed" >&2
2878 test_done
"$testroot" 1
2882 (cd $testroot/wt
&& env EDITOR
="$testroot/editor.sh" \
2883 VISUAL
="$testroot/editor.sh" got histedit
-m > /dev
/null
)
2886 if [ $ret -ne 0 ]; then
2887 echo "histedit -m failed" >&2
2888 test_done
"$testroot" $ret
2892 cp $testroot/wt
/beta
$testroot/content
2894 cmp -s $testroot/content.expected
$testroot/content
2896 if [ $ret -ne 0 ]; then
2897 diff -u $testroot/content.expected
$testroot/content
2898 test_done
"$testroot" "$ret"
2902 test_done
"$testroot" 0
2906 run_test test_histedit_no_op
2907 run_test test_histedit_swap
2908 run_test test_histedit_drop
2909 run_test test_histedit_fold
2910 run_test test_histedit_edit
2911 run_test test_histedit_fold_last_commit
2912 run_test test_histedit_missing_commit_pick
2913 run_test test_histedit_missing_commit_mesg
2914 run_test test_histedit_abort
2915 run_test test_histedit_path_prefix_drop
2916 run_test test_histedit_path_prefix_edit
2917 run_test test_histedit_outside_refs_heads
2918 run_test test_histedit_fold_last_commit_swap
2919 run_test test_histedit_split_commit
2920 run_test test_histedit_duplicate_commit_in_script
2921 run_test test_histedit_fold_add_delete
2922 run_test test_histedit_fold_edit_delete
2923 run_test test_histedit_fold_delete_add
2924 run_test test_histedit_fold_only
2925 run_test test_histedit_fold_only_empty_logmsg
2926 run_test test_histedit_edit_only
2927 run_test test_histedit_prepend_line
2928 run_test test_histedit_resets_committer
2929 run_test test_histedit_umask
2930 run_test test_histedit_mesg_filemode_change
2931 run_test test_histedit_drop_only
2932 run_test test_histedit_conflict_revert
2933 run_test test_histedit_no_eof_newline