-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Higher-level types for working with hlibgit2 -- -- Higher-level types for working with hlibgit2 @package gitlib @version 0.5.1 -- | Error types which may be thrown during Git operations, using -- throwIO. module Data.Git.Error -- | There is a separate GitException for each possible failure when -- interacting with the Git repository. data GitException RepositoryNotExist :: String -> GitException RepositoryInvalid :: GitException BlobCreateFailed :: GitException BlobEmptyCreateFailed :: GitException TreeCreateFailed :: GitException TreeBuilderCreateFailed :: GitException TreeBuilderInsertFailed :: GitException TreeBuilderWriteFailed :: GitException TreeLookupFailed :: GitException TreeCannotTraverseBlob :: GitException TreeEntryLookupFailed :: GitException CommitCreateFailed :: GitException CommitLookupFailed :: GitException ReferenceCreateFailed :: GitException RefCannotCreateFromPartialOid :: GitException ReferenceLookupFailed :: GitException ObjectLookupFailed :: GitException ObjectIdTooLong :: GitException ObjectRefRequiresFullOid :: GitException OidCopyFailed :: GitException type Result = Either Text instance Typeable GitException instance Show GitException instance Exception GitException -- | The Oid type represents a Git hash value, whether partial or -- full. In general users do not interact with this type much, as all the -- top-level functions which expect hash values typically expect strings. module Data.Git.Oid -- | Oid represents either a full or partial SHA1 hash code used to -- identify Git objects. data Oid Oid :: COid -> Oid PartialOid :: COid -> Int -> Oid -- | COid is a type wrapper for a foreign pointer to libgit2's -- git_oid structure. Users should not have to deal with this -- type. newtype COid COid :: (ForeignPtr C'git_oid) -> COid oidToStr :: Ptr C'git_oid -> IO String -- | ObjRef refers to either a Git object of a particular type (if -- it has already been loaded into memory), or it refers to the -- COid of that object in the repository. This permits deferred -- loading of objects within potentially very large structures, such as -- trees and commits. However, it also means that every access to a -- sub-object must use loadObject from the type class Updatable. data ObjRef a IdRef :: COid -> ObjRef a ObjRef :: a -> ObjRef a -- | An Ident abstracts the fact that some objects won't have an -- identifier until they are written to disk -- even if sufficient -- information exists to determine that hash value. If construct as a -- Pending value, it is an IO action that writes the object -- to disk and retrieves the resulting hash value from Git; if -- Stored, it is a COid that is known to the repository. data Ident a Pending :: (a -> IO COid) -> Ident a Stored :: COid -> Ident a wrapOidPtr :: Ptr C'git_oid -> IO (ObjRef a) -- | Compare two COid values for equality. More typical is to use -- compare. compareCOid :: COid -> COid -> Ordering -- | Compare two COid values for equality, but only up to a certain -- length. compareCOidLen :: COid -> COid -> Int -> Ordering -- | True if two COid values are equal. equalCOid :: Ord a => a -> a -> Bool -- | Convert a hash string to a Maybe Oid value. If the -- string is less than 40 hexadecimal digits, the result will be of type -- PartialOid. -- --
--   >>> stringToOid "a143ecf"
--   Just a143ecf
--   
--   >>> stringToOid "a143ecf" >>= (\(Just (PartialOid _ l)) -> return $ l == 7)
--   True
--   
-- --
--   >>> let hash = "6cfc2ca31732fb6fa6b54bae6e586a57a0611aab"
--   
--   >>> stringToOid hash
--   Just 6cfc2ca31732fb6fa6b54bae6e586a57a0611aab
--   
--   >>> stringToOid hash >>= (\(Just (Oid _)) -> return True)
--   True
--   
stringToOid :: CStringable a => a -> IO (Maybe Oid) instance Show a => Show (ObjRef a) instance Eq Oid instance Eq COid instance Ord COid instance Show Oid instance Show (Ident a) instance Show COid module Data.Git.Reference data RefTarget RefTargetId :: Oid -> RefTarget RefTargetSymbolic :: Text -> RefTarget data Reference Reference :: Repository -> Text -> RefTarget -> ObjPtr C'git_reference -> Reference refRepo :: Reference -> Repository refName :: Reference -> Text refTarget :: Reference -> RefTarget refObj :: Reference -> ObjPtr C'git_reference createRef :: Text -> RefTarget -> Repository -> Reference lookupRef :: Text -> Repository -> IO (Maybe Reference) listRefNames :: Repository -> ListFlags -> IO [Text] allRefsFlag :: ListFlags oidRefsFlag :: ListFlags looseOidRefsFlag :: ListFlags symbolicRefsFlag :: ListFlags mapRefs :: Repository -> ListFlags -> ForeachRefCallback -> IO () mapAllRefs :: Repository -> ForeachRefCallback -> IO () mapOidRefs :: Repository -> ForeachRefCallback -> IO () mapLooseOidRefs :: Repository -> ForeachRefCallback -> IO () mapSymbolicRefs :: Repository -> ForeachRefCallback -> IO () lookupId :: Text -> Repository -> IO Oid writeRef :: Reference -> IO Reference writeRef_ :: Reference -> IO () instance Show RefTarget instance Eq RefTarget instance Show Reference instance Show ListFlags instance Eq ListFlags module Data.Git.Common data Signature Signature :: Text -> Text -> UTCTime -> Signature signatureName :: Signature -> Text signatureEmail :: Signature -> Text signatureWhen :: Signature -> UTCTime createSignature :: Signature packSignature :: Converter -> Ptr C'git_signature -> IO Signature withSignature :: Converter -> Signature -> (Ptr C'git_signature -> IO a) -> IO a data Base a Base :: Ident a -> Repository -> ObjPtr C'git_object -> Base a gitId :: Base a -> Ident a gitRepo :: Base a -> Repository gitObj :: Base a -> ObjPtr C'git_object newBase :: Repository -> Ident a -> ObjPtr C'git_object -> Base a instance Show Signature instance Eq Signature module Data.Git.Backend odbBackendAdd :: Repository -> Ptr C'git_odb_backend -> Int -> IO (Result Repository) type F'git_odb_backend_read_callback = Ptr (Ptr ()) -> Ptr CSize -> Ptr C'git_otype -> Ptr C'git_odb_backend -> Ptr C'git_oid -> IO CInt type F'git_odb_backend_read_prefix_callback = Ptr C'git_oid -> Ptr (Ptr ()) -> Ptr CSize -> Ptr C'git_otype -> Ptr C'git_odb_backend -> Ptr C'git_oid -> CUInt -> IO CInt type F'git_odb_backend_readstream_callback = Ptr (Ptr C'git_odb_stream) -> Ptr C'git_odb_backend -> Ptr C'git_oid -> IO CInt type F'git_odb_backend_read_header_callback = Ptr CSize -> Ptr C'git_otype -> Ptr C'git_odb_backend -> Ptr C'git_oid -> IO CInt type F'git_odb_backend_write_callback = Ptr C'git_oid -> Ptr C'git_odb_backend -> Ptr () -> CSize -> C'git_otype -> IO CInt type F'git_odb_backend_writestream_callback = Ptr (Ptr C'git_odb_stream) -> Ptr C'git_odb_backend -> CSize -> C'git_otype -> IO CInt type F'git_odb_backend_exists_callback = Ptr C'git_odb_backend -> Ptr C'git_oid -> IO CInt type F'git_odb_backend_free_callback = Ptr C'git_odb_backend -> IO () module Data.Git.Tag data Tag Tag :: Base Tag -> Oid -> Tag tagInfo :: Tag -> Base Tag tagRef :: Tag -> Oid instance Show Tag module Data.Git.Backend.Trace traceBackend :: Ptr C'git_odb_backend -> IO (Ptr C'git_odb_backend) instance Storable TraceBackend module Data.Git.Blob data Blob Blob :: Base Blob -> BlobContents -> Blob blobInfo :: Blob -> Base Blob blobContents :: Blob -> BlobContents data BlobContents BlobEmpty :: BlobContents BlobString :: ByteString -> BlobContents BlobStream :: ByteSource -> BlobContents newBlobBase :: Blob -> Base Blob -- | Create a new blob in the Repository, with ByteString as -- its contents. -- -- Note that since empty blobs cannot exist in Git, no means is provided -- for creating one; if the give string is empty, it is an error. createBlob :: ByteString -> Repository -> Blob getBlobContents :: Blob -> IO (Blob, BlobContents) blobSourceToString :: BlobContents -> IO (Maybe ByteString) -- | Write out a blob to its repository. If it has already been written, -- nothing will happen. writeBlob :: Blob -> IO Blob instance Updatable Blob instance Show Blob module Data.Git.Tree data TreeEntry BlobEntry :: ObjRef Blob -> Bool -> TreeEntry blobEntry :: TreeEntry -> ObjRef Blob blobEntryIsExe :: TreeEntry -> Bool TreeEntry :: ObjRef Tree -> TreeEntry treeEntry :: TreeEntry -> ObjRef Tree blobRefWithMode :: Bool -> Blob -> TreeEntry blobRef :: Blob -> TreeEntry exeBlobRef :: Blob -> TreeEntry blobIdRef :: Oid -> Bool -> TreeEntry treeRef :: Tree -> TreeEntry treeIdRef :: Oid -> TreeEntry type TreeMap = Map Text TreeEntry data Tree Tree :: Base Tree -> TreeMap -> Tree treeInfo :: Tree -> Base Tree treeContents :: Tree -> TreeMap newTreeBase :: Tree -> Base Tree -- | Create a new, empty tree. -- -- Since empty trees cannot exist in Git, attempting to write out an -- empty tree is a no-op. createTree :: Repository -> Tree lookupTree :: Oid -> Repository -> IO (Maybe Tree) doLookupTreeEntry :: [Text] -> Tree -> IO (Maybe TreeEntry) lookupTreeEntry :: FilePath -> Tree -> IO (Maybe TreeEntry) withGitTree :: Updatable b => ObjRef Tree -> b -> (Ptr C'git_tree -> IO a) -> IO a -- | Write out a tree to its repository. If it has already been written, -- nothing will happen. writeTree :: Tree -> IO Tree doWriteTree :: Tree -> IO (Tree, COid) doModifyTree :: [Text] -> (Maybe TreeEntry -> Either a (Maybe TreeEntry)) -> Bool -> Tree -> IO (Either a Tree) modifyTree :: FilePath -> (Maybe TreeEntry -> Either a (Maybe TreeEntry)) -> Bool -> Tree -> IO (Either a Tree) doUpdateTree :: [Text] -> TreeEntry -> Tree -> IO Tree updateTree :: FilePath -> TreeEntry -> Tree -> IO Tree removeFromTree :: FilePath -> Tree -> IO Tree splitPath :: FilePath -> [Text] instance Updatable Tree instance Show TreeEntry instance Show Tree module Data.Git.Commit data Commit Commit :: Base Commit -> Signature -> Signature -> Text -> String -> ObjRef Tree -> [ObjRef Commit] -> ObjPtr C'git_commit -> Commit commitInfo :: Commit -> Base Commit commitAuthor :: Commit -> Signature commitCommitter :: Commit -> Signature commitLog :: Commit -> Text commitEncoding :: Commit -> String commitTree :: Commit -> ObjRef Tree commitParents :: Commit -> [ObjRef Commit] commitObj :: Commit -> ObjPtr C'git_commit newCommitBase :: Commit -> Base Commit -- | Create a new, empty commit. -- -- Since empty commits cannot exist in Git, attempting to write out an -- empty commit is a no-op. createCommit :: Repository -> Commit lookupCommit :: Oid -> Repository -> IO (Maybe Commit) -- | Write out a commit to its repository. If it has already been written, -- nothing will happen. writeCommit :: Maybe Text -> Commit -> IO Commit doWriteCommit :: Maybe Text -> Commit -> IO (Commit, COid) getCommitParents :: Commit -> IO [Commit] getCommitParentPtrs :: Commit -> IO [ForeignPtr C'git_commit] modifyCommitTree :: FilePath -> (Maybe TreeEntry -> Either a (Maybe TreeEntry)) -> Bool -> Commit -> IO (Either a Commit) removeFromCommitTree :: FilePath -> Commit -> IO Commit doUpdateCommit :: [Text] -> TreeEntry -> Commit -> IO Commit updateCommit :: FilePath -> TreeEntry -> Commit -> IO Commit instance Updatable Commit instance Show Commit module Data.Git.Object data Object BlobObj :: Blob -> Object TreeObj :: Tree -> Object CommitObj :: Commit -> Object TagObj :: Tag -> Object data ObjectType BlobType :: ObjectType TreeType :: ObjectType CommitType :: ObjectType TagType :: ObjectType data NamedRef a FullHash :: a -> NamedRef a PartialHash :: a -> NamedRef a BranchName :: a -> NamedRef a TagName :: a -> NamedRef a RefName :: a -> NamedRef a FullRefName :: a -> NamedRef a Specifier :: a -> NamedRef a revParse :: CStringable a => NamedRef a -> IO (Maybe Oid) lookupObject :: Oid -> Repository -> IO (Maybe Object) -- | Interface for opening and creating repositories. Repository objects -- are immutable, and serve only to refer to the given repository. Any -- data associated with the repository — such as the list of branches — -- is queried as needed. module Data.Git.Repository type ObjPtr a = Maybe (ForeignPtr a) class Updatable a where update_ = void . update objectId x = case getId x of { Pending f -> Oid <$> f x Stored y -> return $ Oid y } objectRef x = do { oid <- objectId x; case oid of { Oid coid -> return (IdRef coid) PartialOid _ _ -> error "Did not expect to see a PartialOid" } } maybeObjectId x = case getId x of { Pending _ -> Nothing Stored y -> Just (Oid y) } loadObject (IdRef coid) y = lookupFunction (Oid coid) (objectRepo y) loadObject (ObjRef x) _ = return (Just x) getObject (IdRef _) = Nothing getObject (ObjRef x) = Just x getId :: Updatable a => a -> Ident a objectRepo :: Updatable a => a -> Repository objectPtr :: Updatable a => a -> ObjPtr C'git_object update :: Updatable a => a -> IO a update_ :: Updatable a => a -> IO () objectId :: Updatable a => a -> IO Oid objectRef :: Updatable a => a -> IO (ObjRef a) maybeObjectId :: Updatable a => a -> Maybe Oid lookupFunction :: Updatable a => Oid -> Repository -> IO (Maybe a) loadObject :: (Updatable a, Updatable b) => ObjRef a -> b -> IO (Maybe a) getObject :: Updatable a => ObjRef a -> Maybe a data Repository openRepository :: FilePath -> IO Repository createRepository :: FilePath -> Bool -> IO Repository openOrCreateRepository :: FilePath -> Bool -> IO Repository lookupObject' :: Oid -> Repository -> (Ptr (Ptr a) -> Ptr C'git_repository -> Ptr C'git_oid -> IO CInt) -> (Ptr (Ptr a) -> Ptr C'git_repository -> Ptr C'git_oid -> CUInt -> IO CInt) -> (COid -> ForeignPtr C'git_object -> Ptr C'git_object -> IO b) -> IO (Maybe b) withObject :: (Updatable a, Updatable b) => ObjRef a -> b -> (a -> IO c) -> IO c withObjectPtr :: (Updatable a, Updatable b) => ObjRef a -> b -> (Ptr c -> IO d) -> IO d module Data.Git