From 2ec103cb68110deee36e8445d7320d0297ed4342 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 19 Sep 2013 14:48:42 -0400 Subject: sync, pre-commit, indirect: Avoid unnecessarily catting non-symlink files from git, which can be so large it runs out of memory. --- Command/Indirect.hs | 5 +++-- Command/PreCommit.hs | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'Command') diff --git a/Command/Indirect.hs b/Command/Indirect.hs index e63c4cb8a..79e736d11 100644 --- a/Command/Indirect.hs +++ b/Command/Indirect.hs @@ -14,6 +14,7 @@ import Command import qualified Git import qualified Git.Command import qualified Git.LsFiles +import Git.FileMode import Config import qualified Annex import Annex.Direct @@ -67,8 +68,7 @@ perform = do {- Walk tree from top and move all present direct mode files into - the annex, replacing with symlinks. Also delete direct mode - caches and mappings. -} - go (_, Nothing) = noop - go (f, Just sha) = do + go (f, Just sha, Just mode) | isSymLink mode = do r <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus f case r of Just s @@ -80,6 +80,7 @@ perform = do maybe noop (fromdirect f) =<< catKey sha _ -> noop + go _ = noop fromdirect f k = do showStart "indirect" f diff --git a/Command/PreCommit.hs b/Command/PreCommit.hs index c6d9dd278..c35cf61e1 100644 --- a/Command/PreCommit.hs +++ b/Command/PreCommit.hs @@ -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 -- cgit v1.2.3