Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
at inode 80 lines 2.4 kB view raw
1(** Git interoperability. 2 3 Bidirectional support for reading and writing Git repositories. This allows 4 Irmin to work with existing .git directories and interoperate with the Git 5 ecosystem. Pack files are handled transparently. *) 6 7(** {1 Git Repository Operations} *) 8 9val import_git : 10 sw:Eio.Switch.t -> 11 fs:Eio.Fs.dir_ty Eio.Path.t -> 12 git_dir:Fpath.t -> 13 Store.Git.t 14(** [import_git ~sw ~fs ~git_dir] opens a bare .git directory as an Irmin store. 15 Supports both loose objects and pack files. *) 16 17val open_git : 18 sw:Eio.Switch.t -> fs:Eio.Fs.dir_ty Eio.Path.t -> path:Fpath.t -> Store.Git.t 19(** [open_git ~sw ~fs ~path] opens a Git repository (with .git subdirectory) as 20 an Irmin store. Supports both loose objects and pack files. *) 21 22val init_git : 23 sw:Eio.Switch.t -> fs:Eio.Fs.dir_ty Eio.Path.t -> path:Fpath.t -> Store.Git.t 24(** [init_git ~sw ~fs ~path] initializes a new Git repository at [path] and 25 returns an Irmin store for it. *) 26 27(** {1 Backend} *) 28 29val git_backend : Git.Repository.t -> Hash.sha1 Backend.t 30(** [git_backend repo] creates a content-addressable backend that stores 31 objects as Git objects in [repo]. *) 32 33(** {1 Object Operations} *) 34 35val read_object : 36 sw:Eio.Switch.t -> 37 fs:Eio.Fs.dir_ty Eio.Path.t -> 38 git_dir:Fpath.t -> 39 Hash.sha1 -> 40 (string * string, [> `Msg of string ]) result 41(** [read_object ~sw ~fs ~git_dir hash] reads a Git object, returning 42 [(type, data)] where type is "blob", "tree", "commit", or "tag". Checks 43 loose objects first, then pack files. *) 44 45val write_object : 46 sw:Eio.Switch.t -> 47 fs:Eio.Fs.dir_ty Eio.Path.t -> 48 git_dir:Fpath.t -> 49 typ:string -> 50 string -> 51 Hash.sha1 52(** [write_object ~sw ~fs ~git_dir ~typ data] writes a Git object as a 53 zlib-compressed loose object. *) 54 55(** {1 Reference Operations} *) 56 57val read_ref : 58 sw:Eio.Switch.t -> 59 fs:Eio.Fs.dir_ty Eio.Path.t -> 60 git_dir:Fpath.t -> 61 string -> 62 Hash.sha1 option 63(** [read_ref ~sw ~fs ~git_dir name] reads a Git reference. Follows symbolic 64 refs. *) 65 66val write_ref : 67 sw:Eio.Switch.t -> 68 fs:Eio.Fs.dir_ty Eio.Path.t -> 69 git_dir:Fpath.t -> 70 string -> 71 Hash.sha1 -> 72 unit 73(** [write_ref ~sw ~fs ~git_dir name hash] writes a Git reference. *) 74 75val list_refs : 76 sw:Eio.Switch.t -> 77 fs:Eio.Fs.dir_ty Eio.Path.t -> 78 git_dir:Fpath.t -> 79 string list 80(** [list_refs ~sw ~fs ~git_dir] lists all references. *)