diff options
author | Joey Hess <joey@kitenet.net> | 2013-09-19 16:30:37 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-09-19 16:41:21 -0400 |
commit | 4aaa584eb632a981f5364c844f9293d4cdedaa65 (patch) | |
tree | 082addc10fa1a1554a616d54bb8e41d03e94c074 /Annex/Direct.hs | |
parent | 5fddb08efccedd5c1542f5e16ec63a57498bc1f0 (diff) |
more completely solve catKey memory leak
Done using a mode witness, which ensures it's fixed everywhere.
Fixing catFileKey was a bear, because git cat-file does not provide a
nice way to query for the mode of a file and there is no other efficient
way to do it. Oh, for libgit2..
Note that I am looking at tree objects from HEAD, rather than the index.
Because I cat-file cannot show a tree object for the index.
So this fix is technically incomplete. The only cases where it matters
are:
1. A new large file has been directly staged in git, but not committed.
2. A file that was committed to HEAD as a symlink has been staged
directly in the index.
This could be fixed a lot better using libgit2.
Diffstat (limited to 'Annex/Direct.hs')
-rw-r--r-- | Annex/Direct.hs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/Annex/Direct.hs b/Annex/Direct.hs index a6c30ad08..ad9338ec7 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -14,7 +14,6 @@ import qualified Git.Merge import qualified Git.DiffTree as DiffTree import Git.Sha import Git.Types -import Git.FileMode import Annex.CatFile import qualified Annex.Queue import Logs.Location @@ -46,9 +45,7 @@ stageDirect = do - 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, Just mode) = do - shakey <- if isSymLink mode - then catKey sha - else return Nothing + shakey <- catKey sha mode mstat <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file filekey <- isAnnexLink file case (shakey, filekey, mstat, toInodeCache =<< mstat) of @@ -149,10 +146,9 @@ mergeDirectCleanup d oldsha newsha = do where go getsha getmode a araw | getsha item == nullSha = noop - | isSymLink (getmode item) = + | otherwise = maybe (araw f) (\k -> void $ a k f) - =<< catKey (getsha item) - | otherwise = araw f + =<< catKey (getsha item) (getmode item) f = DiffTree.file item moveout = removeDirect |