better prevention of auto repack

Looking through the git sources (documentation is unclear),
it seems commit doesn't ever trigger git-gc, mostly fetching and merging
seems to. I cannot easily override the setting in all those places, so
instead set gc.auto in git config when initializing a repository with
the assistant.

This does mean that the user cannot set gc.auto=0 and completely avoid
repacks, as the assistant does it daily. But, it only does it after there
are 100x the default number of loose objects, so this is probably not going
to be too annoying.
This commit is contained in:
Joey Hess 2013-03-03 14:07:13 -04:00
parent cd06ede772
commit 789ca15012
4 changed files with 26 additions and 10 deletions

View file

@ -15,6 +15,7 @@ import Assistant.DaemonStatus
import Assistant.Alert
import qualified Git.LsFiles
import qualified Git.Command
import qualified Git.Config
import Utility.ThreadScheduler
import qualified Assistant.Threads.Watcher as Watcher
import Utility.LogFile
@ -85,8 +86,16 @@ dailyCheck = do
liftIO $ void cleanup
{- Allow git-gc to run once per day. More frequent gc is avoided
- to avoid slowing things down. -}
void $ liftIO $ Git.Command.runBool [Param "gc", Param "--auto"] g
- by default to avoid slowing things down. Only run repacks when 100x
- the usual number of loose objects are present; we tend
- to have a lot of small objects and they should not be a
- significant size. -}
when (Git.Config.getMaybe "gc.auto" g == Just "0") $
liftIO $ void $ Git.Command.runBool
[ Param "-c", Param "gc.auto=670000"
, Param "gc"
, Param "--auto"
] g
return True
where