diff options
author | Joey Hess <joey@kitenet.net> | 2011-11-12 17:45:12 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-11-12 17:45:12 -0400 |
commit | 04edae6791b4eddaa77dda2407264dc4434d74b7 (patch) | |
tree | 3c42dfa812220f003b53cb47ce4ff1e73dd1f108 /Annex/CatFile.hs | |
parent | cea65b9e5bf6bcc9a9350703dbbb0951c6e00c82 (diff) |
Optimised union merging; now only runs git cat-file once.
Diffstat (limited to 'Annex/CatFile.hs')
-rw-r--r-- | Annex/CatFile.hs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs index 99cc519f5..0541f7269 100644 --- a/Annex/CatFile.hs +++ b/Annex/CatFile.hs @@ -6,18 +6,25 @@ -} module Annex.CatFile ( - catFile + catFile, + catFileHandle ) where +import qualified Data.ByteString.Lazy.Char8 as L + import Common.Annex import qualified Git.CatFile import qualified Annex -catFile :: String -> FilePath -> Annex String -catFile branch file = maybe startup go =<< Annex.getState Annex.catfilehandle +catFile :: String -> FilePath -> Annex L.ByteString +catFile branch file = do + h <- catFileHandle + liftIO $ Git.CatFile.catFile h branch file + +catFileHandle :: Annex Git.CatFile.CatFileHandle +catFileHandle = maybe startup return =<< Annex.getState Annex.catfilehandle where startup = do h <- inRepo Git.CatFile.catFileStart Annex.changeState $ \s -> s { Annex.catfilehandle = Just h } - go h - go h = liftIO $ Git.CatFile.catFile h branch file + return h |