Something went wrong. Try again.
Git format in pure OCaml
Something went wrong. Try again.
1234567891011121314151617181920212223242526(* Copyright (c) 2024-2026 Thomas Gazagnaire <thomas@gazagnaire.org>
Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. *)
(** Git path patterns.
[Pathspec] is the pattern matching that [.gitignore] and [.gitattributes] share: shell globs ([*], [?], [[...]], [**]), anchoring (a leading or internal [/] anchors the pattern to the directory of its file, and a pattern without one matches a base name at any depth), and a leading [**/] that matches at any depth. Callers remove the syntax specific to [.gitignore] ([!] negation, a trailing [/], comments) before compiling. *)
type t(** The type for compiled patterns. *)
val compile : string -> t option(** [compile pat] is the compiled pattern [pat], or [None] if [pat] is empty. *)
val matches : t -> base:string -> path:string -> bool(** [matches t ~base ~path] is [true] iff [path] matches [t]. [path] is slash-separated and relative to the work-tree root, and lies under [base], the directory of the pattern ([""] for the root). *)