]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bisect: Store first bad commit as comment in log file
authorTorstein Hegge <hegge@resisty.net>
Sat, 13 Apr 2013 15:22:57 +0000 (17:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Apr 2013 16:05:42 +0000 (09:05 -0700)
When bisect successfully finds a single revision, the first bad commit
should be shown to human readers of 'git bisect log'.

This resolves the apparent disconnect between the bisection result and
the log when a bug reporter says "I know that the first bad commit is
$rev, as you can see from $(git bisect 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 99efbe884528ffa730d6c0297e20d9de93d5ad9e..c58eea7cb6b34d69e812d2bac8f514272f679beb 100755 (executable)
@@ -311,7 +311,13 @@ bisect_next() {
        res=$?
 
        # Check if we should exit because bisection is finished
-       test $res -eq 10 && exit 0
+       if test $res -eq 10
+       then
+               bad_rev=$(git show-ref --hash --verify refs/bisect/bad)
+               bad_commit=$(git show-branch $bad_rev)
+               echo "# first bad commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG"
+               exit 0
+       fi
 
        # Check for an error in the bisection process
        test $res -ne 0 && exit $res
index 8bf53de3ef6bc7cc5de14b70e93ffe42b9b3f094..4d3074a45cdaf768ea9d46049f5b8eb6da095056 100755 (executable)
@@ -741,4 +741,22 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' "
        git bisect reset
 "
 
+cat > expected.bisect-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'
+# good: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.
+git bisect good 3de952f2416b6084f557ec417709eac740c6818c
+# first bad commit: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
+EOF
+
+test_expect_success 'bisect log: successfull result' '
+       git bisect reset &&
+       git bisect start $HASH4 $HASH2 &&
+       git bisect good &&
+       git bisect log >bisect-log.txt &&
+       test_cmp expected.bisect-log bisect-log.txt &&
+       git bisect reset
+'
+
 test_done