From fc0dd7977490917a1a87968ba117799bf04891bd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 10 Jun 2012 17:53:17 -0400 Subject: avoid running pre-commit hook from watch commits --- Command/Watch.hs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'Command') diff --git a/Command/Watch.hs b/Command/Watch.hs index 92ebb6d70..f468d7271 100644 --- a/Command/Watch.hs +++ b/Command/Watch.hs @@ -197,26 +197,28 @@ refillChanges chan cs = atomically $ mapM_ (writeTChan chan) cs commitThread :: MVar Annex.AnnexState -> ChangeChan -> IO () commitThread st changechan = forever $ do -- First, a simple rate limiter. - threadDelay $ oneSecond - liftIO $ putStrLn "running" + threadDelay oneSecond -- Next, wait until at least one change has been made. cs <- getChanges changechan -- Now see if now's a good time to commit. - ifM (shouldCommit <$> getCurrentTime <*> pure cs) $ - ( commit - , do - liftIO $ putStrLn $ "no commit now " ++ show (length cs) - refillChanges changechan cs - ) + time <- getCurrentTime + if shouldCommit time cs + then commit + else refillChanges changechan cs where commit = void $ tryIO $ runStateMVar st $ do Annex.Queue.flush - {- Empty commits may be made if tree - - changes cancel each other out, etc. -} inRepo $ Git.Command.run "commit" [ Param "--allow-empty-message" , Param "-m", Param "" + -- Empty commits may be made if tree + -- changes cancel each other out, etc , Param "--allow-empty" + -- Avoid running the usual git-annex + -- pre-commit hook; watch does the same + -- symlink fixing, and we don't want to + -- deal with unlocked files in these + -- commits. , Param "--quiet" ] oneSecond = 1000000 -- microseconds -- cgit v1.2.3