Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
at main 74 lines 2.2 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 Object Operations} *) 28 29val read_object : 30 sw:Eio.Switch.t -> 31 fs:Eio.Fs.dir_ty Eio.Path.t -> 32 git_dir:Fpath.t -> 33 Hash.sha1 -> 34 (string * string, [> `Msg of string ]) result 35(** [read_object ~sw ~fs ~git_dir hash] reads a Git object, returning 36 [(type, data)] where type is "blob", "tree", "commit", or "tag". Checks 37 loose objects first, then pack files. *) 38 39val write_object : 40 sw:Eio.Switch.t -> 41 fs:Eio.Fs.dir_ty Eio.Path.t -> 42 git_dir:Fpath.t -> 43 typ:string -> 44 string -> 45 Hash.sha1 46(** [write_object ~sw ~fs ~git_dir ~typ data] writes a Git object as a 47 zlib-compressed loose object. *) 48 49(** {1 Reference Operations} *) 50 51val read_ref : 52 sw:Eio.Switch.t -> 53 fs:Eio.Fs.dir_ty Eio.Path.t -> 54 git_dir:Fpath.t -> 55 string -> 56 Hash.sha1 option 57(** [read_ref ~sw ~fs ~git_dir name] reads a Git reference. Follows symbolic 58 refs. *) 59 60val write_ref : 61 sw:Eio.Switch.t -> 62 fs:Eio.Fs.dir_ty Eio.Path.t -> 63 git_dir:Fpath.t -> 64 string -> 65 Hash.sha1 -> 66 unit 67(** [write_ref ~sw ~fs ~git_dir name hash] writes a Git reference. *) 68 69val list_refs : 70 sw:Eio.Switch.t -> 71 fs:Eio.Fs.dir_ty Eio.Path.t -> 72 git_dir:Fpath.t -> 73 string list 74(** [list_refs ~sw ~fs ~git_dir] lists all references. *)