@@ -65,14 +65,19 @@ bisect_start() {
6565 head=$( GIT_DIR=" $GIT_DIR " git symbolic-ref -q HEAD) ||
6666 head=$( GIT_DIR=" $GIT_DIR " git rev-parse --verify HEAD) ||
6767 die " Bad HEAD - I need a HEAD"
68+ #
69+ # Check that we either already have BISECT_START, or that the
70+ # branches bisect, new-bisect don't exist, to not override them.
71+ #
72+ test -s " $GIT_DIR /BISECT_START" ||
73+ if git show-ref --verify -q refs/heads/bisect ||
74+ git show-ref --verify -q refs/heads/new-bisect; then
75+ die ' The branches "bisect" and "new-bisect" must not exist.'
76+ fi
6877 start_head=' '
6978 case " $head " in
7079 refs/heads/bisect)
71- if [ -s " $GIT_DIR /BISECT_START" ]; then
72- branch=` cat " $GIT_DIR /BISECT_START" `
73- else
74- branch=master
75- fi
80+ branch=` cat " $GIT_DIR /BISECT_START" `
7681 git checkout $branch || exit
7782 ;;
7883 refs/heads/* |$_x40 )
@@ -215,18 +220,33 @@ bisect_auto_next() {
215220 bisect_next_check && bisect_next || :
216221}
217222
223+ eval_rev_list () {
224+ _eval=" $1 "
225+
226+ eval $_eval
227+ res=$?
228+
229+ if [ $res -ne 0 ]; then
230+ echo >&2 " 'git rev-list --bisect-vars' failed:"
231+ echo >&2 " maybe you mistake good and bad revs?"
232+ exit $res
233+ fi
234+
235+ return $res
236+ }
237+
218238filter_skipped () {
219239 _eval=" $1 "
220240 _skip=" $2 "
221241
222242 if [ -z " $_skip " ]; then
223- eval $_eval
243+ eval_rev_list " $_eval "
224244 return
225245 fi
226246
227247 # Let's parse the output of:
228248 # "git rev-list --bisect-vars --bisect-all ..."
229- eval $_eval | while read hash line
249+ eval_rev_list " $_eval " | while read hash line
230250 do
231251 case " $VARS ,$FOUND ,$TRIED ,$hash " in
232252 # We display some vars.
@@ -324,8 +344,8 @@ bisect_next() {
324344 exit_if_skipped_commits " $bisect_rev "
325345
326346 echo " Bisecting: $bisect_nr revisions left to test after this"
327- git branch -f new-bisect " $bisect_rev "
328- git checkout -q new-bisect || exit
347+ git branch -D new-bisect 2> /dev/null
348+ git checkout -q -b new-bisect " $bisect_rev " || exit
329349 git branch -M new-bisect bisect
330350 git show-branch " $bisect_rev "
331351}
0 commit comments