summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-10 17:53:17 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-10 17:53:17 -0400
commitfc0dd7977490917a1a87968ba117799bf04891bd (patch)
tree7d7d7271fc90f3cd655eed1f7f9e84f680e5bee1 /Command
parentcda6c4dff5cfa4733198ab87096235d81fce65d6 (diff)
avoid running pre-commit hook from watch commits
Diffstat (limited to 'Command')
-rw-r--r--Command/Watch.hs22
1 files changed, 12 insertions, 10 deletions
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