X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-bisect.sh;h=79de7017e88b746971f5a730b8615290bba2890d;hb=1689c5de8730ea334535337a341db3c7a21ad002;hp=b314d47704c3d72b0d62382296135a46c2d6469e;hpb=f821d0892173e4e46a71fef4d06995f7a81c9296;p=git.git diff --git a/git-bisect.sh b/git-bisect.sh index b314d4770..79de7017e 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -172,6 +172,25 @@ bisect_write() { test -n "$nolog" || echo "git bisect $state $rev" >>"$GIT_DIR/BISECT_LOG" } +is_expected_rev() { + test -f "$GIT_DIR/BISECT_EXPECTED_REV" && + test "$1" = $(cat "$GIT_DIR/BISECT_EXPECTED_REV") +} + +mark_expected_rev() { + echo "$1" > "$GIT_DIR/BISECT_EXPECTED_REV" +} + +check_expected_revs() { + for _rev in "$@"; do + if ! is_expected_rev "$_rev"; then + rm -f "$GIT_DIR/BISECT_ANCESTORS_OK" + rm -f "$GIT_DIR/BISECT_EXPECTED_REV" + return + fi + done +} + bisect_state() { bisect_autostart state=$1 @@ -181,7 +200,8 @@ bisect_state() { 1,bad|1,good|1,skip) rev=$(git rev-parse --verify HEAD) || die "Bad rev input: HEAD" - bisect_write "$state" "$rev" ;; + bisect_write "$state" "$rev" + check_expected_revs "$rev" ;; 2,bad|*,good|*,skip) shift eval='' @@ -191,7 +211,8 @@ bisect_state() { die "Bad rev input: $rev" eval="$eval bisect_write '$state' '$sha'; " done - eval "$eval" ;; + eval "$eval" + check_expected_revs "$@" ;; *,bad) die "'git bisect bad' can take only one argument." ;; *) @@ -321,6 +342,7 @@ bisect_checkout() { _rev="$1" _msg="$2" echo "Bisecting: $_msg" + mark_expected_rev "$_rev" git checkout -q "$_rev" || exit git show-branch "$_rev" } @@ -332,18 +354,10 @@ is_among() { return 1 } -is_testing_merge_base() { - grep "^testing $1$" "$GIT_DIR/BISECT_MERGE_BASES" >/dev/null 2>&1 -} - -mark_testing_merge_base() { - echo "testing $1" >> "$GIT_DIR/BISECT_MERGE_BASES" -} - handle_bad_merge_base() { _badmb="$1" _good="$2" - if is_testing_merge_base "$_badmb"; then + if is_expected_rev "$_badmb"; then cat >&2 < "$GIT_DIR/BISECT_ANCESTORS_OK" + + return 0 } bisect_next() { @@ -418,8 +458,9 @@ bisect_next() { "refs/bisect/skip-*" | tr '\012' ' ') && # Maybe some merge bases must be tested first - check_good_are_ancestors_of_bad "$bad" "$good" "$skip" || exit - test "$checkout_done" -eq "1" && checkout_done='' && return + check_good_are_ancestors_of_bad "$bad" "$good" "$skip" + # Return now if a checkout has already been done + test "$?" -eq "1" && return # Get bisection information BISECT_OPT='' @@ -491,7 +532,8 @@ bisect_clean_state() { do git update-ref -d $ref $hash || exit done - rm -f "$GIT_DIR/BISECT_MERGE_BASES" && + rm -f "$GIT_DIR/BISECT_EXPECTED_REV" && + rm -f "$GIT_DIR/BISECT_ANCESTORS_OK" && rm -f "$GIT_DIR/BISECT_LOG" && rm -f "$GIT_DIR/BISECT_NAMES" && rm -f "$GIT_DIR/BISECT_RUN" &&