A Git object identifier: a hash algorithm plus the raw digest bytes.
Every OID in Gitility carries its algorithm explicitly — nothing in the library assumes 20-byte digests. Query execution is SHA-1-only until the engine's SHA-256 support lands, but every type, cursor, and protocol is hash-agnostic from day one.
Public functions accept full lowercase or uppercase hex strings as a convenience, but Gitility always returns typed OIDs.
iex> {:ok, oid} = Gitility.OID.parse("da39a3ee5e6b4b0d3255bfef95601890afd80709")
iex> oid.algorithm
:sha1
iex> Gitility.OID.to_string(oid)
"da39a3ee5e6b4b0d3255bfef95601890afd80709"
Summary
Functions
The digest size in bytes for algorithm.
Builds an OID from an algorithm and raw digest bytes.
Like new/2 but raises Gitility.Error on invalid input.
Parses a full hex object ID string, inferring the algorithm from length (40 hex chars → SHA-1, 64 → SHA-256). Accepts upper or lower case.
Like parse/1 but raises Gitility.Error on invalid input.
Formats an OID as a lowercase hex string.
Types
Functions
@spec digest_size(algorithm()) :: pos_integer()
The digest size in bytes for algorithm.
@spec new(algorithm(), binary()) :: {:ok, t()} | {:error, Gitility.Error.t()}
Builds an OID from an algorithm and raw digest bytes.
Returns {:error, %Gitility.Error{code: :invalid_oid}} if the byte size
does not match the algorithm's digest size.
Like new/2 but raises Gitility.Error on invalid input.
@spec parse(String.t()) :: {:ok, t()} | {:error, Gitility.Error.t()}
Parses a full hex object ID string, inferring the algorithm from length (40 hex chars → SHA-1, 64 → SHA-256). Accepts upper or lower case.
Abbreviated IDs are not accepted here; only stores that can prove
uniqueness resolve prefixes (see Gitility.ODB).
Like parse/1 but raises Gitility.Error on invalid input.
Formats an OID as a lowercase hex string.