Skip to content

Commit eaca720

Browse files
committed
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 <[email protected]>
1 parent 6dfdf7b commit eaca720

File tree

2 files changed

+2
-67
lines changed

2 files changed

+2
-67
lines changed

git-gui.sh

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ set _appname {Git Gui}
365365
set _gitdir {}
366366
set _gitworktree {}
367367
set _isbare {}
368-
set _gitexec {}
369368
set _githtmldir {}
370369
set _reponame {}
371370
set _shellpath {@@SHELL_PATH@@}
@@ -430,20 +429,6 @@ proc gitdir {args} {
430429
return [eval [list file join $_gitdir] $args]
431430
}
432431
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-
447432
proc githtmldir {args} {
448433
global _githtmldir
449434
if {$_githtmldir eq {}} {
@@ -576,56 +561,6 @@ proc _trace_exec {cmd} {
576561
577562
#'" fix poor old emacs font-lock mode
578563

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.
629564
# This is for use with textconv filters and uses sh -c "..." to allow it to
630565
# contain a command with arguments. We presume this
631566
# 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}]
11941129

11951130
# Suggest our implementation of askpass, if none is set
11961131
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]
11981133
}
11991134

12001135
######################################################################

lib/about.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ proc do_about {} {
4444

4545
set d {}
4646
append d "git wrapper: $::_git\n"
47-
append d "git exec dir: [gitexec]\n"
47+
append d "git exec dir: [git --exec-path]\n"
4848
append d "git-gui lib: $oguilib"
4949

5050
paddedlabel $w.vers -text $v

0 commit comments

Comments
 (0)