Merge branch 'jc/docmake-perl'
[gitweb.git] / t / t6030-bisect-porcelain.sh
index db82259afe3f95d59d69225353b0d0b1aea4d472..2ba4b00e526eb00c5d236777f896772c6cad538b 100755 (executable)
@@ -71,6 +71,43 @@ test_expect_success 'bisect start with one bad and good' '
        git bisect next
 '
 
+test_expect_success 'bisect reset: back in the master branch' '
+       git bisect reset &&
+       echo "* master" > branch.expect &&
+       git branch > branch.output &&
+       cmp branch.expect branch.output
+'
+
+test_expect_success 'bisect reset: back in another branch' '
+       git checkout -b other &&
+       git bisect start &&
+       git bisect good $HASH1 &&
+       git bisect bad $HASH3 &&
+       git bisect reset &&
+       echo "  master" > branch.expect &&
+       echo "* other" >> branch.expect &&
+       git branch > branch.output &&
+       cmp branch.expect branch.output
+'
+
+test_expect_success 'bisect reset when not bisecting' '
+       git bisect reset &&
+       git branch > branch.output &&
+       cmp branch.expect branch.output
+'
+
+test_expect_success 'bisect reset removes packed refs' '
+       git bisect reset &&
+       git bisect start &&
+       git bisect good $HASH1 &&
+       git bisect bad $HASH3 &&
+       git pack-refs --all --prune &&
+       git bisect next &&
+       git bisect reset &&
+       test -z "$(git for-each-ref "refs/bisect/*")" &&
+       test -z "$(git for-each-ref "refs/heads/bisect")"
+'
+
 # $HASH1 is good, $HASH4 is bad, we skip $HASH3
 # but $HASH2 is bad,
 # so we should find $HASH2 as the first bad commit
@@ -167,9 +204,56 @@ test_expect_success 'bisect skip: add line and then a new test' '
        git bisect skip &&
        git bisect good > my_bisect_log.txt &&
        grep "$HASH5 is first bad commit" my_bisect_log.txt &&
+       git bisect log > log_to_replay.txt &&
        git bisect reset
 '
 
+test_expect_success 'bisect skip and bisect replay' '
+       git bisect replay log_to_replay.txt > my_bisect_log.txt &&
+       grep "$HASH5 is first bad commit" my_bisect_log.txt &&
+       git bisect reset
+'
+
+HASH6=
+test_expect_success 'bisect run & skip: cannot tell between 2' '
+       add_line_into_file "6: Yet a line." hello &&
+       HASH6=$(git rev-parse --verify HEAD) &&
+       echo "#"\!"/bin/sh" > test_script.sh &&
+       echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
+       echo "grep line hello > /dev/null" >> test_script.sh &&
+       echo "test \$? -ne 0" >> test_script.sh &&
+       chmod +x test_script.sh &&
+       git bisect start $HASH6 $HASH1 &&
+       if git bisect run ./test_script.sh > my_bisect_log.txt
+       then
+               echo Oops, should have failed.
+               false
+       else
+               test $? -eq 2 &&
+               grep "first bad commit could be any of" my_bisect_log.txt &&
+               ! grep $HASH3 my_bisect_log.txt &&
+               ! grep $HASH6 my_bisect_log.txt &&
+               grep $HASH4 my_bisect_log.txt &&
+               grep $HASH5 my_bisect_log.txt
+       fi
+'
+
+HASH7=
+test_expect_success 'bisect run & skip: find first bad' '
+       git bisect reset &&
+       add_line_into_file "7: Should be the last line." hello &&
+       HASH7=$(git rev-parse --verify HEAD) &&
+       echo "#"\!"/bin/sh" > test_script.sh &&
+       echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
+       echo "tail -1 hello | grep day > /dev/null && exit 125" >> test_script.sh &&
+       echo "grep Yet hello > /dev/null" >> test_script.sh &&
+       echo "test \$? -ne 0" >> test_script.sh &&
+       chmod +x test_script.sh &&
+       git bisect start $HASH7 $HASH1 &&
+       git bisect run ./test_script.sh > my_bisect_log.txt &&
+       grep "$HASH6 is first bad commit" my_bisect_log.txt
+'
+
 #
 #
 test_done