import: Skip .git directories.

This commit is contained in:
Joey Hess 2013-10-07 13:03:05 -04:00
parent ac26b70809
commit 45aed381df
5 changed files with 10 additions and 3 deletions

View file

@ -162,7 +162,7 @@ checkStaleGitLocks :: Assistant ()
checkStaleGitLocks = do
lockfiles <- filter (not . isInfixOf "gc.pid")
. filter (".lock" `isSuffixOf`)
<$> (liftIO . dirContentsRecursiveSkipping (annexDir `isInfixOf`)
<$> (liftIO . dirContentsRecursiveSkipping (== dropTrailingPathSeparator annexDir)
=<< liftAnnex (fromRepo Git.localGitDir))
checkStaleLocks lockfiles
checkStaleLocks :: [FilePath] -> Assistant ()

View file

@ -60,7 +60,8 @@ withPathContents :: ((FilePath, FilePath) -> CommandStart) -> CommandSeek
withPathContents a params = map a . concat <$> liftIO (mapM get params)
where
get p = ifM (isDirectory <$> getFileStatus p)
( map (\f -> (f, makeRelative (parentDir p) f)) <$> dirContentsRecursive p
( map (\f -> (f, makeRelative (parentDir p) f))
<$> dirContentsRecursiveSkipping (".git" `isSuffixOf`) p
, return [(p, takeFileName p)]
)

View file

@ -40,12 +40,13 @@ dirContents d = map (d </>) . filter (not . dirCruft) <$> getDirectoryContents d
dirContentsRecursive :: FilePath -> IO [FilePath]
dirContentsRecursive topdir = dirContentsRecursiveSkipping (const False) topdir
{- Skips directories whose basenames match the skipdir. -}
dirContentsRecursiveSkipping :: (FilePath -> Bool) -> FilePath -> IO [FilePath]
dirContentsRecursiveSkipping skipdir topdir = go [topdir]
where
go [] = return []
go (dir:dirs)
| skipdir dir = go dirs
| skipdir (takeFileName dir) = go dirs
| otherwise = unsafeInterleaveIO $ do
(files, dirs') <- collect [] []
=<< catchDefaultIO [] (dirContents dir)

1
debian/changelog vendored
View file

@ -11,6 +11,7 @@ git-annex (4.20131003) UNRELEASED; urgency=low
shorter than the maximum unix domain socket length, because ssh
appends stuff to it to make a temporary filename. Closes: #725512
* status: Fix space leak in local mode, introduced in version 4.20130920.
* import: Skip .git directories.
-- Joey Hess <joeyh@debian.org> Thu, 03 Oct 2013 15:41:24 -0400

View file

@ -124,3 +124,7 @@ anarcat@angela:foo$
"""]]
Thanks! --[[anarcat]]
> Would have thought this was obviously something you shouldn't do
> (sorta like running git-annex import on your home directory),
> but ok, it can skip .git directories. [[done]] --[[Joey]]