type t = Git.Hash.t let of_hash h = h let of_hex s = match Git.Hash.of_hex s with | h -> Some h | exception Invalid_argument _ -> None let to_hex = Git.Hash.to_hex let short c = String.sub (to_hex c) 0 12 let equal = Git.Hash.equal let compare = Git.Hash.compare let pp ppf c = Fmt.string ppf (to_hex c) let codec = Json.Codec.of_of_string ~kind:"commit" ~enc:to_hex (fun s -> Option.to_result ~none:(Fmt.str "%S is not a commit id" s) (of_hex s))