-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Git operations in haskell
--
-- An haskell implementation of git storage operations, allowing users to
-- manipulate git repositories (read and write).
--
-- This implementation is fully interoperable with the main C
-- implementation.
--
-- This is stricly only manipulating the git store (what's inside the
-- .git directory), and doesn't do anything with the index or your
-- working directory files.
@package hit
@version 0.4.2
module Data.Git.Delta
-- | a delta is a source size, a destination size and a list of delta cmd
data Delta
Delta :: Word64 -> Word64 -> [DeltaCmd] -> Delta
-- | possible commands in a delta
data DeltaCmd
DeltaCopy :: ByteString -> DeltaCmd
DeltaSrc :: Word64 -> Word64 -> DeltaCmd
-- | parse a delta. format is 2 variable sizes, followed by delta cmds. for
-- each cmd: * if first byte MSB is set, we copy from source. *
-- otherwise, we copy from delta. * extensions are not handled.
deltaParse :: Parser ByteString Delta
-- | read one delta from a lazy bytestring.
deltaRead :: ByteString -> Maybe Delta
-- | apply a delta on a lazy bytestring, returning a new bytestring.
deltaApply :: ByteString -> Delta -> ByteString
instance Show DeltaCmd
instance Eq DeltaCmd
instance Show Delta
instance Eq Delta
module Data.Git.Revision
data Revision
Revision :: String -> [RevModifier] -> Revision
data RevModifier
-- | parent accessor ^n and ^
RevModParent :: Int -> RevModifier
-- | parent accessor ~n
RevModParentFirstN :: Int -> RevModifier
RevModAtType :: String -> RevModifier
RevModAtDate :: String -> RevModifier
RevModAtN :: Int -> RevModifier
fromString :: IsString a => String -> a
instance Eq RevModifier
instance Eq Revision
instance IsString Revision
instance Show Revision
instance Show RevModifier
module Data.Git.Ref
-- | represent a git reference (SHA1)
data Ref
isHex :: ByteString -> Bool
isHexString :: [Char] -> Bool
-- | take a hexadecimal bytestring that represent a reference and turn into
-- a ref
fromHex :: ByteString -> Ref
-- | take a hexadecimal string that represent a reference and turn into a
-- ref
fromHexString :: String -> Ref
-- | transform a bytestring that represent a binary bytestring and returns
-- a ref.
fromBinary :: ByteString -> Ref
-- | turn a reference into a binary bytestring
toBinary :: Ref -> ByteString
-- | transform a ref into an hexadecimal bytestring
toHex :: Ref -> ByteString
-- | transform a ref into an hexadecimal string
toHexString :: Ref -> String
-- | returns the prefix (leading byte) of this reference
refPrefix :: Ref -> Int
-- | compare prefix
cmpPrefix :: String -> Ref -> Ordering
-- | returns the splitted format prefix/suffix for addressing the
-- loose object database
toFilePathParts :: Ref -> (String, String)
-- | hash a bytestring into a reference
hash :: ByteString -> Ref
hashLBS :: ByteString -> Ref
instance Eq Ref
instance Ord Ref
instance Show Ref
module Data.Git.Types
-- | type of a git object.
data ObjectType
TypeTree :: ObjectType
TypeBlob :: ObjectType
TypeCommit :: ObjectType
TypeTag :: ObjectType
TypeDeltaOff :: ObjectType
TypeDeltaRef :: ObjectType
-- | Represent a root tree with zero to many tree entries.
data Tree
Tree :: [TreeEnt] -> Tree
treeGetEnts :: Tree -> [TreeEnt]
-- | Represent a commit object.
data Commit
Commit :: Ref -> [Ref] -> Person -> Person -> Maybe ByteString -> [CommitExtra] -> ByteString -> Commit
commitTreeish :: Commit -> Ref
commitParents :: Commit -> [Ref]
commitAuthor :: Commit -> Person
commitCommitter :: Commit -> Person
commitEncoding :: Commit -> Maybe ByteString
commitExtras :: Commit -> [CommitExtra]
commitMessage :: Commit -> ByteString
data CommitExtra
CommitExtra :: ByteString -> ByteString -> CommitExtra
commitExtraKey :: CommitExtra -> ByteString
commitExtraValue :: CommitExtra -> ByteString
-- | Represent a binary blob.
data Blob
Blob :: ByteString -> Blob
blobGetContent :: Blob -> ByteString
-- | Represent a signed tag.
data Tag
Tag :: Ref -> ObjectType -> ByteString -> Person -> ByteString -> Tag
tagRef :: Tag -> Ref
tagObjectType :: Tag -> ObjectType
tagBlob :: Tag -> ByteString
tagName :: Tag -> Person
tagS :: Tag -> ByteString
-- | an author or committer line has the format: name email time
-- timezone FIXME: should be a string, but I don't know if the data is
-- stored consistantly in one encoding (UTF8)
data Person
Person :: ByteString -> ByteString -> GitTime -> Person
personName :: Person -> ByteString
personEmail :: Person -> ByteString
personTime :: Person -> GitTime
-- | Git time is number of seconds since unix epoch
data GitTime
GitTime :: Integer -> Int -> GitTime
toUTCTime :: GitTime -> UTCTime
toPOSIXTime :: GitTime -> POSIXTime
-- | Delta pointing to an offset.
data DeltaOfs
DeltaOfs :: Word64 -> Delta -> DeltaOfs
-- | Delta pointing to a ref.
data DeltaRef
DeltaRef :: Ref -> Delta -> DeltaRef
-- | represent one entry in the tree (permission,file or directory
-- name,blob or tree ref) name should maybe a filepath, but not sure
-- about the encoding.
type TreeEnt = (Int, ByteString, Ref)
instance Show ObjectType
instance Eq ObjectType
instance Show GitTime
instance Eq GitTime
instance Show Person
instance Eq Person
instance Show Tree
instance Eq Tree
instance Show Blob
instance Eq Blob
instance Show CommitExtra
instance Eq CommitExtra
instance Show Commit
instance Eq Commit
instance Show Tag
instance Eq Tag
instance Show DeltaOfs
instance Eq DeltaOfs
instance Show DeltaRef
instance Eq DeltaRef
instance Monoid Tree
instance Enum ObjectType
module Data.Git.Named
-- | Represent a named specifier.
data RefSpecTy
RefHead :: RefSpecTy
RefOrigHead :: RefSpecTy
RefFetchHead :: RefSpecTy
RefBranch :: String -> RefSpecTy
RefTag :: String -> RefSpecTy
RefRemote :: String -> RefSpecTy
RefPatches :: String -> RefSpecTy
RefStash :: RefSpecTy
RefOther :: String -> RefSpecTy
-- | content of a ref file.
data RefContentTy
RefDirect :: Ref -> RefContentTy
RefLink :: RefSpecTy -> RefContentTy
RefContentUnknown :: ByteString -> RefContentTy
readPackedRefs :: FilePath -> IO [(RefSpecTy, Ref)]
existsRefFile :: FilePath -> RefSpecTy -> IO Bool
writeRefFile :: FilePath -> RefSpecTy -> RefContentTy -> IO ()
readRefFile :: FilePath -> RefSpecTy -> IO RefContentTy
instance Show RefSpecTy
instance Eq RefSpecTy
instance Ord RefSpecTy
instance Show RefContentTy
instance Eq RefContentTy
module Data.Git.Storage.PackIndex
-- | represent an packIndex header with the version and the fanout table
data PackIndexHeader
PackIndexHeader :: !Word32 -> !(Vector Word32) -> PackIndexHeader
data PackIndex
PackIndex :: Vector Ref -> Vector Word32 -> Vector Word32 -> Ref -> Ref -> PackIndex
packIndexSha1s :: PackIndex -> Vector Ref
packIndexCRCs :: PackIndex -> Vector Word32
packIndexPackoffs :: PackIndex -> Vector Word32
packIndexPackChecksum :: PackIndex -> Ref
packIndexChecksum :: PackIndex -> Ref
-- | open an index
packIndexOpen :: FilePath -> Ref -> IO FileReader
-- | close an index
packIndexClose :: FileReader -> IO ()
-- | variant of withFile on the index file and with a FileReader
withPackIndex :: FilePath -> Ref -> (FileReader -> IO a) -> IO a
-- | enumerate every indexes file in the pack directory
packIndexEnumerate :: FilePath -> IO [Ref]
-- | get the number of reference in this index with a specific prefix
packIndexHeaderGetNbWithPrefix :: PackIndexHeader -> Int -> Word32
-- | return the reference offset in the packfile if found
packIndexGetReferenceLocation :: PackIndexHeader -> FileReader -> Ref -> IO (Maybe Word64)
-- | get all references that start by prefix.
packIndexGetReferencesWithPrefix :: PackIndexHeader -> FileReader -> String -> IO [Ref]
-- | read index header from an index filereader
packIndexReadHeader :: FileReader -> IO PackIndexHeader
-- | read all index
packIndexRead :: FilePath -> Ref -> IO (PackIndexHeader, (Vector Ref, Vector Word32, Vector Word32, [ByteString], Ref, Ref))
-- | get index header from an index reference
packIndexGetHeader :: FilePath -> Ref -> IO PackIndexHeader
instance Show PackIndexHeader
instance Eq PackIndexHeader
module Data.Git.Storage.Object
-- | location of an object in the database
data ObjectLocation
NotFound :: ObjectLocation
Loose :: Ref -> ObjectLocation
Packed :: Ref -> Word64 -> ObjectLocation
-- | type of a git object.
data ObjectType
TypeTree :: ObjectType
TypeBlob :: ObjectType
TypeCommit :: ObjectType
TypeTag :: ObjectType
TypeDeltaOff :: ObjectType
TypeDeltaRef :: ObjectType
type ObjectHeader = (ObjectType, Word64, Maybe ObjectPtr)
type ObjectData = ByteString
-- | Delta objects points to some others objects in the database either as
-- offset in the pack or as a direct reference.
data ObjectPtr
PtrRef :: Ref -> ObjectPtr
PtrOfs :: Word64 -> ObjectPtr
-- | describe a git object, that could of 6 differents types: tree, blob,
-- commit, tag and deltas (offset or ref). the deltas one are only
-- available in packs.
data Object
ObjCommit :: Commit -> Object
ObjTag :: Tag -> Object
ObjBlob :: Blob -> Object
ObjTree :: Tree -> Object
ObjDeltaOfs :: DeltaOfs -> Object
ObjDeltaRef :: DeltaRef -> Object
-- | Raw objects infos have an header (type, size, ptr), the data and a
-- pointers chains to parents for resolved objects.
data ObjectInfo
ObjectInfo :: ObjectHeader -> ObjectData -> [ObjectPtr] -> ObjectInfo
oiHeader :: ObjectInfo -> ObjectHeader
oiData :: ObjectInfo -> ObjectData
oiChains :: ObjectInfo -> [ObjectPtr]
class Objectable a
getType :: Objectable a => a -> ObjectType
getRaw :: Objectable a => a -> ByteString
isDelta :: Objectable a => a -> Bool
toObject :: Objectable a => a -> Object
objectToType :: Object -> ObjectType
objectTypeMarshall :: ObjectType -> String
objectTypeUnmarshall :: String -> ObjectType
objectTypeIsDelta :: ObjectType -> Bool
objectIsDelta :: Object -> Bool
objectToTree :: Object -> Maybe Tree
objectToCommit :: Object -> Maybe Commit
objectToTag :: Object -> Maybe Tag
objectToBlob :: Object -> Maybe Blob
-- | parse a tree content
treeParse :: Parser ByteString Tree
-- | parse a commit content
commitParse :: Parser ByteString Commit
-- | parse a tag content
tagParse :: Parser ByteString Tag
-- | parse a blob content
blobParse :: Parser ByteString Blob
objectParseTree :: Parser ByteString Object
objectParseCommit :: Parser ByteString Object
objectParseTag :: Parser ByteString Object
objectParseBlob :: Parser ByteString Object
objectWriteHeader :: ObjectType -> Word64 -> ByteString
objectWrite :: Object -> ByteString
objectHash :: ObjectType -> Word64 -> ByteString -> Ref
instance Show ObjectLocation
instance Eq ObjectLocation
instance Show ObjectPtr
instance Eq ObjectPtr
instance Show ObjectInfo
instance Eq ObjectInfo
instance Show Object
instance Eq Object
instance Objectable DeltaRef
instance Objectable DeltaOfs
instance Objectable Tree
instance Objectable Tag
instance Objectable Commit
instance Objectable Blob
module Data.Git.Storage.Pack
data PackedObjectInfo
PackedObjectInfo :: ObjectType -> Word64 -> Word64 -> Word64 -> Maybe ObjectPtr -> PackedObjectInfo
poiType :: PackedObjectInfo -> ObjectType
poiOffset :: PackedObjectInfo -> Word64
poiSize :: PackedObjectInfo -> Word64
poiActualSize :: PackedObjectInfo -> Word64
poiExtra :: PackedObjectInfo -> Maybe ObjectPtr
type PackedObjectRaw = (PackedObjectInfo, ByteString)
-- | Enumerate the pack refs available in this repository.
packEnumerate :: FilePath -> IO [Ref]
-- | open a pack
packOpen :: FilePath -> Ref -> IO FileReader
-- | close a pack
packClose :: FileReader -> IO ()
-- | return the number of entries in this pack
packReadHeader :: FilePath -> Ref -> IO Word32
-- | read an object at a specific position using a map function on the
-- objectData
packReadMapAtOffset :: FileReader -> Word64 -> (ByteString -> ByteString) -> IO (Maybe Object)
-- | read an object at a specific position
packReadAtOffset :: FileReader -> Word64 -> IO (Maybe Object)
-- | read a raw representation at a specific position
packReadRawAtOffset :: FileReader -> Word64 -> IO (PackedObjectRaw)
-- | enumerate all objects in this pack and callback to f for reach raw
-- objects
packEnumerateObjects :: FilePath -> Ref -> Int -> (PackedObjectRaw -> IO a) -> IO ()
packedObjectToObject :: (PackedObjectInfo, ByteString) -> Maybe Object
packObjectFromRaw :: (ObjectType, Maybe ObjectPtr, ByteString) -> Maybe Object
instance Show PackedObjectInfo
instance Eq PackedObjectInfo
module Data.Git.Storage.Loose
newtype Zipped
Zipped :: ByteString -> Zipped
getZippedData :: Zipped -> ByteString
-- | unmarshall an object (with header) from a bytestring.
looseUnmarshall :: ByteString -> Object
-- | unmarshall an object as (header, data) tuple from a bytestring
looseUnmarshallRaw :: ByteString -> (ObjectHeader, ObjectData)
-- | unmarshall an object (with header) from a zipped stream.
looseUnmarshallZipped :: Zipped -> Object
-- | unmarshall an object as (header, data) tuple from a zipped stream
looseUnmarshallZippedRaw :: Zipped -> (ObjectHeader, ObjectData)
-- | marshall as lazy bytestring an object except deltas.
looseMarshall :: Object -> ByteString
-- | read a specific ref from a loose object and returns an object
looseRead :: FilePath -> Ref -> IO Object
-- | read only the header of a loose object.
looseReadHeader :: FilePath -> Ref -> IO (ObjectType, Word64, Maybe a)
-- | read a specific ref from a loose object and returns an header and
-- data.
looseReadRaw :: FilePath -> Ref -> IO (ObjectHeader, ObjectData)
-- | check if a specific ref exists as loose object
looseExists :: FilePath -> Ref -> IO Bool
-- | create a new blob on a temporary location and on success move it to
-- the object store with its digest name.
looseWriteBlobFromFile :: FilePath -> FilePath -> IO Ref
-- | write an object to disk as a loose reference. use
-- looseWriteBlobFromFile for efficiently writing blobs when being
-- commited from a file.
looseWrite :: FilePath -> Object -> IO Ref
-- | enumarate all prefixes available in the object store.
looseEnumeratePrefixes :: FilePath -> IO [[Char]]
-- | enumerate all references available with a specific prefix.
looseEnumerateWithPrefixFilter :: FilePath -> String -> (Ref -> Bool) -> IO [Ref]
looseEnumerateWithPrefix :: FilePath -> String -> IO [Ref]
module Data.Git.Storage
-- | represent an git repo, with possibly already opened filereaders for
-- indexes and packs
data Git
packedNamed :: Git -> PackedRef
gitRepoPath :: Git -> FilePath
-- | open a new git repository context
openRepo :: FilePath -> IO Git
-- | close a git repository context, closing all remaining fileReaders.
closeRepo :: Git -> IO ()
-- | execute a function f with a git context.
withRepo :: FilePath -> (Git -> IO c) -> IO c
-- | execute a function on the current repository.
--
-- check findRepo to see how the git repository is found.
withCurrentRepo :: (Git -> IO a) -> IO a
-- | Find the git repository from the current directory.
--
-- If the environment variable GIT_DIR is set then it's used, otherwise
-- iterate from current directory, up to 128 parents for a .git directory
findRepoMaybe :: IO (Maybe FilePath)
-- | Find the git repository from the current directory.
--
-- If the environment variable GIT_DIR is set then it's used, otherwise
-- iterate from current directory, up to 128 parents for a .git directory
findRepo :: IO FilePath
-- | basic checks to see if a specific path looks like a git repo.
isRepo :: FilePath -> IO Bool
-- | initialize a new repository at a specific location.
initRepo :: FilePath -> IO ()
iterateIndexes :: Git -> (b -> (Ref, PackIndexReader) -> IO (b, Bool)) -> b -> IO b
-- | Get the object location of a specific reference
findReference :: Git -> Ref -> IO ObjectLocation
-- | get all the references that start by a specific prefix
findReferencesWithPrefix :: Git -> String -> IO [Ref]
-- | get an object from repository
getObjectRaw :: Git -> Ref -> Bool -> IO (Maybe ObjectInfo)
-- | get an object from repository
getObjectRawAt :: Git -> ObjectLocation -> Bool -> IO (Maybe ObjectInfo)
-- | get an object from repository using a ref.
getObject :: Git -> Ref -> Bool -> IO (Maybe Object)
-- | get an object from repository using a location to reference it.
getObjectAt :: Git -> ObjectLocation -> Bool -> IO (Maybe Object)
-- | get an object type from repository
getObjectType :: Git -> Ref -> IO (Maybe ObjectType)
-- | set an object in the store and returns the new ref this is always
-- going to create a loose object.
setObject :: Git -> Object -> IO Ref
module Data.Git.Repository
-- | represent an git repo, with possibly already opened filereaders for
-- indexes and packs
data Git
type HTree = [(Int, ByteString, HTreeEnt)]
-- | hierarchy tree, either a reference to a blob (file) or a tree
-- (directory).
data HTreeEnt
TreeDir :: Ref -> HTree -> HTreeEnt
TreeFile :: Ref -> HTreeEnt
-- | get a specified commit
getCommit :: Git -> Ref -> IO (Maybe Commit)
-- | get a specified tree
getTree :: Git -> Ref -> IO (Maybe Tree)
-- | Rewrite a set of commits from a revision and returns the new ref.
--
-- If during revision traversal (diving) there's a commit with zero or
-- multiple parents then the traversal will stop regardless of the amount
-- of parent requested.
--
-- calling rewrite f 2 (revisionOf d) on the following tree:
--
-- a <-- b <-- c <-- d
--
-- result in the following tree after mapping with f:
--
-- a <-- f(b) <-- f(c) <-- f(d)
rewrite :: Git -> (Commit -> IO Commit) -> Revision -> Int -> IO Ref
-- | build a hierarchy tree from a tree object
buildHTree :: Git -> Tree -> IO HTree
-- | resolve the ref (tree or blob) related to a path at a specific commit
-- ref
resolvePath :: Git -> Ref -> [ByteString] -> IO (Maybe Ref)
-- | returns a tree from a ref that might be either a commit, a tree or a
-- tag.
resolveTreeish :: Git -> Ref -> IO (Maybe Tree)
-- | try to resolve a string to a specific commit ref for example: HEAD,
-- HEAD^, master~3, shortRef
resolveRevision :: Git -> Revision -> IO (Maybe Ref)
-- | initialize a new repository at a specific location.
initRepo :: FilePath -> IO ()
-- | basic checks to see if a specific path looks like a git repo.
isRepo :: FilePath -> IO Bool
module Data.Git
-- | represent a git reference (SHA1)
data Ref
-- | Represent a commit object.
data Commit
Commit :: Ref -> [Ref] -> Person -> Person -> Maybe ByteString -> [CommitExtra] -> ByteString -> Commit
commitTreeish :: Commit -> Ref
commitParents :: Commit -> [Ref]
commitAuthor :: Commit -> Person
commitCommitter :: Commit -> Person
commitEncoding :: Commit -> Maybe ByteString
commitExtras :: Commit -> [CommitExtra]
commitMessage :: Commit -> ByteString
-- | an author or committer line has the format: name email time
-- timezone FIXME: should be a string, but I don't know if the data is
-- stored consistantly in one encoding (UTF8)
data Person
Person :: ByteString -> ByteString -> GitTime -> Person
personName :: Person -> ByteString
personEmail :: Person -> ByteString
personTime :: Person -> GitTime
data CommitExtra
CommitExtra :: ByteString -> ByteString -> CommitExtra
commitExtraKey :: CommitExtra -> ByteString
commitExtraValue :: CommitExtra -> ByteString
-- | Represent a root tree with zero to many tree entries.
data Tree
Tree :: [TreeEnt] -> Tree
treeGetEnts :: Tree -> [TreeEnt]
-- | Represent a binary blob.
data Blob
Blob :: ByteString -> Blob
blobGetContent :: Blob -> ByteString
-- | Represent a signed tag.
data Tag
Tag :: Ref -> ObjectType -> ByteString -> Person -> ByteString -> Tag
tagRef :: Tag -> Ref
tagObjectType :: Tag -> ObjectType
tagBlob :: Tag -> ByteString
tagName :: Tag -> Person
tagS :: Tag -> ByteString
-- | Git time is number of seconds since unix epoch
data GitTime
GitTime :: Integer -> Int -> GitTime
data Revision
-- | try to resolve a string to a specific commit ref for example: HEAD,
-- HEAD^, master~3, shortRef
resolveRevision :: Git -> Revision -> IO (Maybe Ref)
-- | returns a tree from a ref that might be either a commit, a tree or a
-- tag.
resolveTreeish :: Git -> Ref -> IO (Maybe Tree)
-- | resolve the ref (tree or blob) related to a path at a specific commit
-- ref
resolvePath :: Git -> Ref -> [ByteString] -> IO (Maybe Ref)
-- | execute a function on the current repository.
--
-- check findRepo to see how the git repository is found.
withCurrentRepo :: (Git -> IO a) -> IO a
-- | execute a function f with a git context.
withRepo :: FilePath -> (Git -> IO c) -> IO c
-- | Find the git repository from the current directory.
--
-- If the environment variable GIT_DIR is set then it's used, otherwise
-- iterate from current directory, up to 128 parents for a .git directory
findRepo :: IO FilePath
-- | initialize a new repository at a specific location.
initRepo :: FilePath -> IO ()
-- | basic checks to see if a specific path looks like a git repo.
isRepo :: FilePath -> IO Bool
-- | Rewrite a set of commits from a revision and returns the new ref.
--
-- If during revision traversal (diving) there's a commit with zero or
-- multiple parents then the traversal will stop regardless of the amount
-- of parent requested.
--
-- calling rewrite f 2 (revisionOf d) on the following tree:
--
-- a <-- b <-- c <-- d
--
-- result in the following tree after mapping with f:
--
-- a <-- f(b) <-- f(c) <-- f(d)
rewrite :: Git -> (Commit -> IO Commit) -> Revision -> Int -> IO Ref
-- | get an object from repository using a ref.
getObject :: Git -> Ref -> Bool -> IO (Maybe Object)
-- | get a specified commit
getCommit :: Git -> Ref -> IO (Maybe Commit)
-- | get a specified tree
getTree :: Git -> Ref -> IO (Maybe Tree)
-- | set an object in the store and returns the new ref this is always
-- going to create a loose object.
setObject :: Git -> Object -> IO Ref