sync, pre-commit, indirect: Avoid unnecessarily catting non-symlink files from git, which can be so large it runs out of memory.

This commit is contained in:
Joey Hess 2013-09-19 14:48:42 -04:00
parent 66b6a9cc4e
commit eb42bde19a
6 changed files with 26 additions and 14 deletions

View file

@ -16,6 +16,7 @@ import qualified Git.Ref
import Annex.CatFile
import Annex.Content.Direct
import Git.Sha
import Git.FileMode
def :: [Command]
def = [command "pre-commit" paramPaths seek SectionPlumbing
@ -44,10 +45,10 @@ startDirect _ = next $ do
next $ liftIO clean
where
go diff = do
withkey (Git.DiffTree.srcsha diff) removeAssociatedFile
withkey (Git.DiffTree.dstsha diff) addAssociatedFile
withkey (Git.DiffTree.srcsha diff) (Git.DiffTree.srcmode diff) removeAssociatedFile
withkey (Git.DiffTree.dstsha diff) (Git.DiffTree.dstmode diff) addAssociatedFile
where
withkey sha a = when (sha /= nullSha) $ do
withkey sha mode a = when (sha /= nullSha && isSymLink mode) $ do
k <- catKey sha
case k of
Nothing -> noop