@matheusbsbs / matheus-bagliano / commits / 23b5f18b50
Fork 0

bisect: use "bisect--helper" and remove "filter_skipped" function

Use the new "git bisect--helper" builtin. It should be faster and safer instead of the old "filter_skipped" shell function. And it is a first step to move more shell code to C. As the output is a little bit different we have to change the code that interpret the results. But these changes improve code clarity. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Mar 26, 2009 at 05:56 UTC 23b5f18b50c15155f79618522b5721b880eceb65
1 file changed +12 -77
git-bisect.sh
+12 -77
@@ -279,76 +279,13 @@ bisect_auto_next() {
279 bisect_next_check && bisect_next || :
280 }
281
282 -filter_skipped() {
282 +eval_and_string_together() {
283 _eval="$1"
284 - _skip="$2"
285 -
286 - if [ -z "$_skip" ]; then
287 - eval "$_eval" | {
288 - while read line
289 - do
290 - echo "$line &&"
291 - done
292 - echo ':'
293 - }
294 - return
295 - fi
284
297 - # Let's parse the output of:
298 - # "git rev-list --bisect-vars --bisect-all ..."
285 eval "$_eval" | {
300 - VARS= FOUND= TRIED=
301 - while read hash line
286 + while read line
287 do
303 - case "$VARS,$FOUND,$TRIED,$hash" in
304 - 1,*,*,*)
305 - # "bisect_foo=bar" read from rev-list output.
306 - echo "$hash &&"
307 - ;;
308 - ,*,*,---*)
309 - # Separator
310 - ;;
311 - ,,,bisect_rev*)
312 - # We had nothing to search.
313 - echo "bisect_rev= &&"
314 - VARS=1
315 - ;;
316 - ,,*,bisect_rev*)
317 - # We did not find a good bisect rev.
318 - # This should happen only if the "bad"
319 - # commit is also a "skip" commit.
320 - echo "bisect_rev='$TRIED' &&"
321 - VARS=1
322 - ;;
323 - ,,*,*)
324 - # We are searching.
325 - TRIED="${TRIED:+$TRIED|}$hash"
326 - case "$_skip" in
327 - *$hash*) ;;
328 - *)
329 - echo "bisect_rev=$hash &&"
330 - echo "bisect_tried='$TRIED' &&"
331 - FOUND=1
332 - ;;
333 - esac
334 - ;;
335 - ,1,*,bisect_rev*)
336 - # We have already found a rev to be tested.
337 - VARS=1
338 - ;;
339 - ,1,*,*)
340 - ;;
341 - *)
342 - # Unexpected input
343 - echo "die 'filter_skipped error'"
344 - die "filter_skipped error " \
345 - "VARS: '$VARS' " \
346 - "FOUND: '$FOUND' " \
347 - "TRIED: '$TRIED' " \
348 - "hash: '$hash' " \
349 - "line: '$line'"
350 - ;;
351 - esac
288 + echo "$line &&"
289 done
290 echo ':'
291 }
@@ -356,10 +293,12 @@ filter_skipped() {
293
294 exit_if_skipped_commits () {
295 _tried=$1
359 - if expr "$_tried" : ".*[|].*" > /dev/null ; then
296 + _bad=$2
297 + if test -n "$_tried" ; then
298 echo "There are only 'skip'ped commit left to test."
299 echo "The first bad commit could be any of:"
300 echo "$_tried" | tr '[|]' '[\012]'
301 + test -n "$_bad" && echo "$_bad"
302 echo "We cannot bisect more!"
303 exit 2
304 fi
@@ -490,28 +429,24 @@ bisect_next() {
429 test "$?" -eq "1" && return
430
431 # Get bisection information
493 - BISECT_OPT=''
494 - test -n "$skip" && BISECT_OPT='--bisect-all'
495 - eval="git rev-list --bisect-vars $BISECT_OPT $good $bad --" &&
496 - eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
497 - eval=$(filter_skipped "$eval" "$skip") &&
432 + eval="git bisect--helper --next-vars" &&
433 + eval=$(eval_and_string_together "$eval") &&
434 eval "$eval" || exit
435
436 if [ -z "$bisect_rev" ]; then
437 + # We should exit here only if the "bad"
438 + # commit is also a "skip" commit (see above).
439 + exit_if_skipped_commits "$bisect_tried"
440 echo "$bad was both good and bad"
441 exit 1
442 fi
443 if [ "$bisect_rev" = "$bad" ]; then
505 - exit_if_skipped_commits "$bisect_tried"
444 + exit_if_skipped_commits "$bisect_tried" "$bad"
445 echo "$bisect_rev is first bad commit"
446 git diff-tree --pretty $bisect_rev
447 exit 0
448 fi
449
511 - # We should exit here only if the "bad"
512 - # commit is also a "skip" commit (see above).
513 - exit_if_skipped_commits "$bisect_rev"
514 -
450 bisect_checkout "$bisect_rev" "$bisect_nr revisions left to test after this (roughly $bisect_steps steps)"
451 }
452