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

Re: [PATCH] git-gui: Look for gitk in $PATH, not $LIBEXEC/git-core

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 30, 2008, 05:42 UTC
Message-ID
<20080730054257.GG7225@spearce.org>
In-Reply-To
<20080729164856.GB1730@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> wrote:
Show 14 quoted lines
> "Murphy, John" <john.murphy@bankofamerica.com> wrote:
> > I have rebuilt git-gui with version 0.10.2.18.gc629 it is still not finding gitk.
> > I have done some debugging in proc _which
> > I have found the issue is with the following line:
> > 
> > set p [file join $p $what$_search_exe]
> > 
> > The variable $p = gitk.exe
> > 
> > And there is no such animal
> > 
> > When I copy gitk to gitk.exe in /usr/local/git/bin, it works fine.
> 
> This is definately a git-gui bug.
And this should fix it.

--8<-- git-gui: Fix gitk search in $PATH to work on Windows

Back in 15430be5a1 ("Look for gitk in $PATH, not $LIBEXEC/git-core") git-gui learned to use [_which gitk] to locate where gitk's script is as Git 1.6 will install gitk to $prefix/bin (in $PATH) and all of the other tools are in $gitexecdir.

This failed on Windows because _which adds the ".exe" suffix as it searches for the program on $PATH, under the assumption that we can only execute something from Tcl if it is a proper Windows executable.

When scanning for gitk on Windows we need to omit the ".exe" suffix.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 git-gui.sh |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index ce941ad..14b2d9a 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -317,7 +317,7 @@ proc _git_cmd {name} {
 	return $v
 }
 
-proc _which {what} {
+proc _which {what args} {
 	global env _search_exe _search_path
 
 	if {$_search_path eq {}} {
@@ -340,8 +340,14 @@ proc _which {what} {
 		}
 	}
 
+	if {[is_Windows] && [lsearch -exact $args -script] >= 0} {
+		set suffix {}
+	} else {
+		set suffix $_search_exe
+	}
+
 	foreach p $_search_path {
-		set p [file join $p $what$_search_exe]
+		set p [file join $p $what$suffix]
 		if {[file exists $p]} {
 			return [file normalize $p]
 		}
@@ -1686,7 +1692,7 @@ proc do_gitk {revs} {
 	# -- Always start gitk through whatever we were loaded with.  This
 	#    lets us bypass using shell process on Windows systems.
 	#
-	set exe [_which gitk]
+	set exe [_which gitk -script]
 	set cmd [list [info nameofexecutable] $exe]
 	if {$exe eq {}} {
 		error_popup [mc "Couldn't find gitk in PATH"]
-- 
1.6.0.rc1.166.gbbfa8


-- 
Shawn.
Previous: Shawn O. Pearce
Message 6 of 6 in “Git Gui bug calling gitk”
  1. Murphy, JohnJul 24, 2008
  2. git-gui: Look for gitk in $PATH, not $LIBEXEC/git-coreAbhijit Menon-Sen, Jul 24, 2008
  3. Shawn O. PearceJul 25, 2008
  4. Murphy, JohnJul 29, 2008
  5. Shawn O. PearceJul 29, 2008
  6. Shawn O. PearceJul 30, 2008

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.