bsdiff#
BSDIFF40 binary diff and patch in pure OCaml.
Overview#
BSDIFF40 is the patch format of Colin Percival's bsdiff and
bspatch tools: a header, then three bzip2 streams holding control
triples, byte-wise difference data and extra data. The matcher -- a
qsufsort suffix array over the source -- aligns regions that differ by
small per-byte deltas at stable offsets, which makes the format excel on
executables. Patches produced here apply with the reference bspatch,
and patches produced by the reference bsdiff apply here; the interop
suite replays a committed reference patch, and bench/check_tools.ml
checks both directions against the installed tools.
For text-like data where regions are either identical or replaced
wholesale, the vcdiff package usually produces smaller patches.
Installation#
$ opam install bsdiff
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 bsdiff
Usage#
# let source = "the quick brown fox jumps over the lazy dog" in
let target = "the quick brown cat jumps over the lazy dog!" in
let patch = Bsdiff.diff ~source ~target in
Bsdiff.apply_exn ~source patch = target;;
- : bool = true
License#
ISC -- the qsufsort construction and the matcher are ported from the BSD-licensed reference bsdiff.c, Copyright 2003-2005 Colin Percival. See LICENSE.md.