aboutsummaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-01-26 01:29:00 -0500
committerShawn O. Pearce <spearce@spearce.org>2007-01-26 01:29:00 -0500
commit6c3d1481bab96659a80771194d935cb6db02300e (patch)
tree82c2fedb15cd3751009bb5ce3e3d4a7019fd40fe /git-gui.sh
parentb972ea59e422588963bda7be8e04c59728accadf (diff)
downloadgit-6c3d1481bab96659a80771194d935cb6db02300e.tar.gz
git-6c3d1481bab96659a80771194d935cb6db02300e.tar.xz
git-gui: Refactor console success/failure handling.
Because I want to be able to run multiple output-producing commands in a single 'console' window within git-gui I'm refactoring the console handling routines to require the "after" argument of console_exec. This should specify a procedure to execute which will receive two args, the first is the console window handle and the second is the status of the last command (0 on failure, 1 on success). A new procedure console_done can be passed to the last console_exec command to forward perform all cleanup and enable the Close button. Its status argument is used to update the final status bar on the bottom of the console window. This isn't any real logic changing, and no new functionality is in this patch. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh47
1 files changed, 29 insertions, 18 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 48e1f821d..d26455807 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1277,7 +1277,7 @@ proc fetch_from {remote} {
"Fetching new changes from $remote"]
set cmd [list git fetch]
lappend cmd $remote
- console_exec $w $cmd
+ console_exec $w $cmd console_done
}
proc push_to {remote} {
@@ -1287,7 +1287,7 @@ proc push_to {remote} {
set cmd [list git push]
lappend cmd -v
lappend cmd $remote
- console_exec $w $cmd
+ console_exec $w $cmd console_done
}
######################################################################
@@ -2476,7 +2476,7 @@ proc start_push_anywhere_action {w} {
}
set cons [new_console "push $r_url" "Pushing $cnt $unit to $r_url"]
- console_exec $cons $cmd
+ console_exec $cons $cmd console_done
destroy $w
}
@@ -2854,7 +2854,7 @@ proc console_init {w} {
return $w
}
-proc console_exec {w cmd {after {}}} {
+proc console_exec {w cmd after} {
# -- Windows tosses the enviroment when we exec our child.
# But most users need that so we have to relogin. :-(
#
@@ -2873,7 +2873,7 @@ proc console_exec {w cmd {after {}}} {
}
proc console_read {w fd after} {
- global console_cr console_data
+ global console_cr
set buf [read $fd]
if {$buf ne {}} {
@@ -2907,25 +2907,36 @@ proc console_read {w fd after} {
fconfigure $fd -blocking 1
if {[eof $fd]} {
if {[catch {close $fd}]} {
- if {![winfo exists $w]} {console_init $w}
- $w.m.s conf -background red -text {Error: Command Failed}
- $w.ok conf -state normal
set ok 0
- } elseif {[winfo exists $w]} {
- $w.m.s conf -background green -text {Success}
- $w.ok conf -state normal
+ } else {
set ok 1
}
- array unset console_cr $w
- array unset console_data $w
- if {$after ne {}} {
- uplevel #0 $after $ok
- }
+ uplevel #0 $after $w $ok
return
}
fconfigure $fd -blocking 0
}
+proc console_done {w ok} {
+ global console_cr console_data
+
+ if {$ok} {
+ if {[winfo exists $w]} {
+ $w.m.s conf -background green -text {Success}
+ $w.ok conf -state normal
+ }
+ } else {
+ if {![winfo exists $w]} {
+ console_init $w
+ }
+ $w.m.s conf -background red -text {Error: Command Failed}
+ $w.ok conf -state normal
+ }
+
+ array unset console_cr $w
+ array unset console_data $w
+}
+
######################################################################
##
## ui commands
@@ -3027,7 +3038,7 @@ proc do_stats {} {
proc do_gc {} {
set w [new_console {gc} {Compressing the object database}]
- console_exec $w {git gc}
+ console_exec $w {git gc} console_done
}
proc do_fsck_objects {} {
@@ -3037,7 +3048,7 @@ proc do_fsck_objects {} {
lappend cmd --full
lappend cmd --cache
lappend cmd --strict
- console_exec $w $cmd
+ console_exec $w $cmd console_done
}
set is_quitting 0