Git object storage and pack files for Eio
OCaml 95.0%
Perl 4.3%
Dune 0.2%
Other 0.5%
102 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-git https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-git
git@git.recoil.org:gazagnaire.org/ocaml-git git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-git

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

git#

Git object format implementation in pure OCaml.

Overview#

Type-safe encoding and decoding of Git objects: blobs, trees, commits, tags, and references. Minimal dependencies with streaming I/O via bytesrw.

Features#

  • All Git object types: blob, tree, commit, tag
  • Reference handling (branches, tags, HEAD)
  • Pack file support
  • SHA-1 hashing with digestif
  • Streaming I/O with bytesrw

Installation#

opam install git

Usage#

open Git

(* Create a blob *)
let blob = Blob.of_string "Hello, World!\n"
let blob_hash = Blob.digest blob

(* Create a tree entry *)
let entry = Tree.entry ~perm:`Normal ~name:"hello.txt" blob_hash
let tree = Tree.v [ entry ]
let tree_hash = Tree.digest tree

(* Create a commit *)
let author = User.v ~name:"Alice" ~email:"alice@example.com" ()
let commit = Commit.v
  ~tree:tree_hash
  ~author
  ~committer:author
  (Some "Initial commit")

Credits#

This is a simplified rewrite derived from:

  • ocaml-git - Git format and protocol in pure OCaml by Thomas Gazagnaire and Romain Calascibetta
  • carton - PACKv2 file implementation by Romain Calascibetta

Licence#

ISC License. See LICENSE.md for details.