(* Copyright (c) 2024-2026 Thomas Gazagnaire 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. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) (** Git worktree operations. This module provides operations for managing git worktrees - separate working directories that share the same git repository. *) type entry = { path : Fpath.t; (** Absolute path to the worktree *) head : Hash.t; (** HEAD commit hash *) branch : string option; (** Branch name if not detached *) } (** A git worktree entry. *) (** {1 Low-level interface} These functions operate on the raw git directory structure. *) type t (** A worktree manager. *) val v : fs:Eio.Fs.dir_ty Eio.Path.t -> git_dir:string -> t (** [v ~fs ~git_dir] creates a worktree manager. *) val add : t -> head:Hash.t -> path:Fpath.t -> branch:string -> (unit, [ `Msg of string ]) result (** [add t ~head ~path ~branch] creates a new worktree at [path] with a new branch [branch] starting at [head]. *) val remove : t -> path:Fpath.t -> force:bool -> (unit, [ `Msg of string ]) result (** [remove t ~path ~force] removes a worktree at [path]. *) val list : t -> head:Hash.t option -> current_branch:string option -> entry list (** [list t ~head ~current_branch] returns all worktrees. *) val exists : t -> path:Fpath.t -> bool (** [exists t ~path] returns true if a worktree exists at [path]. *)