Module Git.Tree

A Git Tree object.

A Tree object ties on or more Blob.t objects into a directory structure. In addition, a tree object can refer to other tree objects, thus creating a directory hierarchy.

type perm = [
  1. | `Normal
    (*

    A Blob.t.

    *)
  2. | `Everybody
  3. | `Exec
    (*

    An executable.

    *)
  4. | `Dir
    (*

    A sub-Tree.t.

    *)
  5. | `Commit
    (*

    A sub-module (Commit.t).

    *)
]

Type of type node.

val equal_perm : perm -> perm -> bool

The equal function for perm.

type 'hash entry = {
  1. perm : perm;
  2. name : string;
  3. node : 'hash;
}

Type of entry. It describes the name name, the type perm and the reference to the node node.

val entry : name:string -> perm -> 'hash -> 'hash entry

entry ~name perm node is the entry to node with the name name and the mode perm.

val pp_entry : pp:'hash Fmt.t -> 'hash entry Fmt.t

Pretty-printer of entry.

val equal_entry : equal:('hash -> 'hash -> bool) -> 'hash entry -> 'hash entry -> bool

The equal function for entry.

type 'hash t = private 'hash entry list

Type of tree is a list of file names and modes along with refs to the associated blob and/or tree objects.

val v : 'hash entry list -> 'hash t

v entries ties all entries into one tree object. It does not remove duplicate but re-order the given list such as:

Tree.digest (Tree.v [ { name= a; _ }; { name= b; _ }] ) ;;
- : hash = 8d14531846b95bfa3564b58ccfb7913a034323b8
Tree.digest (Tree.v [ { name= b; _ }; { name= a; _ }] ) ;;
- : hash = 8d14531846b95bfa3564b58ccfb7913a034323b8
val pp : pp:'hash Fmt.t -> 'hash t Fmt.t

Pretty-printer of t.

val equal : equal:('hash -> 'hash -> bool) -> 'hash t -> 'hash t -> bool

The equal function for t.

val add : 'hash entry -> 'hash t -> 'hash t

add entry tree returns a tree containing all elements of tree, plus entry. If entry was already in tree, tree is unchanged.

val remove : name:string -> 'hash t -> 'hash t

remove ~name tree returns a tree containing all elements of tree, except one with the name name. If any entries of the given tree don't have the name name, tree is returned unchanged.

val is_empty : 'hash t -> bool

is_empty tree tests whether the given tree is empty or not.

val hashes : 'hash t -> 'hash list

hashes tree returns the list of all node references of the given tree.

val to_list : 'hash t -> 'hash entry list

to_list tree returns the list of all entries of the given tree.

val of_list : 'hash entry list -> 'hash t

Same as v.

val iter : ('hash entry -> unit) -> 'hash t -> unit

iter f tree applies f in turn to all elements of s.

module type S = sig ... end
module Make (Hash : sig ... end) : S with type hash = Hash.t

Functor building an implementation of the tree structure. The functor returns a structure containing a type hash of digests and a type t of trees (structurally equal to t).