package git

  1. Overview
  2. Docs
Git format and protocol in pure OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

git-1.11.5.tbz
sha256=258c4607ea99f3550a6f872c21154f1318b8959641992e2f57e3af31c7b73609
md5=86090621429b346357604e157274387a

Description

Support for on-disk and in-memory Git stores. Can read and write all the Git objects: the usual blobs, trees, commits and tags but also the pack files, pack indexes and the index file (where the staging area lives).

All the objects share a consistent API, and convenience functions are provided to manipulate the different objects. For instance, it is possible to make a pack file position independent (as the Zlib compression might change the relative offsets between the packed objects), to generate pack indexes from pack files, or to expand the filesystem of a given commit.

Published: 14 Apr 2018

README

ocaml-git -- Git format and protocol in pure OCaml

Support for on-disk and in-memory Git stores. Can read and write all the Git objects: the usual blobs, trees, commits and tags but also the pack files, pack indexes and the index file (where the staging area lives).

All the objects share a consistent API, and convenience functions are provided to manipulate the different objects. For instance, it is possible to make a pack file position independent (as the Zlib compression might change the relative offsets between the packed objects), to generate pack indexes from pack files, or to expand the filesystem of a given commit.

The library comes with a command-line tool called ogit which shares a similar interface with git, but where all operations are mapped to the API exposed ocaml-git (and hence using only OCaml code).

The API documentation is available online.

Build and Install Instructions

To build and install the project, simply run:

$ opam install git

What is supported

  • The loose object files can be read and written;

  • The pack files (collections of compressed loose objects using a binary-diff representation) and pack indexes (indexes of pack files) can be read and written). The binary diff hunks are exposed using a high-level position-independent representation so that they can be manipulated more easily. Pack file can be created but will not be compressed yet.

  • The index file (used as for managing the staging area) are fully supported. Which means that git diff and git status will work as expected on a repository created by the library.

  • Cloning and fetching (using various options) are fully supported for the Git protocol, the smart-HTTP protocol and git+ssh. A subset of the protocol capabilities are implemented (mainly thin-pack, ofs-delta, side-band-64k and allow-reachable-sha1-in-want).

  • Pushing is still experimental and needs more testing.

  • An abstraction for Git Store Is available. Various store implementations are available:

What is not supported

  • No server-side operations are currently supported.

  • No GC.

  • Updates, merge and rebase are not supported. Use irmin instead.

Performance

Performance is comparable to the Git tool.

Example

# #require "git.unix";;
# open Lwt.Infix;;
# open Git_unix;;
# module Search = Git.Search.Make(FS);;

# let read file =
    FS.create ~root:"." () >>= fun t ->
    FS.read_reference_exn t Git.Reference.master >>= fun head ->
    Search.find t head (`Commit (`Path file)) >>= function
    | None     -> failwith "file not found"
    | Some sha -> FS.read_exn t sha >>= function
      | Git.Value.Blob b -> Lwt.return (Git.Blob.to_raw b)
      | _ -> failwith "not a valid path"
 ;;
 val read : string list -> string Lwt.t = <fun>

# Lwt_main.run (read ["README.md"] >|= print_string)

ocaml-git -- Git format and protocol in pure OCaml

Support for on-disk and in-memory Git stores. Can read and write all
the Git objects: the usual blobs, trees, commits and tags but also
the pack files, pack indexes and the index file (where the staging area
lives).

[...]

License

MIT, see LICENSE.md file for its text.

Dependencies (12)

  1. decompress >= "0.6" & <= "0.7"
  2. ocplib-endian
  3. astring
  4. hex
  5. fmt
  6. logs
  7. lwt >= "2.4.7"
  8. uri >= "1.3.12"
  9. ocamlgraph
  10. mstruct >= "1.3.1"
  11. jbuilder >= "1.0+beta7"
  12. ocaml >= "4.02.3"

Dev Dependencies (3)

  1. mtime with-test & >= "1.0.0"
  2. nocrypto with-test
  3. alcotest with-test

Used by (12)

  1. datakit
  2. dog
  3. git-http < "2.0.0"
  4. git-mirage < "2.0.0"
  5. imaplet-lwt >= "0.1.3"
  6. irmin >= "0.9.0" & != "0.10.1" & < "0.11.1"
  7. irmin-git >= "1.2.0" & < "2.0.0"
  8. irmin-indexeddb >= "2.0"
  9. irmin-unix < "0.9.9"
  10. jitsu
  11. merge-queues >= "0.2.0"
  12. plotkicadsch < "0.5.0"

Conflicts

None

OCaml

Innovation. Community. Security.