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 /Git | |
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 'Git')
-rw-r--r-- | Git/CatFile.hs | 2 | ||||
-rw-r--r-- | Git/FileMode.hs | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/Git/CatFile.hs b/Git/CatFile.hs index 984d2f465..bd86ff326 100644 --- a/Git/CatFile.hs +++ b/Git/CatFile.hs @@ -130,4 +130,4 @@ catTree h treeref = go <$> catObjectDetails h treeref parsemodefile b = let (modestr, file) = separate (== ' ') (encodeW8 $ L.unpack b) in (file, readmode modestr) - readmode = fst . Prelude.head . readOct + readmode = fst . fromMaybe (0, undefined) . headMaybe . readOct diff --git a/Git/FileMode.hs b/Git/FileMode.hs index d42df9833..fc4d0264e 100644 --- a/Git/FileMode.hs +++ b/Git/FileMode.hs @@ -13,8 +13,11 @@ import Utility.FileMode import System.PosixCompat.Types +symLinkMode :: FileMode +symLinkMode = 40960 + {- Git uses a special file mode to indicate a symlink. This is the case - even on Windows, so we hard code the valuse here, rather than using - System.Posix.Files.symbolicLinkMode. -} isSymLink :: FileMode -> Bool -isSymLink = checkMode 40960 +isSymLink = checkMode symLinkMode |