All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH (resend)] git-gui: make gc warning threshold match 'git gc --auto'
@ 2015-06-13 20:22 Karsten Blees
  2015-06-15 16:41 ` Heiko Voigt
  0 siblings, 1 reply; 2+ messages in thread
From: Karsten Blees @ 2015-06-13 20:22 UTC (permalink / raw)
  To: Git List, Pat Thoyts

Date: Wed, 6 Aug 2014 20:43:46 +0200

The number of loose objects at which git-gui shows a gc warning has
historically been hardcoded to ~2000, or ~200 on Windows. The warning can
only be disabled completely via gui.gcwarning=false.

Especially on Windows, the hardcoded threshold is so ridiculously low that
git-gui often complains even immediately after gc (due to loose objects
only referenced by the reflog).

'git gc --auto' uses a much bigger threshold to check if gc is necessary.
Additionally, the value can be configured via gc.auto (default 6700).
There's no special case for Windows.

Change git-gui so that it only warns if 'git gc --auto' would also do an
automatic gc, i.e.:
 - calculate the threshold from the gc.auto setting (default 6700,
   disabled if <= 0)
 - check directory .git/objects/17

We still check four directories (14-17) if gc.auto is very small, to get a
better estimate.

Signed-off-by: Karsten Blees <blees@dcon.de>
---
 git-gui/lib/database.tcl | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/git-gui/lib/database.tcl b/git-gui/lib/database.tcl
index 1f187ed..212b195 100644
--- a/git-gui/lib/database.tcl
+++ b/git-gui/lib/database.tcl
@@ -89,19 +89,26 @@ proc do_fsck_objects {} {
 }
 
 proc hint_gc {} {
+	global repo_config
+	set auto_gc $repo_config(gc.auto)
+	if {$auto_gc eq {}} {
+		set auto_gc 6700
+	} elseif {$auto_gc <= 0} {
+		return
+	}
+
 	set ndirs 1
-	set limit 8
-	if {[is_Windows]} {
+	set limit [expr {($auto_gc + 255) / 256}]
+	if {$limit < 4} {
 		set ndirs 4
-		set limit 1
 	}
 
 	set count [llength [glob \
 		-nocomplain \
 		-- \
-		[gitdir objects 4\[0-[expr {$ndirs-1}]\]/*]]]
+		[gitdir objects 1\[[expr {8-$ndirs}]-7\]/*]]]
 
-	if {$count >= $limit * $ndirs} {
+	if {$count > $limit * $ndirs} {
 		set objects_current [expr {$count * 256/$ndirs}]
 		if {[ask_popup \
 			[mc "This repository currently has approximately %i loose objects.
-- 
2.4.1.windows.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH (resend)] git-gui: make gc warning threshold match 'git gc --auto'
  2015-06-13 20:22 [PATCH (resend)] git-gui: make gc warning threshold match 'git gc --auto' Karsten Blees
@ 2015-06-15 16:41 ` Heiko Voigt
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Voigt @ 2015-06-15 16:41 UTC (permalink / raw)
  To: Karsten Blees; +Cc: Git List, Pat Thoyts

On Sat, Jun 13, 2015 at 10:22:17PM +0200, Karsten Blees wrote:
> Date: Wed, 6 Aug 2014 20:43:46 +0200
> 
> The number of loose objects at which git-gui shows a gc warning has
> historically been hardcoded to ~2000, or ~200 on Windows. The warning can
> only be disabled completely via gui.gcwarning=false.
> 
> Especially on Windows, the hardcoded threshold is so ridiculously low that
> git-gui often complains even immediately after gc (due to loose objects
> only referenced by the reflog).
> 
> 'git gc --auto' uses a much bigger threshold to check if gc is necessary.
> Additionally, the value can be configured via gc.auto (default 6700).
> There's no special case for Windows.
> 
> Change git-gui so that it only warns if 'git gc --auto' would also do an
> automatic gc, i.e.:
>  - calculate the threshold from the gc.auto setting (default 6700,
>    disabled if <= 0)
>  - check directory .git/objects/17
> 
> We still check four directories (14-17) if gc.auto is very small, to get a
> better estimate.
> 
> Signed-off-by: Karsten Blees <blees@dcon.de>

Thanks, I like this!

Cheers Heiko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-15 16:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-13 20:22 [PATCH (resend)] git-gui: make gc warning threshold match 'git gc --auto' Karsten Blees
2015-06-15 16:41 ` Heiko Voigt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.