gitlib-0.6.4: Higher-level types for working with hlibgit2

Safe HaskellNone



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.



data Oid Source

Oid represents either a full or partial SHA1 hash code used to identify Git objects.


Oid COid 
PartialOid COid Int 


newtype COid Source

COid is a type wrapper for a foreign pointer to libgit2's git_oid structure. Users should not have to deal with this type.


COid (ForeignPtr C'git_oid) 


data ObjRef a Source

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.


IdRef COid 
ObjRef a 


Show a => Show (ObjRef a) 

data Ident a Source

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.


Pending (a -> IO COid) 
Stored COid 


Eq (Ident a) 
Show (Ident a) 

compareCOid :: COid -> COid -> OrderingSource

Compare two COid values for equality. More typical is to use compare.

compareCOidLen :: COid -> COid -> Int -> OrderingSource

Compare two COid values for equality, but only up to a certain length.

equalCOid :: Ord a => a -> a -> BoolSource

True if two COid values are equal.

parseOid :: CStringable a => a -> IO (Maybe Oid)Source

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)
>>> let hash = "6cfc2ca31732fb6fa6b54bae6e586a57a0611aab"
>>> parseOid hash
Just 6cfc2ca31732fb6fa6b54bae6e586a57a0611aab
>>> parseOid hash >>= (\(Just (Oid _)) -> return True)