Git object storage and pack files for Eio
at main 54 lines 2.0 kB view raw
1(* Copyright (c) 2024-2026 Thomas Gazagnaire <thomas@gazagnaire.org> 2 3 Permission to use, copy, modify, and distribute this software for any 4 purpose with or without fee is hereby granted, provided that the above 5 copyright notice and this permission notice appear in all copies. 6 7 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) 14 15(** Git worktree operations. 16 17 This module provides operations for managing git worktrees - separate 18 working directories that share the same git repository. *) 19 20type entry = { 21 path : Fpath.t; (** Absolute path to the worktree *) 22 head : Hash.t; (** HEAD commit hash *) 23 branch : string option; (** Branch name if not detached *) 24} 25(** A git worktree entry. *) 26 27(** {1 Low-level interface} 28 29 These functions operate on the raw git directory structure. *) 30 31type t 32(** A worktree manager. *) 33 34val v : fs:Eio.Fs.dir_ty Eio.Path.t -> git_dir:string -> t 35(** [v ~fs ~git_dir] creates a worktree manager. *) 36 37val add : 38 t -> 39 head:Hash.t -> 40 path:Fpath.t -> 41 branch:string -> 42 (unit, [ `Msg of string ]) result 43(** [add t ~head ~path ~branch] creates a new worktree at [path] with a new 44 branch [branch] starting at [head]. *) 45 46val remove : 47 t -> path:Fpath.t -> force:bool -> (unit, [ `Msg of string ]) result 48(** [remove t ~path ~force] removes a worktree at [path]. *) 49 50val list : t -> head:Hash.t option -> current_branch:string option -> entry list 51(** [list t ~head ~current_branch] returns all worktrees. *) 52 53val exists : t -> path:Fpath.t -> bool 54(** [exists t ~path] returns true if a worktree exists at [path]. *)