]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui: remove procs gitexec and _git_cmd
authorMark Levedahl <mlevedahl@gmail.com>
Sun, 6 Apr 2025 15:14:35 +0000 (11:14 -0400)
committerMark Levedahl <mlevedahl@gmail.com>
Mon, 21 Jul 2025 22:22:33 +0000 (18:22 -0400)
gitexec looks up and caches the method to execute git subcommands using
the long deprecated dashed form if found in $(git--exec-path). But,
git_read and git_write now use the dashless form, by-passing gitexec.
This leaves two remaining uses of gitexec: one during startup to define
use of an ssh_key helper, and one in the about dialog box. These are
neither performance critical nor likely to be called more than once, so
do not justify an otherwise unused cacheing system.

Let's change those two uses, making gitexec unused. This allows removing
gitexec and _git_cmd.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
git-gui.sh
lib/about.tcl

index 8c60bdb8cd81d7e989dc29feb3f83d8d8901c73c..9bc773d43c9145d4353cd2185fdda2f7fbd8f2ed 100755 (executable)
@@ -365,7 +365,6 @@ set _appname {Git Gui}
 set _gitdir {}
 set _gitworktree {}
 set _isbare {}
-set _gitexec {}
 set _githtmldir {}
 set _reponame {}
 set _shellpath {@@SHELL_PATH@@}
@@ -430,20 +429,6 @@ proc gitdir {args} {
        return [eval [list file join $_gitdir] $args]
 }
 
-proc gitexec {args} {
-       global _gitexec
-       if {$_gitexec eq {}} {
-               if {[catch {set _gitexec [git --exec-path]} err]} {
-                       error "Git not installed?\n\n$err"
-               }
-               set _gitexec [file normalize $_gitexec]
-       }
-       if {$args eq {}} {
-               return $_gitexec
-       }
-       return [eval [list file join $_gitexec] $args]
-}
-
 proc githtmldir {args} {
        global _githtmldir
        if {$_githtmldir eq {}} {
@@ -576,56 +561,6 @@ proc _trace_exec {cmd} {
 
 #'"  fix poor old emacs font-lock mode
 
-proc _git_cmd {name} {
-       global _git_cmd_path
-
-       if {[catch {set v $_git_cmd_path($name)}]} {
-               switch -- $name {
-                 version   -
-               --version   -
-               --exec-path { return [list $::_git $name] }
-               }
-
-               set p [gitexec git-$name$::_search_exe]
-               if {[file exists $p]} {
-                       set v [list $p]
-               } elseif {[is_Windows] && [file exists [gitexec git-$name]]} {
-                       # Try to determine what sort of magic will make
-                       # git-$name go and do its thing, because native
-                       # Tcl on Windows doesn't know it.
-                       #
-                       set p [gitexec git-$name]
-                       set f [safe_open_file $p r]
-                       set s [gets $f]
-                       close $f
-
-                       switch -glob -- [lindex $s 0] {
-                       #!*sh     { set i sh     }
-                       #!*perl   { set i perl   }
-                       #!*python { set i python }
-                       default   { error "git-$name is not supported: $s" }
-                       }
-
-                       upvar #0 _$i interp
-                       if {![info exists interp]} {
-                               set interp [_which $i]
-                       }
-                       if {$interp eq {}} {
-                               error "git-$name requires $i (not in PATH)"
-                       }
-                       set v [concat [list $interp] [lrange $s 1 end] [list $p]]
-               } else {
-                       # Assume it is builtin to git somehow and we
-                       # aren't actually able to see a file for it.
-                       #
-                       set v [list $::_git $name]
-               }
-               set _git_cmd_path($name) $v
-       }
-       return $v
-}
-
-# Run a shell command connected via pipes on stdout.
 # This is for use with textconv filters and uses sh -c "..." to allow it to
 # contain a command with arguments. We presume this
 # to be a shellscript that the configured shell (/bin/sh by default) knows
@@ -1194,7 +1129,7 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
 
 # Suggest our implementation of askpass, if none is set
 if {![info exists env(SSH_ASKPASS)]} {
-       set env(SSH_ASKPASS) [gitexec git-gui--askpass]
+       set env(SSH_ASKPASS) [file join [git --exec-path] git-gui--askpass]
 }
 
 ######################################################################
index cfa50fca87827f09b2fc93509e0f249cc03ca6cd..85f48709a7d798180209f89dc49bd43552c9b2d7 100644 (file)
@@ -44,7 +44,7 @@ proc do_about {} {
 
        set d {}
        append d "git wrapper: $::_git\n"
-       append d "git exec dir: [gitexec]\n"
+       append d "git exec dir: [git --exec-path]\n"
        append d "git-gui lib: $oguilib"
 
        paddedlabel $w.vers -text $v