http.c: guard config parser from value=NULL
[git.git] / git-bisect.sh
index 7a6521ec3c62b04fe6d4c3e80c418ccc02b4ec65..393fa355849f88d6c5227f90cbf6cbb45b39631e 100755 (executable)
@@ -26,6 +26,9 @@ OPTIONS_SPEC=
 . git-sh-setup
 require_work_tree
 
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+
 sq() {
        @@PERL@@ -e '
                for (@ARGV) {
@@ -60,7 +63,8 @@ bisect_start() {
        # top-of-line master first!
        #
        head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
-       die "Bad HEAD - I need a symbolic ref"
+       head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
+       die "Bad HEAD - I need a HEAD"
        case "$head" in
        refs/heads/bisect)
                if [ -s "$GIT_DIR/head-name" ]; then
@@ -70,7 +74,7 @@ bisect_start() {
                fi
                git checkout $branch || exit
                ;;
-       refs/heads/*)
+       refs/heads/*|$_x40)
                [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
                echo "${head#refs/heads/}" >"$GIT_DIR/head-name"
                ;;
@@ -324,8 +328,23 @@ bisect_next() {
 
 bisect_visualize() {
        bisect_next_check fail
+
+       if test $# = 0
+       then
+               case "${DISPLAY+set}" in
+               '')     set git log ;;
+               set)    set gitk ;;
+               esac
+       else
+               case "$1" in
+               git*|tig) ;;
+               -*)     set git log "$@" ;;
+               *)      set git "$@" ;;
+               esac
+       fi
+
        not=$(git for-each-ref --format='%(refname)' "refs/bisect/good-*")
-       eval gitk refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES")
+       eval '"$@"' refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES")
 }
 
 bisect_reset() {
@@ -449,7 +468,7 @@ case "$#" in
     next)
         # Not sure we want "next" at the UI level anymore.
         bisect_next "$@" ;;
-    visualize)
+    visualize|view)
        bisect_visualize "$@" ;;
     reset)
         bisect_reset "$@" ;;