(* Copyright (c) 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. *) (** Commits written without a ref, as [git commit-tree] writes them: a tree from files, a parent's tree with files written over it or with paths carried from another commit, each committed with the identities and the message given. *) val root : ?sign:(Git.Commit.t -> Git.Commit.t) -> Repository.t -> files:(string * string) list -> author:Git.User.t -> committer:Git.User.t -> string -> Git.Hash.t (** [root ~sign r ~files ~author ~committer message] writes [sign] (defaults to the identity) of a commit with no parent whose tree holds each of [files], a name and its content, as a regular file at its top. *) val child : ?sign:(Git.Commit.t -> Git.Commit.t) -> Repository.t -> parent:Git.Hash.t -> edits:(string * string) list -> author:Git.User.t -> committer:Git.User.t -> string -> (Git.Hash.t, [ `Msg of string ]) result (** [child ~sign r ~parent ~edits ~author ~committer message] writes [sign] (defaults to the identity) of a commit whose one parent is [parent] and whose tree is [parent]'s with each of [edits], a slash-separated path and its content, written over it as a regular file. It is [Error] when [parent] or a part of its tree cannot be read. *) val carry : Repository.t -> base:Git.Hash.t -> tip:Git.Hash.t -> paths:string list -> author:Git.User.t -> committer:Git.User.t -> string -> (Git.Hash.t * Git.Hash.t, [ `Msg of string ]) result (** [carry r ~base ~tip ~paths ~author ~committer message] writes a commit whose one parent is [base] and whose tree is [base]'s with each of [paths] (slash-separated, from the root) as [tip] holds it: its entry, mode included, or none where [tip] has none. It is the commit and its tree, or [Error] when a commit or a tree it reads cannot be read. *) val with_tree : Repository.t -> Git.Hash.t -> tree:Git.Hash.t -> Git.Hash.t (** [with_tree r c ~tree] is the commit [c] with [tree] for its tree and its parents, author, committer and message, written; [c] itself when it has [tree] already. @raise Invalid_argument when [c] cannot be read as a commit. *)