Browse Source

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 <spearce@spearce.org>
maint
Shawn O. Pearce 18 years ago
parent
commit
bc7452f5e7
  1. 45
      git-gui.sh

45
git-gui.sh

@ -2917,9 +2917,45 @@ proc console_read {w fd after} {
fconfigure $fd -blocking 0 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 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 {$ok} {
if {[winfo exists $w]} { if {[winfo exists $w]} {
$w.m.s conf -background green -text {Success} $w.m.s conf -background green -text {Success}
@ -3038,7 +3074,12 @@ proc do_stats {} {


proc do_gc {} { proc do_gc {} {
set w [new_console {gc} {Compressing the object database}] 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 {} { proc do_fsck_objects {} {

Loading…
Cancel
Save