Safe Haskell | None |
---|
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
- = Oid COid
- | PartialOid COid Int
- newtype COid = COid (ForeignPtr C'git_oid)
- oidToStr :: Ptr C'git_oid -> IO String
- data ObjRef a
- data Ident a
- wrapOidPtr :: Ptr C'git_oid -> IO (ObjRef a)
- compareCOid :: COid -> COid -> Ordering
- compareCOidLen :: COid -> COid -> Int -> Ordering
- equalCOid :: Ord a => a -> a -> Bool
- stringToOid :: CStringable a => a -> IO (Maybe Oid)
Documentation
Oid
represents either a full or partial SHA1 hash code used to identify
Git objects.
COid
is a type wrapper for a foreign pointer to libgit2's git_oid
structure. Users should not have to deal with this type.
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
.
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.
compareCOid :: COid -> COid -> OrderingSource
compareCOidLen :: COid -> COid -> Int -> OrderingSource
Compare two COid
values for equality, but only up to a certain length.
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