Git object storage and pack files for Eio
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

OCaml 96.9%
Perl 2.5%
Dune 0.2%
Other 0.4%
145 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#

Install with opam:

$ opam install nox-git

If opam cannot find the package, it may not yet be released in the public opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install nox-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"
  ~date:(Int64.of_float (Unix.gettimeofday ())) ()
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.