@matheusbsbs / matheus-bagliano / commits / 235997c90f
Fork 0

git-bisect visualize: work in non-windowed environments better

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>

Junio C Hamano committed Dec 7, 2007 at 02:25 UTC 235997c90fe8648ac199f9a1ae257e06c145c131
2 files changed +27 -3
Documentation/git-bisect.txt
+10 -1
@@ -92,7 +92,16 @@ During the bisection process, you can say
92 $ git bisect visualize
93 ------------
94
95 -to see the currently remaining suspects in `gitk`.
95 +to see the currently remaining suspects in `gitk`. `visualize` is a bit
96 +too long to type and `view` is provided as a synonym.
97 +
98 +If `DISPLAY` environment variable is not set, `git log` is used
99 +instead. You can even give command line options such as `-p` and
100 +`--stat`.
101 +
102 +------------
103 +$ git bisect view --stat
104 +------------
105
106 Bisect log and bisect replay
107 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
git-bisect.sh
+17 -2
@@ -324,8 +324,23 @@ bisect_next() {
324
325 bisect_visualize() {
326 bisect_next_check fail
327 +
328 + if test $# = 0
329 + then
330 + case "${DISPLAY+set}" in
331 + '') set git log ;;
332 + set) set gitk ;;
333 + esac
334 + else
335 + case "$1" in
336 + git*|tig) ;;
337 + -*) set git log "$@" ;;
338 + *) set git "$@" ;;
339 + esac
340 + fi
341 +
342 not=$(git for-each-ref --format='%(refname)' "refs/bisect/good-*")
328 - eval gitk refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES")
343 + eval '"$@"' refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES")
344 }
345
346 bisect_reset() {
@@ -449,7 +464,7 @@ case "$#" in
464 next)
465 # Not sure we want "next" at the UI level anymore.
466 bisect_next "$@" ;;
452 - visualize)
467 + visualize|view)
468 bisect_visualize "$@" ;;
469 reset)
470 bisect_reset "$@" ;;