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.