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 /Command | |
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 'Command')
-rw-r--r-- | Command/Indirect.hs | 2 | ||||
-rw-r--r-- | Command/PreCommit.hs | 5 | ||||
-rw-r--r-- | Command/Sync.hs | 3 |
3 files changed, 5 insertions, 5 deletions
diff --git a/Command/Indirect.hs b/Command/Indirect.hs index 79e736d11..f866a93b6 100644 --- a/Command/Indirect.hs +++ b/Command/Indirect.hs @@ -78,7 +78,7 @@ perform = do return Nothing | otherwise -> maybe noop (fromdirect f) - =<< catKey sha + =<< catKey sha mode _ -> noop go _ = noop diff --git a/Command/PreCommit.hs b/Command/PreCommit.hs index c35cf61e1..afc5882d4 100644 --- a/Command/PreCommit.hs +++ b/Command/PreCommit.hs @@ -16,7 +16,6 @@ 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 @@ -48,8 +47,8 @@ startDirect _ = next $ do withkey (Git.DiffTree.srcsha diff) (Git.DiffTree.srcmode diff) removeAssociatedFile withkey (Git.DiffTree.dstsha diff) (Git.DiffTree.dstmode diff) addAssociatedFile where - withkey sha mode a = when (sha /= nullSha && isSymLink mode) $ do - k <- catKey sha + withkey sha mode a = when (sha /= nullSha) $ do + k <- catKey sha mode case k of Nothing -> noop Just key -> void $ a key (Git.DiffTree.file diff) diff --git a/Command/Sync.hs b/Command/Sync.hs index ca823c736..d8c6fb8d4 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -29,6 +29,7 @@ import qualified Remote.Git import Types.Key import Config import Annex.ReplaceFile +import Git.FileMode import Data.Hash.MD5 @@ -321,7 +322,7 @@ resolveMerge' u case msha of Nothing -> a Nothing Just sha -> do - key <- catKey sha + key <- catKey sha symLinkMode maybe (return False) (a . Just) key {- The filename to use when resolving a conflicted merge of a file, |