Skip to content

Commit 79317e5

Browse files
committed
git-gui: Fix gitk search in $PATH to work on Windows
Back in 15430be ("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 <[email protected]>
1 parent 25b8fb1 commit 79317e5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

git-gui.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ proc _git_cmd {name} {
317317
return $v
318318
}
319319

320-
proc _which {what} {
320+
proc _which {what args} {
321321
global env _search_exe _search_path
322322

323323
if {$_search_path eq {}} {
@@ -340,8 +340,14 @@ proc _which {what} {
340340
}
341341
}
342342
343+
if {[is_Windows] && [lsearch -exact $args -script] >= 0} {
344+
set suffix {}
345+
} else {
346+
set suffix $_search_exe
347+
}
348+
343349
foreach p $_search_path {
344-
set p [file join $p $what$_search_exe]
350+
set p [file join $p $what$suffix]
345351
if {[file exists $p]} {
346352
return [file normalize $p]
347353
}
@@ -1686,7 +1692,7 @@ proc do_gitk {revs} {
16861692
# -- Always start gitk through whatever we were loaded with. This
16871693
# lets us bypass using shell process on Windows systems.
16881694
#
1689-
set exe [_which gitk]
1695+
set exe [_which gitk -script]
16901696
set cmd [list [info nameofexecutable] $exe]
16911697
if {$exe eq {}} {
16921698
error_popup [mc "Couldn't find gitk in PATH"]

0 commit comments

Comments
 (0)