{"id":13726150,"url":"https://github.com/mirage/duff","last_synced_at":"2025-04-29T01:31:13.163Z","repository":{"id":42436139,"uuid":"128388734","full_name":"mirage/duff","owner":"mirage","description":"Pure OCaml implementation of libXdiff (Rabin's fingerprint)","archived":false,"fork":false,"pushed_at":"2024-11-26T16:05:59.000Z","size":466,"stargazers_count":20,"open_issues_count":0,"forks_count":3,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-04-20T21:41:51.234Z","etag":null,"topics":["diff","fingerprint","git","patch","rabin"],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mirage.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-06T11:55:25.000Z","updated_at":"2024-11-26T16:06:01.000Z","dependencies_parsed_at":"2024-01-03T01:31:06.940Z","dependency_job_id":"3e04232e-dfae-4b63-80bd-3772a375f908","html_url":"https://github.com/mirage/duff","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Fduff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Fduff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Fduff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Fduff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mirage","download_url":"https://codeload.github.com/mirage/duff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251415729,"owners_count":21585882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diff","fingerprint","git","patch","rabin"],"created_at":"2024-08-03T01:02:54.088Z","updated_at":"2025-04-29T01:31:12.665Z","avatar_url":"https://github.com/mirage.png","language":"OCaml","funding_links":[],"categories":["Algorithms and Data Structures","OCaml"],"sub_categories":[],"readme":"Duff – libXdiff implementation in OCaml\n=======================================\n\nDuff is a little library to implement [libXdiff][libXdiff] in OCaml. This\nlibrary is a part of the [ocaml-git][ocaml-git] project. This code is a\ntranslation of `diff-delta.c` available on the git project in OCaml. So, it\nrespects some git's constraints unlike libXdiff.\n\n## Examples\n\nThis library let the user to calculate an `index` from a source (a hash-table)\nwhich can be computed with a blob. Then, from `index` (which represents your\nsource) and a blob, we generate a list of `Copy` and `Insert` elements.\n\n- `Copy (off, len)` means to take a slice of `len` bytes from your source at\n  `off` (absolute offset) and copy it.\n- `Insert (off, len)` means to store a slice of `len` bytes from your __blob__\n  at `off` (absolute offset) and copy it.\n  \nFrom this information, we can have a tiny representation of your blob which can\nbe reconstruct with your source. The goal is to store `Copy` *opcode* with `off`\nand `len`, and `Insert` *opcode* which contains a slice of your blob.\n\nFinally, to produce a PACK file in git or ocaml-git, we use this algorithm and\nthis representation to optimize storage of your blobs (cf. `git gc`).\n\n### Binary\n\nYou can see an example of `duff` in `bin` directory. It's an executable to\nrepresent a _thin_ representation of your file. Then, you can reconstruct it\nwith `patch` sub-command.\n\nThis is an example to use `duff`:\n\n```sh\n$ ./duff.exe diff source target \u003e target.xduff\n$ ./duff.exe patch source \u003c target.xduff \u003e target.new\n$ diff target target.new\n$ echo $?\n0\n```\n\nThe internal format used is close to what `git` does internally (without `zlib`\nlayer). However, it does not correspond to an _official_ format. The binary is\nnot optimized to be used in a production environment but feedback and\nimprovement on it are welcome.\n\n## Limitations\n\nBecause this project is used by [ocaml-git][ocaml-git], we have some\nlimitations:\n\n- We compute at most `0xFFFFFFFE` bytes from source\n- An `insert` block can not be bigger than `0x10000` bytes\n\nFor example, libXdiff computes a bigger source than this implementation. Then,\nlimitation about `insert` block depends on the PACK (git) file format. So, don't\nask me to compute bigger source or merge and produce bigger `insert` block -\nthese constraints is outside the scope of this library.\n\nFrom this limitation, `Copy` *opcode* have an offset between 0x0 and 0xFFFFFFE\nand `off + len` is lower than 0xFFFFFFFE.\n\n## Fuzzer\n\nWe provide a fuzzer to randomly test this library. Currently (4/9/2018),\n`afl-fuzz` did not find any bugs and it computed 67.7k cycles (117 paths).\n\n[libXdiff]: http://www.xmailserver.org/xdiff-lib.html\n[ocaml-git]: https://github.com/mirage/ocaml-git\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirage%2Fduff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirage%2Fduff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirage%2Fduff/lists"}