-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Higher-level types for working with hlibgit2 -- -- gitlib is a high-level, lazy and conduit-aware type wrapper -- around the libgit2 C library (http://libgit2.github.com). The -- aim is both type-safety and convenience of use for Haskell users, -- combined with high performance and minimal memory footprint by taking -- advantage of Haskell's laziness and the conduit library's -- deterministic resource cleanup. -- -- For further information, as well as typical use cases, see -- Data.Git.Tutorial. @package gitlib @version 0.7.0 -- | This module provides a brief introductory tutorial in the -- "Introduction" section followed by a lengthy discussion of the -- library's design and idioms. module Data.Git.Tutorial -- | 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 TreeUpdateFailed :: 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. -- --
-- >>> parseOid "a143ecf" -- Just a143ecf -- -- >>> parseOid "a143ecf" >>= (\(Just (PartialOid _ l)) -> return $ l == 7) -- True ---- --
-- >>> let hash = "6cfc2ca31732fb6fa6b54bae6e586a57a0611aab" -- -- >>> parseOid hash -- Just 6cfc2ca31732fb6fa6b54bae6e586a57a0611aab -- -- >>> parseOid hash >>= (\(Just (Oid _)) -> return True) -- True --parseOid :: 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 Eq (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 :: Repository -> Text -> RefTarget -> Reference resolveRef :: Repository -> Text -> IO (Maybe Oid) lookupRef :: Repository -> Text -> IO (Maybe Reference) listRefNames :: Repository -> ListFlags -> IO [Text] data ListFlags allRefsFlag :: ListFlags oidRefsFlag :: ListFlags looseOidRefsFlag :: ListFlags symbolicRefsFlag :: ListFlags mapRefs :: Repository -> ListFlags -> (Text -> IO a) -> IO [a] mapAllRefs :: Repository -> (Text -> IO a) -> IO [a] mapOidRefs :: Repository -> (Text -> IO a) -> IO [a] mapLooseOidRefs :: Repository -> (Text -> IO a) -> IO [a] mapSymbolicRefs :: Repository -> (Text -> IO a) -> IO [a] writeRef :: Reference -> IO Reference writeRef_ :: Reference -> IO () 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 type ByteSource = GSource IO ByteString 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 :: Repository -> ByteString -> Blob getBlobContents :: Blob -> IO (Blob, BlobContents) blobSourceToString :: BlobContents -> IO (Maybe ByteString) lookupBlob :: Repository -> Oid -> IO (Maybe Blob) -- | Write out a blob to its repository. If it has already been written, -- nothing will happen. writeBlob :: Blob -> IO Blob instance Eq Blob instance Updatable Blob instance Show Blob instance Eq BlobContents 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 :: Repository -> Oid -> IO (Maybe Tree) doLookupTreeEntry :: Tree -> [Text] -> IO (Maybe TreeEntry) lookupTreeEntry :: Tree -> FilePath -> 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 :: Tree -> [Text] -> TreeEntry -> IO Tree updateTree :: Tree -> FilePath -> TreeEntry -> 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 data PinnedEntry PinnedEntry :: Oid -> Commit -> TreeEntry -> PinnedEntry pinnedOid :: PinnedEntry -> Oid pinnedCommit :: PinnedEntry -> Commit pinnedEntry :: PinnedEntry -> TreeEntry 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 -> Signature -> Commit lookupCommit :: Repository -> Oid -> IO (Maybe Commit) lookupRefCommit :: Repository -> Text -> IO (Maybe Commit) addCommitParent :: Commit -> Commit -> Commit -- | Write out a commit to its repository. If it has already been written, -- nothing will happen. writeCommit :: Commit -> Maybe Text -> IO Commit getCommitParents :: Commit -> IO [Commit] modifyCommitTree :: Commit -> FilePath -> (Maybe TreeEntry -> Either a (Maybe TreeEntry)) -> Bool -> IO (Either a Commit) removeFromCommitTree :: Commit -> FilePath -> IO Commit updateCommit :: Commit -> FilePath -> TreeEntry -> IO Commit commitHistoryFirstParent :: Commit -> IO [Commit] commitEntry :: Commit -> FilePath -> IO (Maybe TreeEntry) commitEntryHistory :: Commit -> FilePath -> IO [PinnedEntry] instance Show PinnedEntry 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 :: Repository -> Oid -> 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" } } objectRefId (IdRef coid) = return (Oid coid) objectRefId (ObjRef x) = objectId x maybeObjectId x = case getId x of { Pending _ -> Nothing Stored y -> Just (Oid y) } loadObject (IdRef coid) y = lookupFunction (objectRepo y) (Oid coid) loadObject (ObjRef x) _ = return (Just x) loadObject' x y = maybe (throwIO ObjectLookupFailed) return =<< loadObject x y 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) objectRefId :: Updatable a => ObjRef a -> IO Oid maybeObjectId :: Updatable a => a -> Maybe Oid lookupFunction :: Updatable a => Repository -> Oid -> IO (Maybe a) loadObject :: (Updatable a, Updatable b) => ObjRef a -> b -> IO (Maybe a) loadObject' :: (Updatable a, Updatable b) => ObjRef a -> b -> IO a getObject :: Updatable a => ObjRef a -> Maybe a data Repository Repository :: FilePath -> [Repository -> Text -> IO ()] -> [Repository -> Reference -> IO ()] -> ForeignPtr C'git_repository -> Repository repoPath :: Repository -> FilePath repoBeforeReadRef :: Repository -> [Repository -> Text -> IO ()] repoOnWriteRef :: Repository -> [Repository -> Reference -> IO ()] repoObj :: Repository -> ForeignPtr C'git_repository openRepository :: FilePath -> IO Repository createRepository :: FilePath -> Bool -> IO Repository openOrCreateRepository :: FilePath -> Bool -> IO Repository repositoryPtr :: Repository -> ForeignPtr C'git_repository lookupObject' :: Repository -> Oid -> (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 -- | gitlib is a high-level, lazy and conduit-aware type wrapper -- around the libgit2 C library (http://libgit2.github.com). The -- aim is both type-safety and convenience of use for Haskell users, -- combined with high performance and minimal memory footprint by taking -- advantage of Haskell's laziness and the conduit library's -- deterministic resource cleanup. -- -- For further information, as well as typical use cases, see -- Data.Git.Tutorial. module Data.Git