package git

  1. Overview
  2. Docs

Implementation of the V2 Git Index format (as V1 is deprecated).

The index file contains information used by Git to manage the state of working directory contents.

type time = {
  1. lsb32 : Stdlib.Int32.t;
    (*

    binary integer containg the lower 32 bits of the entry (file or symbolic link) timestamp.

    *)
  2. nsec : Stdlib.Int32.t;
    (*

    binary integer containg the lower 32 bits of the entry (file or symbolic link) more precise timestamp, if available.

    *)
}

The type for time values.

type mode = [
  1. | `Normal
  2. | `Exec
]

The type for files' permission in the index file.

val pp_mode : Stdlib.Format.formatter -> mode -> unit

Pretty print file modes.

type stat_info = {
  1. ctime : time;
  2. mtime : time;
  3. dev : Stdlib.Int32.t;
  4. inode : Stdlib.Int32.t;
  5. mode : mode;
    (*

    binary integer containg the lower 32 bits of the entry (file or symbolic link) file system entity type and permissions.

    *)
  6. uid : Stdlib.Int32.t;
  7. gid : Stdlib.Int32.t;
  8. size : Stdlib.Int32.t;
    (*

    binary integer containg the lower 32 bits of the entry (file or symbolic link) size.

    *)
}

These fields are used as a part of a heuristic to determine if the file system entity associated with this entry has changed. The names are very *nix centric but the exact contents of each field have no meaning to Git, besides exact match, except for the mode and size fields.

val pp_stats : Stdlib.Format.formatter -> stat_info -> unit

Pretty-print file stats.

type entry = {
  1. stats : stat_info;
  2. id : Hash.Blob.t;
  3. stage : int;
  4. name : string;
}
val pp_entry : Stdlib.Format.formatter -> entry -> unit

Human-readable representation of an index entry.

type extension_kind = [
  1. | `Tree
  2. | `Reuc
  3. | `Other of string
]

The type for extension kinds.

  • Tree is for cached tree
  • Reuc is for reuse undo
  • Link is for split index
  • Other is for other extension kinds
type extension = {
  1. kind : extension_kind;
  2. payload : string;
}

The type for extension payload.

val pp_extension : Stdlib.Format.formatter -> extension -> unit

Human-readable representation of the extension.

type t = private {
  1. entries : entry list;
  2. extensions : extension list;
}

Index entries are sorted by the byte sequence that comprises the entry name; with a secondary comparison of the stage bits if the entry name byte sequences are identical

val create : ?extensions:extension list -> entry list -> t

Create an index.

val empty : t

The empty index file.

include S with type t := t
val equal : t -> t -> bool

Are two objects equal?

val hash : t -> int

Hash an object.

val compare : t -> t -> int

Compare two objects.

val pp : t Fmt.t

pp is the pretty-printer for values of type t.

module type IO = IO with type t = t
module IO (D : Hash.DIGEST) : IO
OCaml

Innovation. Community. Security.