package git

  1. Overview
  2. Docs

Create an on-disk store implementation.

Parameters

module IO : IO
module D : Hash.DIGEST
module I : Inflate.S

Signature

include Store.S
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.

Objects

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.

References

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 refernce.

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.

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.

val create_file : t -> string -> Tree.perm -> Blob.t -> unit Lwt.t

Create a file on the filesystem, with the given mode.

val entry_of_file : t -> Index.t -> string -> Tree.perm -> Hash.Blob.t -> Blob.t -> Index.entry option Lwt.t

Generate a cache entry for the file. Create a fresh file if it does not already exist. If root is not set, use the current working directory as repository root.

val reset : t -> unit Lwt.t

Reset the store.

val clear : unit -> unit

Clear the LRU caches.

OCaml

Innovation. Community. Security.