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>maint
parent
c9c4e2d5a2
commit
6a54d976f6
|
@ -384,6 +384,17 @@ We continue anyway.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# "check_merge_bases" checks that merge bases are not "bad".
|
||||||
|
#
|
||||||
|
# - If one is "good", that's good, we have nothing to do.
|
||||||
|
# - If one is "bad", it means the user assumed something wrong
|
||||||
|
# and we must exit.
|
||||||
|
# - If one is "skipped", we can't know but we should warn.
|
||||||
|
# - If we don't know, we should check it out and ask the user to test.
|
||||||
|
#
|
||||||
|
# In the last case we will return 1, and otherwise 0.
|
||||||
|
#
|
||||||
check_merge_bases() {
|
check_merge_bases() {
|
||||||
_bad="$1"
|
_bad="$1"
|
||||||
_good="$2"
|
_good="$2"
|
||||||
|
@ -398,12 +409,20 @@ check_merge_bases() {
|
||||||
handle_skipped_merge_base "$_mb" "$_bad" "$_good"
|
handle_skipped_merge_base "$_mb" "$_bad" "$_good"
|
||||||
else
|
else
|
||||||
bisect_checkout "$_mb" "a merge base must be tested"
|
bisect_checkout "$_mb" "a merge base must be tested"
|
||||||
checkout_done=1
|
return 1
|
||||||
return
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# "check_good_are_ancestors_of_bad" checks that all "good" revs are
|
||||||
|
# ancestor of the "bad" rev.
|
||||||
|
#
|
||||||
|
# If that's not the case, we need to check the merge bases.
|
||||||
|
# If a merge base must be tested by the user we return 1 and
|
||||||
|
# otherwise 0.
|
||||||
|
#
|
||||||
check_good_are_ancestors_of_bad() {
|
check_good_are_ancestors_of_bad() {
|
||||||
test -f "$GIT_DIR/BISECT_ANCESTORS_OK" &&
|
test -f "$GIT_DIR/BISECT_ANCESTORS_OK" &&
|
||||||
return
|
return
|
||||||
|
@ -417,11 +436,13 @@ check_good_are_ancestors_of_bad() {
|
||||||
|
|
||||||
_side=$(git rev-list $_good ^$_bad)
|
_side=$(git rev-list $_good ^$_bad)
|
||||||
if test -n "$_side"; then
|
if test -n "$_side"; then
|
||||||
|
# Return if a checkout was done
|
||||||
check_merge_bases "$_bad" "$_good" "$_skip" || return
|
check_merge_bases "$_bad" "$_good" "$_skip" || return
|
||||||
test "$checkout_done" -eq "1" && return
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
: > "$GIT_DIR/BISECT_ANCESTORS_OK"
|
: > "$GIT_DIR/BISECT_ANCESTORS_OK"
|
||||||
|
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
bisect_next() {
|
bisect_next() {
|
||||||
|
@ -437,8 +458,9 @@ bisect_next() {
|
||||||
"refs/bisect/skip-*" | tr '\012' ' ') &&
|
"refs/bisect/skip-*" | tr '\012' ' ') &&
|
||||||
|
|
||||||
# Maybe some merge bases must be tested first
|
# Maybe some merge bases must be tested first
|
||||||
check_good_are_ancestors_of_bad "$bad" "$good" "$skip" || exit
|
check_good_are_ancestors_of_bad "$bad" "$good" "$skip"
|
||||||
test "$checkout_done" -eq "1" && checkout_done='' && return
|
# Return now if a checkout has already been done
|
||||||
|
test "$?" -eq "1" && return
|
||||||
|
|
||||||
# Get bisection information
|
# Get bisection information
|
||||||
BISECT_OPT=''
|
BISECT_OPT=''
|
||||||
|
|
Loading…
Reference in New Issue