Skip to content

Commit 6a54d97

Browse files
chriscoolgitster
authored andcommitted
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>
1 parent c9c4e2d commit 6a54d97

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

git-bisect.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,17 @@ We continue anyway.
384384
EOF
385385
}
386386

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+
#
387398
check_merge_bases() {
388399
_bad="$1"
389400
_good="$2"
@@ -398,12 +409,20 @@ check_merge_bases() {
398409
handle_skipped_merge_base "$_mb" "$_bad" "$_good"
399410
else
400411
bisect_checkout "$_mb" "a merge base must be tested"
401-
checkout_done=1
402-
return
412+
return 1
403413
fi
404414
done
415+
return 0
405416
}
406417

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+
#
407426
check_good_are_ancestors_of_bad() {
408427
test -f "$GIT_DIR/BISECT_ANCESTORS_OK" &&
409428
return
@@ -417,11 +436,13 @@ check_good_are_ancestors_of_bad() {
417436

418437
_side=$(git rev-list $_good ^$_bad)
419438
if test -n "$_side"; then
439+
# Return if a checkout was done
420440
check_merge_bases "$_bad" "$_good" "$_skip" || return
421-
test "$checkout_done" -eq "1" && return
422441
fi
423442

424443
: > "$GIT_DIR/BISECT_ANCESTORS_OK"
444+
445+
return 0
425446
}
426447

427448
bisect_next() {
@@ -437,8 +458,9 @@ bisect_next() {
437458
"refs/bisect/skip-*" | tr '\012' ' ') &&
438459

439460
# 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
442464

443465
# Get bisection information
444466
BISECT_OPT=''

0 commit comments

Comments
 (0)