From: Shawn O. Pearce Date: Fri, 26 Jan 2007 07:02:09 +0000 (-0500) Subject: git-gui: Use builtin version of 'git gc'. X-Git-Tag: gitgui-0.6.0~41 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bc7452f5e7c0c472bc580e2e00d84f31d1af50ce;p=git.git git-gui: Use builtin version of 'git gc'. Technically the new git-gc command is strictly Porcelain; its invoking multiple plumbing commands to do its work. Since git-gui tries to not rely on Porclain we shouldn't be invoking git-gc directly, instead we should perform its tasks on our own. To make this easy I've created console_chain, which takes a list of tasks to perform and runs them all in the same console window. If any individual task fails then the chain stops running and the window shows a failure bar. Only once all tasks have been completed will it invoke console_done with a successful status. Signed-off-by: Shawn O. Pearce --- diff --git a/git-gui.sh b/git-gui.sh index d26455807..0982da569 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2917,9 +2917,45 @@ proc console_read {w fd after} { fconfigure $fd -blocking 0 } -proc console_done {w ok} { +proc console_chain {cmdlist w {ok 1}} { + if {$ok} { + if {[llength $cmdlist] == 0} { + console_done $w $ok + return + } + + set cmd [lindex $cmdlist 0] + set cmdlist [lrange $cmdlist 1 end] + + if {[lindex $cmd 0] eq {console_exec}} { + console_exec $w \ + [lindex $cmd 1] \ + [list console_chain $cmdlist] + } else { + uplevel #0 $cmd $cmdlist $w $ok + } + } else { + console_done $w $ok + } +} + +proc console_done {args} { global console_cr console_data + switch -- [llength $args] { + 2 { + set w [lindex $args 0] + set ok [lindex $args 1] + } + 3 { + set w [lindex $args 1] + set ok [lindex $args 2] + } + default { + error "wrong number of args: console_done ?ignored? w ok" + } + } + if {$ok} { if {[winfo exists $w]} { $w.m.s conf -background green -text {Success} @@ -3038,7 +3074,12 @@ proc do_stats {} { proc do_gc {} { set w [new_console {gc} {Compressing the object database}] - console_exec $w {git gc} console_done + console_chain { + {console_exec {git pack-refs --prune}} + {console_exec {git reflog expire --all}} + {console_exec {git repack -a -d -l}} + {console_exec {git rerere gc}} + } $w } proc do_fsck_objects {} {