9290095fc2
In git, a Ref can be a Sha, or a Branch, or a Tag. I added type aliases for those. Note that this does not prevent mixing up of eg, refs and branches at the type level. Since git really doesn't care, except rare cases like git update-ref, or git tag -d, that seems ok for now. There's also a tree-ish, but let's just use Ref for it. A given Sha or Ref may or may not be a tree-ish, depending on the object type, so there seems no point in trying to represent it at the type level.
31 lines
798 B
Haskell
31 lines
798 B
Haskell
{- 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,
|
|
catFileHandle
|
|
) where
|
|
|
|
import qualified Data.ByteString.Lazy.Char8 as L
|
|
|
|
import Common.Annex
|
|
import qualified Git
|
|
import qualified Git.CatFile
|
|
import qualified Annex
|
|
|
|
catFile :: Git.Branch -> 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 }
|
|
return h
|