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

Safe HaskellNone

Data.Git.Oid

Description

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.

Synopsis

Documentation

data Oid Source

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

Constructors

Oid COid 
PartialOid COid Int 

Instances

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.

Constructors

COid (ForeignPtr C'git_oid) 

Instances

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.

Constructors

IdRef COid 
ObjRef a 

Instances

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.

Constructors

Pending (a -> IO COid) 
Stored COid 

Instances

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.

stringToOid :: 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.

>>> 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