@matheusbsbs / matheus-bagliano / commits / 6a54d976f6
Fork 0

bisect: remove "checkout_done" variable used when checking merge bases

Using return values from the following functions: - check_merge_bases - check_good_are_ancestors_of_bad seems simpler. While at it, let's add some comments to better document the above functions. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Sep 6, 2008 at 07:27 UTC 6a54d976f654ef15ce6db7d52c76677dfdd0de6c
1 file changed +27 -5
git-bisect.sh
+27 -5
@@ -384,6 +384,17 @@ We continue anyway.
384 EOF
385 }
386
387 +#
388 +# "check_merge_bases" checks that merge bases are not "bad".
389 +#
390 +# - If one is "good", that's good, we have nothing to do.
391 +# - If one is "bad", it means the user assumed something wrong
392 +# and we must exit.
393 +# - If one is "skipped", we can't know but we should warn.
394 +# - If we don't know, we should check it out and ask the user to test.
395 +#
396 +# In the last case we will return 1, and otherwise 0.
397 +#
398 check_merge_bases() {
399 _bad="$1"
400 _good="$2"
@@ -398,12 +409,20 @@ check_merge_bases() {
409 handle_skipped_merge_base "$_mb" "$_bad" "$_good"
410 else
411 bisect_checkout "$_mb" "a merge base must be tested"
401 - checkout_done=1
402 - return
412 + return 1
413 fi
414 done
415 + return 0
416 }
417
418 +#
419 +# "check_good_are_ancestors_of_bad" checks that all "good" revs are
420 +# ancestor of the "bad" rev.
421 +#
422 +# If that's not the case, we need to check the merge bases.
423 +# If a merge base must be tested by the user we return 1 and
424 +# otherwise 0.
425 +#
426 check_good_are_ancestors_of_bad() {
427 test -f "$GIT_DIR/BISECT_ANCESTORS_OK" &&
428 return
@@ -417,11 +436,13 @@ check_good_are_ancestors_of_bad() {
436
437 _side=$(git rev-list $_good ^$_bad)
438 if test -n "$_side"; then
439 + # Return if a checkout was done
440 check_merge_bases "$_bad" "$_good" "$_skip" || return
421 - test "$checkout_done" -eq "1" && return
441 fi
442
443 : > "$GIT_DIR/BISECT_ANCESTORS_OK"
444 +
445 + return 0
446 }
447
448 bisect_next() {
@@ -437,8 +458,9 @@ bisect_next() {
458 "refs/bisect/skip-*" | tr '\012' ' ') &&
459
460 # Maybe some merge bases must be tested first
440 - check_good_are_ancestors_of_bad "$bad" "$good" "$skip" || exit
441 - test "$checkout_done" -eq "1" && checkout_done='' && return
461 + check_good_are_ancestors_of_bad "$bad" "$good" "$skip"
462 + # Return now if a checkout has already been done
463 + test "$?" -eq "1" && return
464
465 # Get bisection information
466 BISECT_OPT=''