Git is one of the most popular tools for developers and – while this is usually little known – part of the power of Git comes from functional concepts. ocaml-git is a re-implementation of the Git protocol(s) in pure OCaml: it can synchronize (push and pull) with remote Git servers and it can inspect, create and modify local Git repositories (all Git object kinds are supported, including compressed PACK files). Using Git as a library with ocaml-git unlocked a new ecosystem of Git-based applications, including Irmin, a Git-like database or datakit, a Git-like orchestration tool (both used in production at Docker Inc).. Blockchain ledger such as Tezos, tamper-evident logging system, or conflict-free replicated datatypes have also been built using ocaml-git and Irmin.
In this tutorial, we will learn more about Git using OCaml. The first part of the talk will be dedicated to understanding the on-disk Git format and to explaining the functional concepts that Git uses to be really efficient: immutability, radix/patricia tree, etc. In the second part of this talk, we will implement a simple application to display the history of local Git repositories on a webpage, using ocaml-git and js_of_ocaml.