package git

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

Install

Dune Dependency

Authors

Maintainers

Sources

git-2.1.2.tbz
sha256=b2fc7aae9735526eb11ecf7c2bfc02393327268a4d3327d8be679622a0a6cc7b
sha512=bb3306f2728d3ac4975b4ba347b53aec26a831a96445ed4812685e9991c46ed45393c107f1b4cb42ca77fed1cbb2a06ffb41036fd7284d812270630c3ac3dc6f

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.

Published: 18 Nov 2019

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 some command-line tools called ogit-* as a Proof-of-concept of the core library 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). However, these tools are not done to be use. They are just examples of how to use ocaml-git.

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 and is compressed.

  • 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 Git_unix;;
# module Search = Git.Search.Make(FS);;

# let read filename =
    let open Lwt_result.Infix in
    Store.v (Fpath.v ".") >>= fun t ->
    Store.Ref.resolve Store.Reference.master >>= fun head ->
    let open Lwt.Infix in
    Search.find t head (`Commit (`Path filename)) >|= function
    | None -> Lwt.return (Error `Not_found)
    | Some hash -> Store.read t hash
val read : string list -> (Store.Value.t, Store.error) Lwt_result.t
    
# let pp =
    let ok ppf = function
      | Store.Value.Blob blob ->
        Fmt.string ppf (Store.Value.Blob.to_string blob)
      | _ -> Fmt.string ppf "#git-object" in
    Fmt.pp_result ~ok ~error:Store.pp_error
val pp : (Store.Value.t, Store.error) Fmt.t

# Lwt_main.run Lwt.Infix.(read [ "README.md" ] >|= pp Fmt.stdout)

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 (22)

  1. ocamlgraph
  2. cstruct
  3. astring
  4. fmt
  5. logs
  6. rresult
  7. ocplib-endian
  8. hex
  9. duff < "0.3"
  10. encore < "0.6"
  11. ke
  12. stdlib-shims
  13. checkseum >= "0.0.9" & < "0.5.0"
  14. decompress >= "0.9.0" & < "1.0.0"
  15. lru >= "0.3.0"
  16. digestif >= "0.7.2" & < "1.0.0"
  17. fpath >= "0.7.0"
  18. angstrom >= "0.9.0" & < "0.14.0"
  19. lwt >= "2.4.7"
  20. uri >= "1.9.0"
  21. dune >= "1.1"
  22. ocaml >= "4.03.0"

Dev Dependencies (4)

  1. mtime with-test & >= "1.0.0" & < "2.0.0"
  2. tls with-test & < "1.0.0"
  3. nocrypto with-test & >= "0.5.4"
  4. alcotest with-test & >= "0.8.1"

Used by (11)

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

Conflicts

None

OCaml

Innovation. Community. Security.