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:
@ -146,7 +146,7 @@ The working directory will now be reset.
|
||||
|
||||
You can attempt this merge again by merging only one branch at a time." $w
|
||||
|
||||
set fd [open "| git read-tree --reset -u HEAD" r]
|
||||
set fd [git_read read-tree --reset -u HEAD]
|
||||
fconfigure $fd -blocking 0 -translation binary
|
||||
fileevent $fd readable \
|
||||
[namespace code [list _reset_wait $fd]]
|
||||
@ -167,11 +167,13 @@ proc dialog {} {
|
||||
if {![_can_merge]} return
|
||||
|
||||
set fmt {list %(objectname) %(*objectname) %(refname) %(subject)}
|
||||
set cmd [list git for-each-ref --tcl --format=$fmt]
|
||||
lappend cmd refs/heads
|
||||
lappend cmd refs/remotes
|
||||
lappend cmd refs/tags
|
||||
set fr_fd [open "| $cmd" r]
|
||||
set fr_fd [git_read for-each-ref \
|
||||
--tcl \
|
||||
--format=$fmt \
|
||||
refs/heads \
|
||||
refs/remotes \
|
||||
refs/tags \
|
||||
]
|
||||
fconfigure $fr_fd -translation binary
|
||||
while {[gets $fr_fd line] > 0} {
|
||||
set line [eval $line]
|
||||
@ -186,7 +188,7 @@ proc dialog {} {
|
||||
close $fr_fd
|
||||
|
||||
set to_show {}
|
||||
set fr_fd [open "| git rev-list --all --not HEAD"]
|
||||
set fr_fd [git_read rev-list --all --not HEAD]
|
||||
while {[gets $fr_fd line] > 0} {
|
||||
if {[catch {set ref $sha1($line)}]} continue
|
||||
foreach n $ref {
|
||||
@ -282,7 +284,7 @@ You must finish amending this commit.
|
||||
Aborting the current $op will cause *ALL* uncommitted changes to be lost.
|
||||
|
||||
Continue with aborting the current $op?"] eq {yes}} {
|
||||
set fd [open "| git read-tree --reset -u HEAD" r]
|
||||
set fd [git_read read-tree --reset -u HEAD]
|
||||
fconfigure $fd -blocking 0 -translation binary
|
||||
fileevent $fd readable [namespace code [list _reset_wait $fd]]
|
||||
ui_status {Aborting... please wait...}
|
||||
|
Reference in New Issue
Block a user