git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] bisect: visualize with git-log if gitk is unavailable

From
Jeff King <peff@peff.net>
Date
Mar 21, 2011, 13:14 UTC
Message-ID
<20110321131422.GA24382@sigill.intra.peff.net>
In-Reply-To
<AANLkTinS87obXcgbcFZ8L-UjZUQL96SzpHp84Y6-yX6v@mail.gmail.com>

If gitk is not available in the PATH, bisect ends up exiting with the shell's 127 error code, confusing the git wrapper into thinking that bisect is not a git command.

We already fallback to git-log if there doesn't seem to be a graphical display available. We should do the same if gitk is not available in our PATH at all. This not only fixes the ugly error message, but is a much more sensible default than failing to show the user anything.

Reported by Maxin John.
Tested-by: Maxin B. John <maxin@maxinbjohn.info>
Signed-off-by: Jeff King <peff@peff.net>
---
 git-bisect.sh |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/git-bisect.sh b/git-bisect.sh
index c21e33c..415a8d0 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -288,10 +288,12 @@ bisect_visualize() {
 
 	if test $# = 0
 	then
-		case "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" in
-		'')	set git log ;;
-		set*)	set gitk ;;
-		esac
+		if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
+		   type gitk >/dev/null 2>&1; then
+			set gitk
+		else
+			set git log
+		fi
 	else
 		case "$1" in
 		git*|tig) ;;
-- 
1.7.2.5.22.g853c5
Previous: Maxin john
Message 4 of 4 in “"git bisect visualize" results in an invalid error if "gitk" is not installed”
  1. "git bisect visualize" results in an invalid error if "gitk" is not installedMaxin john, Mar 20, 2011
  2. Jeff KingMar 21, 2011
  3. Maxin johnMar 21, 2011
  4. bisect: visualize with git-log if gitk is unavailableJeff King, Mar 21, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.