package git

  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 -> (Hash.t * Value.t) list Lwt.t

Get the full store contents.


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

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

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

Return the object having the given Hash name.

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

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

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

Check whether a key belongs to the store.

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

Return the list of Hash names.

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

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

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

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


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

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

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

Check if a reference exists.

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

Read a given reference.

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

Read a given reference.

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

Write the HEAD.

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

Read the head contents.

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

Write a reference.

val remove_reference : t -> 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 -> Reference.t -> test:Hash.t option -> set: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 -> Index.t Lwt.t

Return the index file.

val write_index : t -> ?index:Index.t -> 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 -> Hash.t -> string option Lwt.t

Read a raw buffer from the store.

val write_inflated : t -> string -> 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.


Innovation. Community. Security.