@matheusbsbs / matheus-bagliano / commits / 79317e5df1
Fork 0

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>

Shawn O. Pearce committed Jul 29, 2008 at 22:36 UTC 79317e5df184773f3211503be49b8836b712facc
1 file changed +9 -3
git-gui.sh
+9 -3
@@ -317,7 +317,7 @@ proc _git_cmd {name} {
317 return $v
318 }
319
320 -proc _which {what} {
320 +proc _which {what args} {
321 global env _search_exe _search_path
322
323 if {$_search_path eq {}} {
@@ -340,8 +340,14 @@ proc _which {what} {
340 }
341 }
342
343 + if {[is_Windows] && [lsearch -exact $args -script] >= 0} {
344 + set suffix {}
345 + } else {
346 + set suffix $_search_exe
347 + }
348 +
349 foreach p $_search_path {
344 - set p [file join $p $what$_search_exe]
350 + set p [file join $p $what$suffix]
351 if {[file exists $p]} {
352 return [file normalize $p]
353 }
@@ -1686,7 +1692,7 @@ proc do_gitk {revs} {
1692 # -- Always start gitk through whatever we were loaded with. This
1693 # lets us bypass using shell process on Windows systems.
1694 #
1689 - set exe [_which gitk]
1695 + set exe [_which gitk -script]
1696 set cmd [list [info nameofexecutable] $exe]
1697 if {$exe eq {}} {
1698 error_popup [mc "Couldn't find gitk in PATH"]