summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-06 15:50:12 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-06 15:50:12 -0400
commitdb8effb8f3e861c61bc4c640d712688a8ed342e1 (patch)
treeb448bd75c212620f43f01a819457bfe7f6e85d14
parentb819f644ad00c5ad13ba5b249d3e127fd59d8694 (diff)
ignore .gitignore and .gitattributes
-rw-r--r--Command/Watch.hs7
-rw-r--r--Utility/Inotify.hs20
2 files changed, 14 insertions, 13 deletions
diff --git a/Command/Watch.hs b/Command/Watch.hs
index 7b714ac18..d6f77b6ae 100644
--- a/Command/Watch.hs
+++ b/Command/Watch.hs
@@ -43,14 +43,17 @@ start = notBareRepo $ do
mvar <- liftIO $ newMVar state
next $ next $ liftIO $ withINotify $ \i -> do
let hook a = Just $ runAnnex mvar a
- watchDir i "." (not . pruned)
+ watchDir i "." (ignored . takeFileName)
(hook onAdd) (hook onAddSymlink)
(hook onDel) (hook onDelDir)
putStrLn "(started)"
waitForTermination
return True
where
- pruned dir = takeFileName dir /= ".git"
+ ignored ".git" = True
+ ignored ".gitignore" = True
+ ignored ".gitattributes" = True
+ ignored _ = False
{- Runs a handler, inside the Annex monad.
-
diff --git a/Utility/Inotify.hs b/Utility/Inotify.hs
index 3c69a7ee2..1896a2a26 100644
--- a/Utility/Inotify.hs
+++ b/Utility/Inotify.hs
@@ -48,15 +48,13 @@ type Hook = Maybe (FilePath -> IO ())
- So this will fail if there are too many subdirectories.
-}
watchDir :: INotify -> FilePath -> (FilePath -> Bool) -> Hook -> Hook -> Hook -> Hook -> IO ()
-watchDir i dir ignored add addsymlink del deldir
- | ignored dir = noop
- | otherwise = do
- lock <- newLock
- void $ addWatch i watchevents dir $ \event ->
- withLock lock (void $ go event)
- withLock lock $
- mapM_ walk =<< filter (not . dirCruft) <$>
- getDirectoryContents dir
+watchDir i dir ignored add addsymlink del deldir = unless (ignored dir) $ do
+ lock <- newLock
+ void $ addWatch i watchevents dir $ \event ->
+ withLock lock (void $ go event)
+ withLock lock $
+ mapM_ walk =<< filter (not . dirCruft) <$>
+ getDirectoryContents dir
where
recurse d = watchDir i d ignored add addsymlink del deldir
@@ -71,7 +69,7 @@ watchDir i dir ignored add addsymlink del deldir
| isJust del || isJust deldir = [MoveOut, Delete]
| otherwise = []
- walk f = do
+ walk f = unless (ignored f) $ do
let fullf = indir f
r <- catchMaybeIO $ getSymbolicLinkStatus fullf
case r of
@@ -112,7 +110,7 @@ watchDir i dir ignored add addsymlink del deldir
guarded = unlessM (filetype (const True) f)
go _ = noop
- Just a <@> f = a $ indir f
+ Just a <@> f = unless (ignored f) $ a $ indir f
Nothing <@> _ = noop
indir f = dir </> f