package git

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

The Pack module which represents any packed git object available in the git repository.

The type of the packed Git object.

type state = t

The type for the state of a Git store.

type value = Value.t

The type of the Git values.

module Deflate : sig ... end

The Deflate module used to make the implementation.

module PEnc : Pack.P with module Hash := Hash and module Deflate := Deflate
module IDec : Index_pack.LAZY with module Hash := Hash
module IEnc : Index_pack.ENCODER with module Hash := Hash
module PInfo : Pack_info.S with module Hash := Hash and module Inflate := Inflate and module HDec := HDec and module PDec := PDec
type error = error
val lookup : state -> Hash.t -> (Hash.t * (Checkseum.Crc32.t * int64)) option Lwt.t

lookup state hash tries to find the object associated by the hash hash in all IDX files available in the current git repository state. This function returns None if the Git object does not exist in any IDX files or it does not exists in the current repository.

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

mem state hash is true iff there is an object such that digest(object) = hash. This function is the same as lookup state hash <> None.

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

list state is the list of all the packed Git object noticed by all IDX files available in the current git repository state. Errors are ignored and skipped.

val read : state -> Hash.t -> (value, error) Stdlib.result Lwt.t

read state hash can retrieve a git packed object from any PACK files available in the current git repository state. It just inflates the git object and informs some meta-data (like kind, CRC-32 check-sum, length, etc.) about it. Then, the client can use the related decoder to get the OCaml value.

This function allocates 2

struct.t

needed to re-construct the git packed object in any case (if it is delta-ified or not) and a certain amount of little buffer (sized by 0x7F bytes) to help the construction only when the requested object is delta-ified.

Can return an error:

  • FS.File.error or FS.Dir.error or FS.Mapper.error when we retrieve a file-system error
  • PACKDecoder.error when we retrieve an error about the decoding of the packed git object in the founded PACKi file
  • IDXDecoder.error when we retrieve an error about the decoding of an IDX file
  • `Not_found when the requested object is not packed
val size : state -> Hash.t -> (int, error) Stdlib.result Lwt.t

size state hash returns the size of the git packed object which respects the predicate digest(object) = hash. The size is how many byte(s) are needed to store the serialized (but not inflated) git object in bytes (without the header).

As for read, size can return an error.

type stream = unit -> Cstruct.t option Lwt.t

The stream contains the PACK flow.

val from : state -> stream -> (Hash.t * int, error) Stdlib.result Lwt.t

from git stream populates the Git repository git from the PACK flow stream. If any error is encountered, any Git objects of the PACK flow are not added in the Git repository.

val make : state -> ?window:[ `Object of int | `Memory of int ] -> ?depth:int -> value list -> (stream * (Checkseum.Crc32.t * int64) Hash.Map.t Lwt_mvar.t, error) Stdlib.result Lwt.t

make ?window ?depth values makes a PACK stream from a list of Value.t.

?window specifies the weight of the window while the delta-ification. The client can limit the weight by the number of objects in the windoz (by default, is 10) or by the weight in byte of the window in your memory.

depth (default is 50) limits the depth of the delta-ification.

Then, the function returns a stream and a protected variable which contains a representation of the associated IDX file of the PACK stream. This protected variable is available (Lwt_mvar.take) only at the end of the PACK stream. That means, the client needs to consume all of the stream and only then he can take the Graph.t associated.

OCaml

Innovation. Community. Security.