{"thread":{"id":"39621","subject":"[PATCH (resend)] git-gui: make gc warning threshold match 'git gc --auto'","startedAt":"2015-06-13T20:22:17Z","lastAt":"2015-06-15T16:41:40Z","messageCount":2,"participants":["Karsten Blees","Heiko Voigt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"263763","messageId":"557C90F9.8000200@gmail.com","threadId":"39621","inReplyTo":null,"subject":"[PATCH (resend)] git-gui: make gc warning threshold match 'git gc --auto'","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2015-06-13T20:22:17Z","receivedAt":"2015-06-13T20:22:17Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Date: Wed, 6 Aug 2014 20:43:46 +0200\n\nThe number of loose objects at which git-gui shows a gc warning has\nhistorically been hardcoded to ~2000, or ~200 on Windows. The warning can\nonly be disabled completely via gui.gcwarning=false.\n\nEspecially on Windows, the hardcoded threshold is so ridiculously low that\ngit-gui often complains even immediately after gc (due to loose objects\nonly referenced by the reflog).\n\n'git gc --auto' uses a much bigger threshold to check if gc is necessary.\nAdditionally, the value can be configured via gc.auto (default 6700).\nThere's no special case for Windows.\n\nChange git-gui so that it only warns if 'git gc --auto' would also do an\nautomatic gc, i.e.:\n - calculate the threshold from the gc.auto setting (default 6700,\n   disabled if <= 0)\n - check directory .git/objects/17\n\nWe still check four directories (14-17) if gc.auto is very small, to get a\nbetter estimate.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n git-gui/lib/database.tcl | 17 ++++++++++++-----\n 1 file changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/git-gui/lib/database.tcl b/git-gui/lib/database.tcl\nindex 1f187ed..212b195 100644\n--- a/git-gui/lib/database.tcl\n+++ b/git-gui/lib/database.tcl\n@@ -89,19 +89,26 @@ proc do_fsck_objects {} {\n }\n \n proc hint_gc {} {\n+\tglobal repo_config\n+\tset auto_gc $repo_config(gc.auto)\n+\tif {$auto_gc eq {}} {\n+\t\tset auto_gc 6700\n+\t} elseif {$auto_gc <= 0} {\n+\t\treturn\n+\t}\n+\n \tset ndirs 1\n-\tset limit 8\n-\tif {[is_Windows]} {\n+\tset limit [expr {($auto_gc + 255) / 256}]\n+\tif {$limit < 4} {\n \t\tset ndirs 4\n-\t\tset limit 1\n \t}\n \n \tset count [llength [glob \\\n \t\t-nocomplain \\\n \t\t-- \\\n-\t\t[gitdir objects 4\\[0-[expr {$ndirs-1}]\\]/*]]]\n+\t\t[gitdir objects 1\\[[expr {8-$ndirs}]-7\\]/*]]]\n \n-\tif {$count >= $limit * $ndirs} {\n+\tif {$count > $limit * $ndirs} {\n \t\tset objects_current [expr {$count * 256/$ndirs}]\n \t\tif {[ask_popup \\\n \t\t\t[mc \"This repository currently has approximately %i loose objects.\n-- \n2.4.1.windows.1\n"},{"id":"263865","messageId":"20150615164140.GA8990@book.hvoigt.net","threadId":"39621","inReplyTo":"557C90F9.8000200@gmail.com","subject":"Re: [PATCH (resend)] git-gui: make gc warning threshold match 'git gc --auto'","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2015-06-15T16:41:40Z","receivedAt":"2015-06-15T16:41:40Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"On Sat, Jun 13, 2015 at 10:22:17PM +0200, Karsten Blees wrote:\n> Date: Wed, 6 Aug 2014 20:43:46 +0200\n> \n> The number of loose objects at which git-gui shows a gc warning has\n> historically been hardcoded to ~2000, or ~200 on Windows. The warning can\n> only be disabled completely via gui.gcwarning=false.\n> \n> Especially on Windows, the hardcoded threshold is so ridiculously low that\n> git-gui often complains even immediately after gc (due to loose objects\n> only referenced by the reflog).\n> \n> 'git gc --auto' uses a much bigger threshold to check if gc is necessary.\n> Additionally, the value can be configured via gc.auto (default 6700).\n> There's no special case for Windows.\n> \n> Change git-gui so that it only warns if 'git gc --auto' would also do an\n> automatic gc, i.e.:\n>  - calculate the threshold from the gc.auto setting (default 6700,\n>    disabled if <= 0)\n>  - check directory .git/objects/17\n> \n> We still check four directories (14-17) if gc.auto is very small, to get a\n> better estimate.\n> \n> Signed-off-by: Karsten Blees <blees@dcon.de>\n\nThanks, I like this!\n\nCheers Heiko\n"}]}