mirror of
https://github.com/git/git.git
synced 2024-10-29 21:37:53 +01:00
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>
This commit is contained in:
parent
b972ea59e4
commit
6c3d1481ba
1 changed files with 29 additions and 18 deletions
47
git-gui.sh
47
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
|
||||
|
|
Loading…
Reference in a new issue