git-gui: Use builtin version of 'git gc'.
authorShawn O. Pearce <spearce@spearce.org>
Fri, 26 Jan 2007 07:02:09 +0000 (02:02 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 26 Jan 2007 07:02:09 +0000 (02:02 -0500)
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 <spearce@spearce.org>
git-gui.sh

index d2645580769c02d285314551842e0aed6fd4f824..0982da569045afae4ec1059816cefa71c30fcbb8 100755 (executable)
@@ -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 {} {