]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-bisect.sh
Merge branch 'cc/bisect'
[git.git] / git-bisect.sh
index 3a210335e7e2bdcaebf561b23374a32bec2faffd..7a6521ec3c62b04fe6d4c3e80c418ccc02b4ec65 100755 (executable)
@@ -22,6 +22,7 @@ git bisect log
 git bisect run <cmd>...
         use <cmd>... to automatically bisect.'
 
+OPTIONS_SPEC=
 . git-sh-setup
 require_work_tree
 
@@ -36,7 +37,7 @@ sq() {
 }
 
 bisect_autostart() {
-       test -d "$GIT_DIR/refs/bisect" || {
+       test -f "$GIT_DIR/BISECT_NAMES" || {
                echo >&2 'You need to start by "git bisect start"'
                if test -t 0
                then
@@ -82,7 +83,6 @@ bisect_start() {
        # Get rid of any old bisect state
        #
        bisect_clean_state
-       mkdir "$GIT_DIR/refs/bisect"
 
        #
        # Check for one bad and then some good revisions.
@@ -130,7 +130,7 @@ bisect_write() {
                good|skip)      tag="$state"-"$rev" ;;
                *)              die "Bad bisect_write argument: $state" ;;
        esac
-       echo "$rev" >"$GIT_DIR/refs/bisect/$tag"
+       git update-ref "refs/bisect/$tag" "$rev"
        echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
        test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
 }
@@ -191,7 +191,7 @@ bisect_next_check() {
                ;;
        *)
                THEN=''
-               test -d "$GIT_DIR/refs/bisect" || {
+               test -f "$GIT_DIR/BISECT_NAMES" || {
                        echo >&2 'You need to start by "git bisect start".'
                        THEN='then '
                }
@@ -316,20 +316,23 @@ bisect_next() {
        exit_if_skipped_commits "$bisect_rev"
 
        echo "Bisecting: $bisect_nr revisions left to test after this"
-       echo "$bisect_rev" >"$GIT_DIR/refs/heads/new-bisect"
+       git branch -f new-bisect "$bisect_rev"
        git checkout -q new-bisect || exit
-       mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" &&
-       GIT_DIR="$GIT_DIR" git symbolic-ref HEAD refs/heads/bisect
+       git branch -M new-bisect bisect
        git show-branch "$bisect_rev"
 }
 
 bisect_visualize() {
        bisect_next_check fail
-       not=`cd "$GIT_DIR/refs" && echo bisect/good-*`
-       eval gitk bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES")
+       not=$(git for-each-ref --format='%(refname)' "refs/bisect/good-*")
+       eval gitk refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES")
 }
 
 bisect_reset() {
+       test -f "$GIT_DIR/BISECT_NAMES" || {
+               echo "We are not bisecting."
+               return
+       }
        case "$#" in
        0) if [ -s "$GIT_DIR/head-name" ]; then
               branch=`cat "$GIT_DIR/head-name"`
@@ -349,8 +352,6 @@ bisect_reset() {
 }
 
 bisect_clean_state() {
-       rm -fr "$GIT_DIR/refs/bisect"
-
        # There may be some refs packed during bisection.
        git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* refs/heads/bisect |
        while read ref hash