Skip to content

Commit 6dfdf7b

Browse files
committed
git-gui: use dashless 'git cmd' form for read/write
git-gui implements its own approach to locating and running various git subcommands, bypassing git's capabilities for running git-*. This was written in 2007: at that time, many git commands were shell-scripts stored in $(git --exec-path), git's run-command api was not well adapted to Windows and had serious performance issues when it worked at all, and running subcommand 'git foo' as 'git-foo' was common and fully supported. On Windows, git-gui searches $(git --exec-path) for builtin commands, then attempts to find an interpreter on PATH to run those, invoking these differently than on other platforms. For instance, the explicit shebang #!/usr/bin/perl found in a script will be run by the first Perl interpreter found on $PATH, which might not be at that specific location so could be different than what git would run. The various issues leading to the current implemention no longer exist. Most git commands are now builtins, links to run those are not installed in $(git --exec-path) by default (the "dashless" form is recommended instead), and git's run-command api works well everywhere. So, let's use git to launch its subcommands on all platforms. Do so by modifying procs git_read and git_write to use the "dashless" form for invoking git commands, avoiding the search for git-<foo>. This leaves _git_cmd unused with cleanup in a later patch. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 3ce650f commit 6dfdf7b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

git-gui.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -681,30 +681,30 @@ proc safe_open_command {cmd {redir {}}} {
681681
}
682682

683683
proc git_read {cmd {redir {}}} {
684-
set cmdp [_git_cmd [lindex $cmd 0]]
685-
set cmd [lrange $cmd 1 end]
684+
global _git
685+
set cmdp [concat [list $_git] $cmd]
686686

687-
return [safe_open_command [concat $cmdp $cmd] $redir]
687+
return [safe_open_command $cmdp $redir]
688688
}
689689

690690
proc git_read_nice {cmd} {
691+
global _git
691692
set opt [list]
692693

693694
_lappend_nice opt
694695

695-
set cmdp [_git_cmd [lindex $cmd 0]]
696-
set cmd [lrange $cmd 1 end]
696+
set cmdp [concat [list $_git] $cmd]
697697

698-
return [safe_open_command [concat $opt $cmdp $cmd]]
698+
return [safe_open_command [concat $opt $cmdp]]
699699
}
700700

701701
proc git_write {cmd} {
702+
global _git
702703
set cmd [make_arglist_safe $cmd]
703-
set cmdp [_git_cmd [lindex $cmd 0]]
704-
set cmd [lrange $cmd 1 end]
704+
set cmdp [concat [list $_git] $cmd]
705705

706-
_trace_exec [concat $cmdp $cmd]
707-
return [open [concat [list | ] $cmdp $cmd] w]
706+
_trace_exec $cmdp
707+
return [open [concat [list | ] $cmdp] w]
708708
}
709709

710710
proc githook_read {hook_name args} {

0 commit comments

Comments
 (0)