git-gui: Always use absolute path to all git executables

Rather than making the C library search for git every time we want
to execute it we now search for the main git wrapper at startup, do
symlink resolution, and then always use the absolute path that we
found to execute the binary later on.  This should save us some
cycles, especially on stat challenged systems like Cygwin/Win32.

While I was working on this change I also converted all of our
existing pipes ([open "| git ..."]) to use two new pipe wrapper
functions.  These functions take additional options like --nice
and --stderr which instructs Tcl to take special action, like
running the underlying git program through `nice` (if available)
or redirect stderr to stdout for capture in Tcl.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce
2007-07-09 01:17:09 -04:00
parent b79223064e
commit 0b81261622
13 changed files with 258 additions and 84 deletions

View File

@ -131,7 +131,7 @@ proc show_diff {path w {lno {}}} {
return
}
set cmd [list | git]
set cmd [list]
if {$w eq $ui_index} {
lappend cmd diff-index
lappend cmd --cached
@ -154,7 +154,7 @@ proc show_diff {path w {lno {}}} {
lappend cmd --
lappend cmd $path
if {[catch {set fd [open $cmd r]} err]} {
if {[catch {set fd [eval git_read --nice $cmd]} err]} {
set diff_active 0
unlock_index
ui_status "Unable to display [escape_path $path]"
@ -271,7 +271,7 @@ proc apply_hunk {x y} {
if {$current_diff_path eq {} || $current_diff_header eq {}} return
if {![lock_index apply_hunk]} return
set apply_cmd {git apply --cached --whitespace=nowarn}
set apply_cmd {apply --cached --whitespace=nowarn}
set mi [lindex $file_states($current_diff_path) 0]
if {$current_diff_side eq $ui_index} {
set mode unstage
@ -301,7 +301,7 @@ proc apply_hunk {x y} {
}
if {[catch {
set p [open "| $apply_cmd" w]
set p [eval git_write $apply_cmd]
fconfigure $p -translation binary -encoding binary
puts -nonewline $p $current_diff_header
puts -nonewline $p [$ui_diff get $s_lno $e_lno]