bisect: Log possibly bad, skipped commits at bisection end
authorTorstein Hegge <hegge@resisty.net>
Mon, 22 Apr 2013 21:02:29 +0000 (23:02 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Apr 2013 16:09:44 +0000 (09:09 -0700)
If the bisection completes with only skipped commits left to as possible
first bad commit, output the list of possible first bad commits to human
readers of the bisection log.

Signed-off-by: Torstein Hegge <hegge@resisty.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-bisect.sh
t/t6030-bisect-porcelain.sh
index c58eea7cb6b34d69e812d2bac8f514272f679beb..d7518e9c3b2cdf16da10b791a0591dc2347fd168 100755 (executable)
@@ -317,6 +317,16 @@ bisect_next() {
                bad_commit=$(git show-branch $bad_rev)
                echo "# first bad commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG"
                exit 0
+       elif test $res -eq 2
+       then
+               echo "# only skipped commits left to test" >>"$GIT_DIR/BISECT_LOG"
+               good_revs=$(git for-each-ref --format="--not %(objectname)" "refs/bisect/good-*")
+               for skipped in $(git rev-list refs/bisect/bad $good_revs)
+               do
+                       skipped_commit=$(git show-branch $skipped)
+                       echo "# possible first bad commit: $skipped_commit" >>"$GIT_DIR/BISECT_LOG"
+               done
+               exit $res
        fi
 
        # Check for an error in the bisection process
index 4d3074a45cdaf768ea9d46049f5b8eb6da095056..064f5cefeb4cf7e3bfa2c104384094492dc54f91 100755 (executable)
@@ -759,4 +759,24 @@ test_expect_success 'bisect log: successfull result' '
        git bisect reset
 '
 
+cat > expected.bisect-skip-log <<EOF
+# bad: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
+# good: [7b7f204a749c3125d5224ed61ea2ae1187ad046f] Add <2: A new day for git> into <hello>.
+git bisect start '32a594a3fdac2d57cf6d02987e30eec68511498c' '7b7f204a749c3125d5224ed61ea2ae1187ad046f'
+# skip: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.
+git bisect skip 3de952f2416b6084f557ec417709eac740c6818c
+# only skipped commits left to test
+# possible first bad commit: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
+# possible first bad commit: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.
+EOF
+
+test_expect_success 'bisect log: only skip commits left' '
+       git bisect reset &&
+       git bisect start $HASH4 $HASH2 &&
+       test_must_fail git bisect skip &&
+       git bisect log >bisect-skip-log.txt &&
+       test_cmp expected.bisect-skip-log bisect-skip-log.txt &&
+       git bisect reset
+'
+
 test_done