@@ -69,14 +69,19 @@ bisect_start() {
6969 head=$( GIT_DIR=" $GIT_DIR " git symbolic-ref -q HEAD) ||
7070 head=$( GIT_DIR=" $GIT_DIR " git rev-parse --verify HEAD) ||
7171 die " Bad HEAD - I need a HEAD"
72+ #
73+ # Check that we either already have BISECT_START, or that the
74+ # branches bisect, new-bisect don't exist, to not override them.
75+ #
76+ test -s " $GIT_DIR /BISECT_START" ||
77+ if git show-ref --verify -q refs/heads/bisect ||
78+ git show-ref --verify -q refs/heads/new-bisect; then
79+ die ' The branches "bisect" and "new-bisect" must not exist.'
80+ fi
7281 start_head=' '
7382 case " $head " in
7483 refs/heads/bisect)
75- if [ -s " $GIT_DIR /BISECT_START" ]; then
76- branch=` cat " $GIT_DIR /BISECT_START" `
77- else
78- branch=master
79- fi
84+ branch=` cat " $GIT_DIR /BISECT_START" `
8085 git checkout $branch || exit
8186 ;;
8287 refs/heads/* |$_x40 )
@@ -219,18 +224,33 @@ bisect_auto_next() {
219224 bisect_next_check && bisect_next || :
220225}
221226
227+ eval_rev_list () {
228+ _eval=" $1 "
229+
230+ eval $_eval
231+ res=$?
232+
233+ if [ $res -ne 0 ]; then
234+ echo >&2 " 'git rev-list --bisect-vars' failed:"
235+ echo >&2 " maybe you mistake good and bad revs?"
236+ exit $res
237+ fi
238+
239+ return $res
240+ }
241+
222242filter_skipped () {
223243 _eval=" $1 "
224244 _skip=" $2 "
225245
226246 if [ -z " $_skip " ]; then
227- eval $_eval
247+ eval_rev_list " $_eval "
228248 return
229249 fi
230250
231251 # Let's parse the output of:
232252 # "git rev-list --bisect-vars --bisect-all ..."
233- eval $_eval | while read hash line
253+ eval_rev_list " $_eval " | while read hash line
234254 do
235255 case " $VARS ,$FOUND ,$TRIED ,$hash " in
236256 # We display some vars.
@@ -328,8 +348,8 @@ bisect_next() {
328348 exit_if_skipped_commits " $bisect_rev "
329349
330350 echo " Bisecting: $bisect_nr revisions left to test after this"
331- git branch -f new-bisect " $bisect_rev "
332- git checkout -q new-bisect || exit
351+ git branch -D new-bisect 2> /dev/null
352+ git checkout -q -b new-bisect " $bisect_rev " || exit
333353 git branch -M new-bisect bisect
334354 git show-branch " $bisect_rev "
335355}
0 commit comments