bisect: add tests to document expected behaviour in presence of broken trees.
If the repo is broken, we expect bisect to fail. Signed-off-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jon Seymour committed
Aug 4, 2011 at 22:00 UTC
d3dfeedf2ec8c72bceaabf4e109c19a14576d333
1 file changed
+48
t/t6030-bisect-porcelain.sh
+48
@@ -581,5 +581,53 @@ test_expect_success 'erroring out when using bad path parameters' '
581
'
582
583
#
584
+# This creates a broken branch which cannot be checked out because
585
+# the tree created has been deleted.
586
#
587
+# H1-H2-H3-H4-H5-H6-H7 <--other
588
+# \
589
+# S5-S6'-S7'-S8'-S9 <--broken
590
+#
591
+# Commits marked with ' have a missing tree.
592
+#
593
+test_expect_success 'broken branch creation' '
594
+ git bisect reset &&
595
+ git checkout -b broken $HASH4 &&
596
+ git tag BROKEN_HASH4 $HASH4 &&
597
+ add_line_into_file "5(broken): first line on a broken branch" hello2 &&
598
+ git tag BROKEN_HASH5 &&
599
+ mkdir missing &&
600
+ :> missing/MISSING &&
601
+ git add missing/MISSING &&
602
+ git commit -m "6(broken): Added file that will be deleted"
603
+ git tag BROKEN_HASH6 &&
604
+ add_line_into_file "7(broken): second line on a broken branch" hello2 &&
605
+ git tag BROKEN_HASH7 &&
606
+ add_line_into_file "8(broken): third line on a broken branch" hello2 &&
607
+ git tag BROKEN_HASH8 &&
608
+ git rm missing/MISSING &&
609
+ git commit -m "9(broken): Remove missing file"
610
+ git tag BROKEN_HASH9 &&
611
+ rm .git/objects/39/f7e61a724187ab767d2e08442d9b6b9dab587d
612
+'
613
+
614
+echo "" > expected.ok
615
+cat > expected.missing-tree.default <<EOF
616
+fatal: unable to read tree 39f7e61a724187ab767d2e08442d9b6b9dab587d
617
+EOF
618
+
619
+test_expect_success 'bisect fails if tree is broken on start commit' '
620
+ git bisect reset &&
621
+ test_must_fail git bisect start BROKEN_HASH7 BROKEN_HASH4 2>error.txt &&
622
+ test_cmp expected.missing-tree.default error.txt
623
+'
624
+
625
+test_expect_success 'bisect fails if tree is broken on trial commit' '
626
+ git bisect reset &&
627
+ test_must_fail git bisect start BROKEN_HASH9 BROKEN_HASH4 2>error.txt &&
628
+ git reset --hard broken &&
629
+ git checkout broken &&
630
+ test_cmp expected.missing-tree.default error.txt
631
+'
632
+
633
test_done