aboutsummaryrefslogtreecommitdiff
path: root/Annex/CatFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-10-04 00:40:47 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-10-04 00:59:08 -0400
commitcfe21e85e7fba61ac588e210f2a9b75f8d081f42 (patch)
tree3237aa5460cb38254a44a6462c83db3c2276c229 /Annex/CatFile.hs
parentff21fd4a652cc6516d0e06ab885adf1c93eddced (diff)
rename
Diffstat (limited to 'Annex/CatFile.hs')
-rw-r--r--Annex/CatFile.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs
new file mode 100644
index 000000000..4f98815f8
--- /dev/null
+++ b/Annex/CatFile.hs
@@ -0,0 +1,24 @@
+{- git cat-file interface, with handle automatically stored in the Annex monad
+ -
+ - Copyright 2011 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Annex.CatFile (
+ catFile
+) where
+
+import Annex.Common
+import qualified Git.CatFile
+import qualified Annex
+
+catFile :: String -> FilePath -> Annex String
+catFile branch file = maybe startup go =<< Annex.getState Annex.catfilehandle
+ where
+ startup = do
+ g <- gitRepo
+ h <- liftIO $ Git.CatFile.catFileStart g
+ Annex.changeState $ \s -> s { Annex.catfilehandle = Just h }
+ go h
+ go h = liftIO $ Git.CatFile.catFile h branch file