bisect--helper: `bisect_write` shell function in C
[gitweb.git] / git-bisect.sh
index afbfbc1f8e33864b2f8c6aa7bda3e1cb98579cff..ebf445223ceb39175260663648f410fef8ca58f2 100755 (executable)
@@ -144,7 +144,7 @@ bisect_start() {
                0) state=$TERM_BAD ; bad_seen=1 ;;
                *) state=$TERM_GOOD ;;
                esac
-               eval="$eval bisect_write '$state' '$rev' 'nolog' &&"
+               eval="$eval git bisect--helper --bisect-write '$state' '$rev' '$TERM_GOOD' '$TERM_BAD' 'nolog' &&"
        done
        #
        # Verify HEAD.
@@ -220,23 +220,6 @@ bisect_start() {
        trap '-' 0
 }
 
-bisect_write() {
-       state="$1"
-       rev="$2"
-       nolog="$3"
-       case "$state" in
-               "$TERM_BAD")
-                       tag="$state" ;;
-               "$TERM_GOOD"|skip)
-                       tag="$state"-"$rev" ;;
-               *)
-                       die "$(eval_gettext "Bad bisect_write argument: \$state")" ;;
-       esac
-       git update-ref "refs/bisect/$tag" "$rev" || exit
-       echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG"
-       test -n "$nolog" || echo "git bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
-}
-
 bisect_skip() {
        all=''
        for arg in "$@"
@@ -263,7 +246,7 @@ bisect_state() {
                bisected_head=$(bisect_head)
                rev=$(git rev-parse --verify "$bisected_head") ||
                        die "$(eval_gettext "Bad rev input: \$bisected_head")"
-               bisect_write "$state" "$rev"
+               git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit
                git bisect--helper --check-expected-revs "$rev" ;;
        2,"$TERM_BAD"|*,"$TERM_GOOD"|*,skip)
                shift
@@ -276,7 +259,7 @@ bisect_state() {
                done
                for rev in $hash_list
                do
-                       bisect_write "$state" "$rev"
+                       git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit
                done
                git bisect--helper --check-expected-revs $hash_list ;;
        *,"$TERM_BAD")
@@ -413,7 +396,7 @@ bisect_replay () {
                        cmd="bisect_start $rev"
                        eval "$cmd" ;;
                "$TERM_GOOD"|"$TERM_BAD"|skip)
-                       bisect_write "$command" "$rev" ;;
+                       git bisect--helper --bisect-write "$command" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit;;
                terms)
                        bisect_terms $rev ;;
                *)