@@ -168,26 +168,40 @@ bisect_write_good() {
168168}
169169
170170bisect_next_check () {
171- next_ok=no
172- git show-ref -q --verify refs/bisect/bad &&
173- test -n " $( git for-each-ref " refs/bisect/good-*" ) " &&
174- next_ok=yes
175-
176- case " $next_ok ,$1 " in
177- no,) false ;;
178- no,fail)
179- THEN=' '
180- test -d " $GIT_DIR /refs/bisect" || {
181- echo >&2 ' You need to start by "git bisect start".'
182- THEN=' then '
183- }
184- echo >&2 ' You ' $THEN ' need to give me at least one good' \
185- ' and one bad revisions.'
186- echo >&2 ' (You can use "git bisect bad" and' \
187- ' "git bisect good" for that.)'
188- exit 1 ;;
171+ missing_good= missing_bad=
172+ git show-ref -q --verify refs/bisect/bad || missing_bad=t
173+ test -n " $( git for-each-ref " refs/bisect/good-*" ) " || missing_good=t
174+
175+ case " $missing_good ,$missing_bad ,$1 " in
176+ ,,* )
177+ : have both good and bad - ok
178+ ;;
179+ * ,)
180+ # do not have both but not asked to fail - just report.
181+ false
182+ ;;
183+ t,,good)
184+ # have bad but not good. we could bisect although
185+ # this is less optimum.
186+ echo >&2 ' Warning: bisecting only with a bad commit.'
187+ if test -t 0
188+ then
189+ printf >&2 ' Are you sure [Y/n]? '
190+ case " $( read yesno) " in [Nn]* ) exit 1 ;; esac
191+ fi
192+ : bisect without good...
193+ ;;
189194 * )
190- true ;;
195+ THEN=' '
196+ test -d " $GIT_DIR /refs/bisect" || {
197+ echo >&2 ' You need to start by "git bisect start".'
198+ THEN=' then '
199+ }
200+ echo >&2 ' You ' $THEN ' need to give me at least one good' \
201+ ' and one bad revisions.'
202+ echo >&2 ' (You can use "git bisect bad" and' \
203+ ' "git bisect good" for that.)'
204+ exit 1 ;;
191205 esac
192206}
193207
@@ -198,27 +212,32 @@ bisect_auto_next() {
198212bisect_next () {
199213 case " $# " in 0) ;; * ) usage ;; esac
200214 bisect_autostart
201- bisect_next_check fail
215+ bisect_next_check good
216+
202217 bad=$( git-rev-parse --verify refs/bisect/bad) &&
203- good=$( git-rev-parse --sq --revs-only --not \
204- $( cd " $GIT_DIR " && ls refs/bisect/good-* ) ) &&
205- rev=$( eval " git-rev-list --bisect $good $bad -- $( cat " $GIT_DIR /BISECT_NAMES" ) " ) || exit
206- if [ -z " $rev " ]; then
207- echo " $bad was both good and bad"
208- exit 1
218+ good=$( git for-each-ref --format=' ^%(objectname)' \
219+ " refs/bisect/good-*" | tr ' [\012]' ' ' ) &&
220+ eval=" git-rev-list --bisect-vars $good $bad --" &&
221+ eval=" $eval $( cat " $GIT_DIR /BISECT_NAMES" ) " &&
222+ eval=$( eval " $eval " ) &&
223+ eval " $eval " || exit
224+
225+ if [ -z " $bisect_rev " ]; then
226+ echo " $bad was both good and bad"
227+ exit 1
209228 fi
210- if [ " $rev " = " $bad " ]; then
211- echo " $rev is first bad commit"
212- git-diff-tree --pretty $rev
213- exit 0
229+ if [ " $bisect_rev " = " $bad " ]; then
230+ echo " $bisect_rev is first bad commit"
231+ git-diff-tree --pretty $bisect_rev
232+ exit 0
214233 fi
215- nr= $( eval " git-rev-list $rev $good -- $( cat $GIT_DIR /BISECT_NAMES ) " | wc -l ) || exit
216- echo " Bisecting: $nr revisions left to test after this"
217- echo " $rev " > " $GIT_DIR /refs/heads/new-bisect"
234+
235+ echo " Bisecting: $bisect_nr revisions left to test after this"
236+ echo " $bisect_rev " > " $GIT_DIR /refs/heads/new-bisect"
218237 git checkout -q new-bisect || exit
219238 mv " $GIT_DIR /refs/heads/new-bisect" " $GIT_DIR /refs/heads/bisect" &&
220239 GIT_DIR=" $GIT_DIR " git-symbolic-ref HEAD refs/heads/bisect
221- git-show-branch " $rev "
240+ git-show-branch " $bisect_rev "
222241}
223242
224243bisect_visualize () {
0 commit comments