Git object storage and pack files for Eio
1(* Copyright (c) 2015 Daniel C. Bünzli
2 Copyright (c) 2020-2024 Romain Calascibetta <romain.calascibetta@gmail.com>
3 Copyright (c) 2024-2026 Thomas Gazagnaire <thomas@gazagnaire.org>
4
5 Permission to use, copy, modify, and distribute this software for any
6 purpose with or without fee is hereby granted, provided that the above
7 copyright notice and this permission notice appear in all copies.
8
9 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *)
16
17(** Git references (branches, tags, HEAD). *)
18
19type t
20(** The type of references. *)
21
22val head : t
23(** The HEAD reference. *)
24
25val master : t
26(** The refs/heads/master reference. *)
27
28val main : t
29(** The refs/heads/main reference. *)
30
31val of_string : string -> (t, [ `Msg of string ]) result
32(** Parse a reference from a string. *)
33
34val of_string_exn : string -> t
35(** [of_string_exn s] is like {!of_string} but raises on error. *)
36
37val v : string -> t
38(** [v s] is an alias for {!of_string_exn}. *)
39
40val to_string : t -> string
41(** Convert a reference to a string. *)
42
43val pp : t Fmt.t
44(** Pretty-print a reference. *)
45
46val equal : t -> t -> bool
47(** Equality on references. *)
48
49val compare : t -> t -> int
50(** Total ordering on references. *)
51
52val hash : t -> int
53(** Hash function for use with Hashtbl. *)
54
55val segs : t -> string list
56(** Split a reference into path segments. *)
57
58val ( / ) : t -> string -> t
59(** [t / seg] appends a segment to a reference.
60 @raise Invalid_argument if segment contains null or slash. *)
61
62val ( // ) : t -> t -> t
63(** [t1 // t2] appends two references. *)
64
65(** {1 Reference contents} *)
66
67type contents =
68 | Hash of Hash.t
69 | Ref of t
70 (** Reference contents: either a direct hash or a symbolic reference. *)
71
72val contents_equal : contents -> contents -> bool
73(** Equality on reference contents. *)
74
75val contents_compare : contents -> contents -> int
76(** Total ordering on reference contents. *)
77
78val pp_contents : contents Fmt.t
79(** Pretty-print reference contents. *)
80
81val contents_of_string : string -> (contents, [ `Msg of string ]) result
82(** Parse reference file contents. *)
83
84val contents_of_string_exn : string -> contents
85(** [contents_of_string_exn s] is like {!contents_of_string} but raises on
86 error. *)
87
88val contents_to_string : contents -> string
89(** Encode reference contents for writing to file. *)
90
91module Set : Set.S with type elt = t
92module Map : Map.S with type key = t