@matheusbsbs / matheus-bagliano / commits / bc7452f5e7
Fork 0

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>

Shawn O. Pearce committed Jan 26, 2007 at 02:02 UTC bc7452f5e7c0c472bc580e2e00d84f31d1af50ce
1 file changed +43 -2
git-gui.sh
+43 -2
@@ -2917,9 +2917,45 @@ proc console_read {w fd after} {
2917 fconfigure $fd -blocking 0
2918 }
2919
2920 -proc console_done {w ok} {
2920 +proc console_chain {cmdlist w {ok 1}} {
2921 + if {$ok} {
2922 + if {[llength $cmdlist] == 0} {
2923 + console_done $w $ok
2924 + return
2925 + }
2926 +
2927 + set cmd [lindex $cmdlist 0]
2928 + set cmdlist [lrange $cmdlist 1 end]
2929 +
2930 + if {[lindex $cmd 0] eq {console_exec}} {
2931 + console_exec $w \
2932 + [lindex $cmd 1] \
2933 + [list console_chain $cmdlist]
2934 + } else {
2935 + uplevel #0 $cmd $cmdlist $w $ok
2936 + }
2937 + } else {
2938 + console_done $w $ok
2939 + }
2940 +}
2941 +
2942 +proc console_done {args} {
2943 global console_cr console_data
2944
2945 + switch -- [llength $args] {
2946 + 2 {
2947 + set w [lindex $args 0]
2948 + set ok [lindex $args 1]
2949 + }
2950 + 3 {
2951 + set w [lindex $args 1]
2952 + set ok [lindex $args 2]
2953 + }
2954 + default {
2955 + error "wrong number of args: console_done ?ignored? w ok"
2956 + }
2957 + }
2958 +
2959 if {$ok} {
2960 if {[winfo exists $w]} {
2961 $w.m.s conf -background green -text {Success}
@@ -3038,7 +3074,12 @@ proc do_stats {} {
3074
3075 proc do_gc {} {
3076 set w [new_console {gc} {Compressing the object database}]
3041 - console_exec $w {git gc} console_done
3077 + console_chain {
3078 + {console_exec {git pack-refs --prune}}
3079 + {console_exec {git reflog expire --all}}
3080 + {console_exec {git repack -a -d -l}}
3081 + {console_exec {git rerere gc}}
3082 + } $w
3083 }
3084
3085 proc do_fsck_objects {} {