package git

  1. Overview
  2. Docs

Hashing.

This module handles both usual hashes and short hashes, which are shorter sequences of bits with a valid hexadecimal representation. The only way to create short hashes is to use of_hex with the strict argument set to false.

When short hashes are used in normal Git operations, they can raise Ambiguous.

This module define various abstraction to distinguish between general, commit, node and blob hashes. It's just an abstraction layer, at runtine they will all be similar.

module type S = sig ... end
include S

Signature for hash values

The usual compare functions on hashes, but can raise Ambiguous if one is short hash and is prefix to the other.

include S
type t

The type for the given Git object.

val equal : t -> t -> bool

Are two objects equal?

val hash : t -> int

Hash an object.

val compare : t -> t -> int

Compare two objects.

val pp : t Fmt.t

pp is the pretty-printer for values of type t.

val to_raw : t -> string

Raw hash value.

val of_raw : string -> t

Abstract a raw hash value.

val to_hex : t -> string

to_hex h is hs' hex encoding.

val hex_length : t -> int

The number of hex digits in the hash.

val lt : t -> t -> bool

(<) relation between hash.

val is_prefix : t -> t -> bool

Check if a hash is a prefix of another hash.

module Set : Set with type elt = t
module Map : Map with type key = t
exception Ambiguous of string

Exception raised when using short and ambiguous hashes.

module Commit : S

Commit nodes.

module Tree : S

Treee nodes.

module Blob : S

Blob nodes.

val of_commit : Commit.t -> t

A commit node is also a node.

val to_commit : t -> Commit.t

A node might be a commit.

val of_tree : Tree.t -> t

A tree node is also a node.

val to_tree : t -> Tree.t

A node might be a node.

val of_blob : Blob.t -> t

A blob node is also a node.

val to_blob : t -> Blob.t

A node might be a blob node.

module type H = sig ... end
module type IO = sig ... end
type 'a digest = 'a -> t

The type for digest functions.

module type DIGEST = sig ... end

The signature to compute hash digests.

module IO (D : DIGEST) : IO
module Array (D : DIGEST) : sig ... end