summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-07-09 07:07:05 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-07-09 07:07:05 (GMT)
commit74c4763c76a111809747652210962ad09896b74f (patch)
tree9094f1e0c23d07a1d816521af342e6070bbbe8e9 /git-gui.sh
parentc136f2b8b9eaac7a702799de25648b74ef12618a (diff)
downloadgit-74c4763c76a111809747652210962ad09896b74f.zip
git-74c4763c76a111809747652210962ad09896b74f.tar.gz
git-74c4763c76a111809747652210962ad09896b74f.tar.bz2
git-gui: Teach console widget to use git_read
Now that we are pretty strict about setting up own absolute paths to any git helper (saving a marginal runtime cost to resolve the tool) we can do the same in our console widget by making sure all console execs go through git_read if they are a git subcommand, and if not make sure they at least try to use the Tcl 2>@1 IO redirection if possible, as it should be faster than |& cat. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh46
1 files changed, 24 insertions, 22 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 7e6952c..3efecdd 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -394,6 +394,29 @@ proc git {args} {
return [eval $opt $cmdp $args]
}
+proc _open_stdout_stderr {cmd} {
+ if {[catch {
+ set fd [open $cmd r]
+ } err]} {
+ if { [lindex $cmd end] eq {2>@1}
+ && $err eq {can not find channel named "1"}
+ } {
+ # Older versions of Tcl 8.4 don't have this 2>@1 IO
+ # redirect operator. Fallback to |& cat for those.
+ # The command was not actually started, so its safe
+ # to try to start it a second time.
+ #
+ set fd [open [concat \
+ [lrange $cmd 0 end-1] \
+ [list |& cat] \
+ ] r]
+ } else {
+ error $err
+ }
+ }
+ return $fd
+}
+
proc git_read {args} {
set opt [list |]
@@ -422,28 +445,7 @@ proc git_read {args} {
set cmdp [_git_cmd [lindex $args 0]]
set args [lrange $args 1 end]
- if {[catch {
- set fd [open [concat $opt $cmdp $args] r]
- } err]} {
- if { [lindex $args end] eq {2>@1}
- && $err eq {can not find channel named "1"}
- } {
- # Older versions of Tcl 8.4 don't have this 2>@1 IO
- # redirect operator. Fallback to |& cat for those.
- # The command was not actually started, so its safe
- # to try to start it a second time.
- #
- set fd [open [concat \
- $opt \
- $cmdp \
- [lrange $args 0 end-1] \
- [list |& cat] \
- ] r]
- } else {
- error $err
- }
- }
- return $fd
+ return [_open_stdout_stderr [concat $opt $cmdp $args]]
}
proc git_write {args} {