]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitk: limit PATH search to bare executable names
authorMark Levedahl <mlevedahl@gmail.com>
Tue, 1 Apr 2025 03:01:02 +0000 (23:01 -0400)
committerJohannes Sixt <j6t@kdbg.org>
Tue, 1 Apr 2025 16:13:04 +0000 (18:13 +0200)
The path search overrides used by gitk on Windows are applied to any
executable whose name is not 'absolute', meaning that
[exec foo/bar ...]
will search each element of $PATH to find one with subdirectory foo
containing bar. But, per POSIX, and Tcl implementation on all platforms,
foo/bar is taken as $(pwd)/foo/bar, and is not searched on $PATH.

Fix this descrepency using the same approach applied to git-gui in
commit 3f71c97e. The key is that the executable name must have no path
component, indicated by [file split $exename] having array length 1.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
gitk

diff --git a/gitk b/gitk
index 899b51ca557669e346b8c3320b717953120d09f1..11ad639d0622aeb26c1a5ee84d5d5eaf7d535893 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -58,7 +58,7 @@ if {[is_Windows]} {
         set i $from_index
         while {$i < [llength $command_line]} {
             set cmd [lindex $command_line $i]
-            if {[file pathtype $cmd] ne "absolute"} {
+            if {[llength [file split $cmd]] < 2} {
                 set fullpath [_which $cmd]
                 if {$fullpath eq ""} {
                     throw {NOT-FOUND} "$cmd not found in PATH"