Skip to content

Commit

Permalink
bisect: add tests to document expected behaviour in presence of broke…
Browse files Browse the repository at this point in the history
…n trees.

If the repo is broken, we expect bisect to fail.

Signed-off-by: Jon Seymour <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
jonseymour authored and gitster committed Aug 4, 2011
1 parent 6ba7acf commit d3dfeed
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions t/t6030-bisect-porcelain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -581,5 +581,53 @@ test_expect_success 'erroring out when using bad path parameters' '
'

#
# This creates a broken branch which cannot be checked out because
# the tree created has been deleted.
#
# H1-H2-H3-H4-H5-H6-H7 <--other
# \
# S5-S6'-S7'-S8'-S9 <--broken
#
# Commits marked with ' have a missing tree.
#
test_expect_success 'broken branch creation' '
git bisect reset &&
git checkout -b broken $HASH4 &&
git tag BROKEN_HASH4 $HASH4 &&
add_line_into_file "5(broken): first line on a broken branch" hello2 &&
git tag BROKEN_HASH5 &&
mkdir missing &&
:> missing/MISSING &&
git add missing/MISSING &&
git commit -m "6(broken): Added file that will be deleted"
git tag BROKEN_HASH6 &&
add_line_into_file "7(broken): second line on a broken branch" hello2 &&
git tag BROKEN_HASH7 &&
add_line_into_file "8(broken): third line on a broken branch" hello2 &&
git tag BROKEN_HASH8 &&
git rm missing/MISSING &&
git commit -m "9(broken): Remove missing file"
git tag BROKEN_HASH9 &&
rm .git/objects/39/f7e61a724187ab767d2e08442d9b6b9dab587d
'

echo "" > expected.ok
cat > expected.missing-tree.default <<EOF
fatal: unable to read tree 39f7e61a724187ab767d2e08442d9b6b9dab587d
EOF

test_expect_success 'bisect fails if tree is broken on start commit' '
git bisect reset &&
test_must_fail git bisect start BROKEN_HASH7 BROKEN_HASH4 2>error.txt &&
test_cmp expected.missing-tree.default error.txt
'

test_expect_success 'bisect fails if tree is broken on trial commit' '
git bisect reset &&
test_must_fail git bisect start BROKEN_HASH9 BROKEN_HASH4 2>error.txt &&
git reset --hard broken &&
git checkout broken &&
test_cmp expected.missing-tree.default error.txt
'

test_done

0 comments on commit d3dfeed

Please sign in to comment.