All Projects → mirage → duff

mirage / duff

Licence: MIT license
Pure OCaml implementation of libXdiff (Rabin's fingerprint)

Programming Languages

ocaml
1615 projects

Projects that are alternatives of or similar to duff

intellij-diff-plugin
Syntax highlighting for .diff files and .patch files in IntelliJ IDEs
Stars: ✭ 17 (-15%)
Mutual labels:  diff, patch
Hdiffpatch
a C\C++ library and command-line tools for Diff & Patch between binary files or directories(folder); cross-platform; run fast; create small delta/differential; support large files and limit memory requires when diff & patch.
Stars: ✭ 459 (+2195%)
Mutual labels:  diff, patch
Gojsondiff
Go JSON Diff
Stars: ✭ 371 (+1755%)
Mutual labels:  diff, patch
Editscript
A library designed to diff and patch Clojure data structures
Stars: ✭ 281 (+1305%)
Mutual labels:  diff, patch
Apkdiffpatch
a C++ library and command-line tools for Zip(Jar,Apk) file Diff & Patch; create minimal delta/differential; support Jar sign(apk v1 sign) & apk v2,v3 sign .
Stars: ✭ 121 (+505%)
Mutual labels:  diff, patch
Gsync
gSync is an rsync based library for sending delta updates of files to a remote server.
Stars: ✭ 344 (+1620%)
Mutual labels:  diff, patch
Diff Match Patch
Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.
Stars: ✭ 4,910 (+24450%)
Mutual labels:  diff, patch
deltaq
Fast and portable delta encoding for .NET in 100% safe, managed code.
Stars: ✭ 26 (+30%)
Mutual labels:  diff, patch
Python Patch
Library to parse and apply unified diffs
Stars: ✭ 65 (+225%)
Mutual labels:  diff, patch
Git Follow
Follow lifetime changes of a pathspec in Git.
Stars: ✭ 25 (+25%)
Mutual labels:  diff, patch
Diffson
A scala diff/patch library for Json
Stars: ✭ 258 (+1190%)
Mutual labels:  diff, patch
dipa
dipa makes it easy to efficiently delta encode large Rust data structures.
Stars: ✭ 243 (+1115%)
Mutual labels:  diff, patch
tmux-eaw-fix
tmux 2.6 以降において East Asian Ambiguous Character を全角文字の幅で表示する
Stars: ✭ 16 (-20%)
Mutual labels:  diff, patch
Jsondiffpatch
Diff & patch JavaScript objects
Stars: ✭ 3,951 (+19655%)
Mutual labels:  diff, patch
go-gitdiff
Go library for parsing and applying patches created by Git
Stars: ✭ 41 (+105%)
Mutual labels:  diff, patch
Similar
A high level diffing library for rust based on diffs
Stars: ✭ 386 (+1830%)
Mutual labels:  diff, patch
Patch Package
Fix broken node modules instantly 🏃🏽‍♀️💨
Stars: ✭ 6,062 (+30210%)
Mutual labels:  diff, patch
Ex audit
Ecto auditing library that transparently tracks changes and can revert them.
Stars: ✭ 214 (+970%)
Mutual labels:  diff, patch
diffy
Tools for finding and manipulating differences between files
Stars: ✭ 47 (+135%)
Mutual labels:  diff, patch
diffviewer
HTML widget to visually compare files
Stars: ✭ 52 (+160%)
Mutual labels:  diff

Duff – libXdiff implementation in OCaml

Duff is a little library to implement libXdiff in OCaml. This library is a part of the ocaml-git project. This code is a translation of diff-delta.c available on the git project in OCaml. So, it respects some git's constraints unlike libXdiff.

Examples

This library let the user to calculate an index from a source (a hash-table) which can be computed with a blob. Then, from index (which represents your source) and a blob, we generate a list of Copy and Insert elements.

  • Copy (off, len) means to take a slice of len bytes from your source at off (absolute offset) and copy it.
  • Insert (off, len) means to store a slice of len bytes from your blob at off (absolute offset) and copy it.

From this information, we can have a tiny representation of your blob which can be reconstruct with your source. The goal is to store Copy opcode with off and len, and Insert opcode which contains a slice of your blob.

Finally, to produce a PACK file in git or ocaml-git, we use this algorithm and this representation to optimize storage of your blobs (cf. git gc).

Binary

You can see an example of duff in bin directory. It's an executable to represent a thin representation of your file. Then, you can reconstruct it with patch sub-command.

This is an example to use duff:

$ ./duff.exe diff source target > target.xduff
$ ./duff.exe patch source < target.xduff > target.new
$ diff target target.new
$ echo $?
0

The internal format used is close to what git does internally (without zlib layer). However, it does not correspond to an official format. The binary is not optimized to be used in a production environment but feedback and improvement on it are welcome.

Limitations

Because this project is used by ocaml-git, we have some limitations:

  • We compute at most 0xFFFFFFFE bytes from source
  • An insert block can not be bigger than 0x10000 bytes

For example, libXdiff computes a bigger source than this implementation. Then, limitation about insert block depends on the PACK (git) file format. So, don't ask me to compute bigger source or merge and produce bigger insert block - these constraints is outside the scope of this library.

From this limitation, Copy opcode have an offset between 0x0 and 0xFFFFFFE and off + len is lower than 0xFFFFFFFE.

Fuzzer

We provide a fuzzer to randomly test this library. Currently (4/9/2018), afl-fuzz did not find any bugs and it computed 67.7k cycles (117 paths).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].