package git-mirage

  1. Overview
  2. Docs
type t

Git store handlers.

val create : ?root:string -> ?dot_git:string -> ?level:int -> unit -> t Lwt.t

Create a store handler for the given path. See root and level.

val dot_git : t -> string

The location of the .git directory. By defaut it is root/.git.

val root : t -> string

The location of the repository root (or any other meaningful name to be displayed to the user). By default, it is the current directory.

val level : t -> int

The compression level used when creating new Git objects. must be between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). The default value (currently equivalent to level 6) requests a default compromise between speed and compression.

val dump : t -> unit Lwt.t

Dump the store contents to stderr.

val contents : t -> (Git.Hash.t * Git.Value.t) list Lwt.t

Get the full store contents.

Objects

val size : t -> Git.Hash.t -> int option Lwt.t

Return the size of the blob having the given Hash name.

val read : t -> Git.Hash.t -> Git.Value.t option Lwt.t

Return the object having the given Hash name.

val read_exn : t -> Git.Hash.t -> Git.Value.t Lwt.t

Same as read but raises Not_found if no object with the given Hash is found.

val mem : t -> Git.Hash.t -> bool Lwt.t

Check whether a key belongs to the store.

val list : t -> Git.Hash.t list Lwt.t

Return the list of Hash names.

val write : t -> Git.Value.t -> Git.Hash.t Lwt.t

Write a value and return the Hash of its serialized contents.

val write_pack : t -> Git.Pack.raw -> Git.Hash.Set.t Lwt.t

Write a raw pack file and the corresponding index. Return the objects IDs which have been written.

References

val references : t -> Git.Reference.t list Lwt.t

Return the list of references (ie. tags and branches).

val mem_reference : t -> Git.Reference.t -> bool Lwt.t

Check if a reference exists.

val read_reference : t -> Git.Reference.t -> Git.Hash.t option Lwt.t

Read a given reference.

val read_reference_exn : t -> Git.Reference.t -> Git.Hash.t Lwt.t

Read a given reference.

val write_head : t -> Git.Reference.head_contents -> unit Lwt.t

Write the HEAD.

val read_head : t -> Git.Reference.head_contents option Lwt.t

Read the head contents.

val write_reference : t -> Git.Reference.t -> Git.Hash.t -> unit Lwt.t

Write a reference.

val remove_reference : t -> Git.Reference.t -> unit Lwt.t

Remove a reference. Note: packed references cannot be removed (and no error will be raised) so assume that remove_reference r is unsafe as it could either delete r, do nothing, or revert r to a previous (packed) value.

val test_and_set_reference : t -> Git.Reference.t -> test:Git.Hash.t option -> set:Git.Hash.t option -> bool Lwt.t

Atomic updates (Test and set) for references. Note: when set is None, test_and_set_reference should be considered unsafe. See remove_reference for details.

Git index files

val read_index : t -> Git.Index.t Lwt.t

Return the index file.

val write_index : t -> ?index:Git.Index.t -> Git.Hash.Commit.t -> unit Lwt.t

Update the index file for the given revision. A side-effect of this operation is that the blobs are expanded into the filesystem.

Note: It is the user responsability to ensure that filenames are valid. No sanitazition is done by the library -- the Git format does not impose a filename format as this is a constraint of the underlying filesystem.

If index is not set, read the current index and update it with the current state of the filesystem.

Backend kind

val kind : [ `Mem | `Disk ]

The kind of backend.

Raw values

val read_inflated : t -> Git.Hash.t -> string option Lwt.t

Read a raw buffer from the store.

val write_inflated : t -> string -> Git.Hash.t Lwt.t

Write a raw buffer in the store.

Digest functions that the store is using.

Inflate functions that the store is using.

OCaml

Innovation. Community. Security.