Skip to content

Commit f989cac

Browse files
heggegitster
authored andcommitted
bisect: Log possibly bad, skipped commits at bisection end
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 118f60e commit f989cac

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

git-bisect.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,16 @@ bisect_next() {
317317
bad_commit=$(git show-branch $bad_rev)
318318
echo "# first bad commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG"
319319
exit 0
320+
elif test $res -eq 2
321+
then
322+
echo "# only skipped commits left to test" >>"$GIT_DIR/BISECT_LOG"
323+
good_revs=$(git for-each-ref --format="--not %(objectname)" "refs/bisect/good-*")
324+
for skipped in $(git rev-list refs/bisect/bad $good_revs)
325+
do
326+
skipped_commit=$(git show-branch $skipped)
327+
echo "# possible first bad commit: $skipped_commit" >>"$GIT_DIR/BISECT_LOG"
328+
done
329+
exit $res
320330
fi
321331

322332
# Check for an error in the bisection process

t/t6030-bisect-porcelain.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,4 +759,24 @@ test_expect_success 'bisect log: successfull result' '
759759
git bisect reset
760760
'
761761

762+
cat > expected.bisect-skip-log <<EOF
763+
# bad: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
764+
# good: [7b7f204a749c3125d5224ed61ea2ae1187ad046f] Add <2: A new day for git> into <hello>.
765+
git bisect start '32a594a3fdac2d57cf6d02987e30eec68511498c' '7b7f204a749c3125d5224ed61ea2ae1187ad046f'
766+
# skip: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.
767+
git bisect skip 3de952f2416b6084f557ec417709eac740c6818c
768+
# only skipped commits left to test
769+
# possible first bad commit: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
770+
# possible first bad commit: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.
771+
EOF
772+
773+
test_expect_success 'bisect log: only skip commits left' '
774+
git bisect reset &&
775+
git bisect start $HASH4 $HASH2 &&
776+
test_must_fail git bisect skip &&
777+
git bisect log >bisect-skip-log.txt &&
778+
test_cmp expected.bisect-skip-log bisect-skip-log.txt &&
779+
git bisect reset
780+
'
781+
762782
test_done

0 commit comments

Comments
 (0)