git-bisect visualize: work in non-windowed environments better
authorJunio C Hamano <gitster@pobox.com>
Fri, 7 Dec 2007 10:25:34 +0000 (02:25 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 8 Dec 2007 10:58:26 +0000 (02:58 -0800)
This teaches "git bisect visualize" to be more useful in non-windowed
environments.

(1) When no option is given, and $DISPLAY is set, it continues to
spawn gitk as before;

(2) When no option is given, and $DISPLAY is unset, "git log" is run
to show the range of commits between the bad one and the good ones;

(3) If only "-flag" options are given, "git log <options>" is run.
E.g. "git bisect visualize --stat"

(4) Otherwise, all of the given options are taken as the initial part
of the command line and the commit range expression is given to
that command. E.g. "git bisect visualize tig" will run "tig"
history viewer to show between the bad one and the good ones.

As "visualize" is a bit too long to type, we also give it a shorter
synonym "view".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-bisect.txt
git-bisect.sh
index 4795349c10fd91c330ddde2d8397401be09cc86b..8b9d61a8a4cdfcf9c993ed02a60297eb9d978b9a 100644 (file)
@@ -92,7 +92,16 @@ During the bisection process, you can say
 $ git bisect visualize
 ------------
 
-to see the currently remaining suspects in `gitk`.
+to see the currently remaining suspects in `gitk`.  `visualize` is a bit
+too long to type and `view` is provided as a synonym.
+
+If `DISPLAY` environment variable is not set, `git log` is used
+instead.  You can even give command line options such as `-p` and
+`--stat`.
+
+------------
+$ git bisect view --stat
+------------
 
 Bisect log and bisect replay
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 7a6521ec3c62b04fe6d4c3e80c418ccc02b4ec65..5385249890698632dedcaf8dda03d865f66abca9 100755 (executable)
@@ -324,8 +324,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 +464,7 @@ case "$#" in
     next)
         # Not sure we want "next" at the UI level anymore.
         bisect_next "$@" ;;
-    visualize)
+    visualize|view)
        bisect_visualize "$@" ;;
     reset)
         bisect_reset "$@" ;;