Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
at main 66 lines 1.5 kB view raw
1(** Commit objects. 2 3 Commits point to a tree and have metadata like author, message, timestamp. 4*) 5 6(** {1 Commit Functor} *) 7 8module Make (F : Codec.S) : sig 9 type t 10 (** A commit object. *) 11 12 type hash = F.hash 13 14 (** {2 Commit Fields} *) 15 16 val tree : t -> hash 17 (** [tree c] returns the root tree hash. *) 18 19 val parents : t -> hash list 20 (** [parents c] returns parent commit hashes. *) 21 22 val author : t -> string 23 (** [author c] returns the author string. *) 24 25 val committer : t -> string 26 (** [committer c] returns the committer string. *) 27 28 val message : t -> string 29 (** [message c] returns the commit message. *) 30 31 val timestamp : t -> int64 32 (** [timestamp c] returns the commit timestamp (Unix epoch). *) 33 34 (** {2 Construction} *) 35 36 val v : 37 tree:hash -> 38 parents:hash list -> 39 author:string -> 40 ?committer:string -> 41 ?timestamp:int64 -> 42 message:string -> 43 unit -> 44 t 45 (** [v ~tree ~parents ~author ?committer ?timestamp ~message ()] creates a new 46 commit. *) 47 48 (** {2 Serialization} *) 49 50 val hash : t -> hash 51 (** [hash c] computes the commit hash. *) 52 53 val of_bytes : string -> (t, [> `Msg of string ]) result 54 (** [of_bytes data] deserializes a commit. *) 55 56 val to_bytes : t -> string 57 (** [to_bytes c] serializes a commit. *) 58end 59 60(** {1 Pre-instantiated Commits} *) 61 62module Git : module type of Make (Codec.Git) 63(** Git-format commits with SHA-1 hashes. *) 64 65module Mst : module type of Make (Codec.Mst) 66(** MST-format commits with SHA-256 hashes. *)