@matheusbsbs / matheus-bagliano / commits / 3972b987d3
Fork 0

git-gui: Delay the GC hint until after we are running

I'm moving the code related to looking to see if we should GC now into a procedure closer to where it belongs, the database module. This reduces our script by a few lines for the single commit case (aka citool). But really it just is to help organize the code. We now perform the check after we have been running for at least 1 second. This way the main window has time to open up and our dialog (if we open it) will attach to the main window, instead of floating out in no-mans-land like it did before on Mac OS X. I had to use a wait of a full second here as a wait of 1 millisecond made our console install itself into the main window. Apparently we had a race condition with the console code where both the console and the main window thought they were the main window. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jul 17, 2007 at 23:20 UTC 3972b987d373759ae4868012fe8133ca1e26ea20
2 files changed +30 -28
git-gui.sh
+3 -28
@@ -2581,36 +2581,11 @@ if {[is_enabled transport]} {
2581 populate_push_menu
2582 }
2583
2584 -# -- Only suggest a gc run if we are going to stay running.
2585 -#
2586 -if {[is_enabled multicommit]} {
2587 - set object_limit 8
2588 - if {[is_Windows]} {
2589 - set object_limit 1
2590 - }
2591 - set objects_current [llength [glob \
2592 - -directory [gitdir objects 42] \
2593 - -nocomplain \
2594 - -tails \
2595 - -- \
2596 - *]]
2597 - if {$objects_current >= $object_limit} {
2598 - set objects_current [expr {$objects_current * 256}]
2599 - set object_limit [expr {$object_limit * 256}]
2600 - if {[ask_popup \
2601 - "This repository currently has approximately $objects_current loose objects.
2602 -
2603 -To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist.
2604 -
2605 -Compress the database now?"] eq yes} {
2606 - do_gc
2607 - }
2608 - }
2609 - unset object_limit objects_current
2610 -}
2611 -
2584 lock_index begin-read
2585 if {![winfo ismapped .]} {
2586 wm deiconify .
2587 }
2588 after 1 do_rescan
2589 +if {[is_enabled multicommit]} {
2590 + after 1000 hint_gc
2591 +}
lib/database.tcl
+27
@@ -87,3 +87,30 @@ proc do_fsck_objects {} {
87 lappend cmd --strict
88 console::exec $w $cmd
89 }
90 +
91 +proc hint_gc {} {
92 + set object_limit 8
93 + if {[is_Windows]} {
94 + set object_limit 1
95 + }
96 +
97 + set objects_current [llength [glob \
98 + -directory [gitdir objects 42] \
99 + -nocomplain \
100 + -tails \
101 + -- \
102 + *]]
103 +
104 + if {$objects_current >= $object_limit} {
105 + set objects_current [expr {$objects_current * 256}]
106 + set object_limit [expr {$object_limit * 256}]
107 + if {[ask_popup \
108 + "This repository currently has approximately $objects_current loose objects.
109 +
110 +To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist.
111 +
112 +Compress the database now?"] eq yes} {
113 + do_gc
114 + }
115 + }
116 +}