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

@ -14,8 +14,8 @@ import qualified Git.Merge
import qualified Git.DiffTree as DiffTree
import Git.Sha
import Git.Types
import Annex.CatFile
import Git.FileMode
import Annex.CatFile
import qualified Annex.Queue
import Logs.Location
import Backend
@ -45,8 +45,10 @@ stageDirect = do
{- Determine what kind of modified or deleted file this is, as
- efficiently as we can, by getting any key that's associated
- with it in git, as well as its stat info. -}
go (file, Just sha) = do
shakey <- catKey sha
go (file, Just sha, Just mode) = do
shakey <- if isSymLink mode
then catKey sha
else return Nothing
mstat <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file
filekey <- isAnnexLink file
case (shakey, filekey, mstat, toInodeCache =<< mstat) of