Pure OCaml Git format and protocol
OCaml Makefile
Latest commit b21bf26 May 9, 2016 @samoht samoht Merge pull request #152 from hannesm/minor
revert unintentional search-replace of SHA->Hash
Failed to load latest commit information.
bin
doc
lib
lib_test
scripts Add a github proxy script. Mar 11, 2015
.gitignore Generate Git.Version and use it in ogit Oct 31, 2014
.merlin
.travis.yml Update .travis to bump version Mar 15, 2016
CHANGES.md
LICENSE
Makefile
README.md
TODO
_oasis
_tags
appveyor.yml
configure Update the build system to switch from obuild to oasis Jan 3, 2014
git-unix.opam
git.install Clean up the opam file, run the tests in test mode, add a git.install… Jun 12, 2015
mirage-git.opam
myocamlbuild.ml Update autogen files May 3, 2016
opam
setup.ml

README.md

ocaml-git

Pure OCaml Git format and protocol -- Guaranteed no C inside.

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 Status

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 stagging 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 need 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(FS);;

# let read file =
    FS.create () >>= fun t ->
    FS.read_reference_exn t Git.Reference.master >>= fun head ->
    Search.find t (Git.SHA.of_commit 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)

Pure OCaml Git format and protocol -- Guaranteed no C inside.

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 file for its text.