add catFileIndex

This commit is contained in:
Joey Hess 2012-09-15 16:44:27 -04:00
parent 87fb9c690e
commit e1baf48d88
2 changed files with 11 additions and 0 deletions

View file

@ -7,6 +7,7 @@
module Annex.CatFile ( module Annex.CatFile (
catFile, catFile,
catFileIndex,
catObject, catObject,
catObjectDetails, catObjectDetails,
catFileHandle catFileHandle
@ -25,6 +26,11 @@ catFile branch file = do
h <- catFileHandle h <- catFileHandle
liftIO $ Git.CatFile.catFile h branch file liftIO $ Git.CatFile.catFile h branch file
catFileIndex :: FilePath -> Annex L.ByteString
catFileIndex file = do
h <- catFileHandle
liftIO $ Git.CatFile.catFileIndex h file
catObject :: Git.Ref -> Annex L.ByteString catObject :: Git.Ref -> Annex L.ByteString
catObject ref = do catObject ref = do
h <- catFileHandle h <- catFileHandle

View file

@ -10,6 +10,7 @@ module Git.CatFile (
catFileStart, catFileStart,
catFileStop, catFileStop,
catFile, catFile,
catFileIndex,
catObject, catObject,
catObjectDetails, catObjectDetails,
) where ) where
@ -40,6 +41,10 @@ catFileStop = CoProcess.stop
catFile :: CatFileHandle -> Branch -> FilePath -> IO L.ByteString catFile :: CatFileHandle -> Branch -> FilePath -> IO L.ByteString
catFile h branch file = catObject h $ Ref $ show branch ++ ":" ++ file catFile h branch file = catObject h $ Ref $ show branch ++ ":" ++ file
{- Reads a file from the index. -}
catFileIndex :: CatFileHandle -> FilePath -> IO L.ByteString
catFileIndex h file = catObject h $ Ref $ ':' : file
{- Uses a running git cat-file read the content of an object. {- Uses a running git cat-file read the content of an object.
- Objects that do not exist will have "" returned. -} - Objects that do not exist will have "" returned. -}
catObject :: CatFileHandle -> Ref -> IO L.ByteString catObject :: CatFileHandle -> Ref -> IO L.ByteString