git-gui: remove procs gitexec and _git_cmd

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>

Mark Levedahl committed Apr 6, 2025 at 11:14 UTC eaca720ecd4368943657c470d5ce0146804d09a7
2 files changed +2 -67
git-gui.sh
+1 -66
@@ -365,7 +365,6 @@ set _appname {Git Gui}
365 set _gitdir {}
366 set _gitworktree {}
367 set _isbare {}
368 -set _gitexec {}
368 set _githtmldir {}
369 set _reponame {}
370 set _shellpath {@@SHELL_PATH@@}
@@ -430,20 +429,6 @@ proc gitdir {args} {
429 return [eval [list file join $_gitdir] $args]
430 }
431
433 -proc gitexec {args} {
434 - global _gitexec
435 - if {$_gitexec eq {}} {
436 - if {[catch {set _gitexec [git --exec-path]} err]} {
437 - error "Git not installed?\n\n$err"
438 - }
439 - set _gitexec [file normalize $_gitexec]
440 - }
441 - if {$args eq {}} {
442 - return $_gitexec
443 - }
444 - return [eval [list file join $_gitexec] $args]
445 -}
446 -
432 proc githtmldir {args} {
433 global _githtmldir
434 if {$_githtmldir eq {}} {
@@ -576,56 +561,6 @@ proc _trace_exec {cmd} {
561
562 #'" fix poor old emacs font-lock mode
563
579 -proc _git_cmd {name} {
580 - global _git_cmd_path
581 -
582 - if {[catch {set v $_git_cmd_path($name)}]} {
583 - switch -- $name {
584 - version -
585 - --version -
586 - --exec-path { return [list $::_git $name] }
587 - }
588 -
589 - set p [gitexec git-$name$::_search_exe]
590 - if {[file exists $p]} {
591 - set v [list $p]
592 - } elseif {[is_Windows] && [file exists [gitexec git-$name]]} {
593 - # Try to determine what sort of magic will make
594 - # git-$name go and do its thing, because native
595 - # Tcl on Windows doesn't know it.
596 - #
597 - set p [gitexec git-$name]
598 - set f [safe_open_file $p r]
599 - set s [gets $f]
600 - close $f
601 -
602 - switch -glob -- [lindex $s 0] {
603 - #!*sh { set i sh }
604 - #!*perl { set i perl }
605 - #!*python { set i python }
606 - default { error "git-$name is not supported: $s" }
607 - }
608 -
609 - upvar #0 _$i interp
610 - if {![info exists interp]} {
611 - set interp [_which $i]
612 - }
613 - if {$interp eq {}} {
614 - error "git-$name requires $i (not in PATH)"
615 - }
616 - set v [concat [list $interp] [lrange $s 1 end] [list $p]]
617 - } else {
618 - # Assume it is builtin to git somehow and we
619 - # aren't actually able to see a file for it.
620 - #
621 - set v [list $::_git $name]
622 - }
623 - set _git_cmd_path($name) $v
624 - }
625 - return $v
626 -}
627 -
628 -# Run a shell command connected via pipes on stdout.
564 # This is for use with textconv filters and uses sh -c "..." to allow it to
565 # contain a command with arguments. We presume this
566 # 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}]
1129
1130 # Suggest our implementation of askpass, if none is set
1131 if {![info exists env(SSH_ASKPASS)]} {
1197 - set env(SSH_ASKPASS) [gitexec git-gui--askpass]
1132 + set env(SSH_ASKPASS) [file join [git --exec-path] git-gui--askpass]
1133 }
1134
1135 ######################################################################
lib/about.tcl
+1 -1
@@ -44,7 +44,7 @@ proc do_about {} {
44
45 set d {}
46 append d "git wrapper: $::_git\n"
47 - append d "git exec dir: [gitexec]\n"
47 + append d "git exec dir: [git --exec-path]\n"
48 append d "git-gui lib: $oguilib"
49
50 paddedlabel $w.vers -text $v