Code

Fix lost-found to show commits only referenced by reflogs
[git.git] / git-bisect.sh
index 3043f65514d8789b7b8f7f72df5968762facb410..11313a7949909f61f47ccc061cfc6390b225c630 100755 (executable)
@@ -50,7 +50,7 @@ bisect_start() {
        head=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD) ||
        die "Bad HEAD - I need a symbolic ref"
        case "$head" in
-       refs/heads/bisect*)
+       refs/heads/bisect)
                if [ -s "$GIT_DIR/head-name" ]; then
                    branch=`cat "$GIT_DIR/head-name"`
                else
@@ -123,7 +123,15 @@ bisect_next_check() {
        case "$next_ok,$1" in
        no,) false ;;
        no,fail)
-           echo >&2 'You need to give me at least one good and one bad revisions.'
+           THEN=''
+           test -d "$GIT_DIR/refs/bisect" || {
+               echo >&2 'You need to start by "git bisect start".'
+               THEN='then '
+           }
+           echo >&2 'You '$THEN'need to give me at least one good' \
+               'and one bad revisions.'
+           echo >&2 '(You can use "git bisect bad" and' \
+               '"git bisect good" for that.)'
            exit 1 ;;
        *)
            true ;;
@@ -141,7 +149,7 @@ bisect_next() {
        bad=$(git-rev-parse --verify refs/bisect/bad) &&
        good=$(git-rev-parse --sq --revs-only --not \
                $(cd "$GIT_DIR" && ls refs/bisect/good-*)) &&
-       rev=$(eval "git-rev-list --bisect $good $bad -- $(cat $GIT_DIR/BISECT_NAMES)") || exit
+       rev=$(eval "git-rev-list --bisect $good $bad -- $(cat "$GIT_DIR/BISECT_NAMES")") || exit
        if [ -z "$rev" ]; then
            echo "$bad was both good and bad"
            exit 1
@@ -173,7 +181,7 @@ bisect_reset() {
           else
               branch=master
           fi ;;
-       1) test -f "$GIT_DIR/refs/heads/$1" || {
+       1) git-show-ref --verify --quiet -- "refs/heads/$1" || {
               echo >&2 "$1 does not seem to be a valid branch"
               exit 1
           }
@@ -223,6 +231,8 @@ bisect_replay () {
 }
 
 bisect_run () {
+    bisect_next_check fail
+
     while true
     do
       echo "running $@"