{"id":13692436,"url":"https://github.com/walles/riff","last_synced_at":"2025-05-15T08:00:24.709Z","repository":{"id":29353735,"uuid":"32888004","full_name":"walles/riff","owner":"walles","description":"A diff filter highlighting which line parts have changed","archived":false,"fork":false,"pushed_at":"2025-05-04T08:14:00.000Z","size":8105,"stargazers_count":422,"open_issues_count":5,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-11T17:04:56.054Z","etag":null,"topics":["console-color","console-tool","diff","git-diff","highlighting","refiner","riff"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/walles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-25T20:07:23.000Z","updated_at":"2025-05-11T12:27:47.000Z","dependencies_parsed_at":"2023-02-19T20:45:43.858Z","dependency_job_id":"8844eea5-0735-4f7d-a362-7415dc4833f9","html_url":"https://github.com/walles/riff","commit_stats":null,"previous_names":[],"tags_count":73,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walles%2Friff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walles%2Friff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walles%2Friff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walles%2Friff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walles","download_url":"https://codeload.github.com/walles/riff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301420,"owners_count":22047901,"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":["console-color","console-tool","diff","git-diff","highlighting","refiner","riff"],"created_at":"2024-08-02T17:00:57.968Z","updated_at":"2025-05-15T08:00:24.635Z","avatar_url":"https://github.com/walles.png","language":"Rust","readme":"# Riff, the Refining Diff\n\nRiff is a wrapper around `diff` that highlights which parts of lines have changed.\n\n![Screenshot of riff in action](screenshot.png 'git show')\n\nUnchanged parts of changed lines are shown in yellow.\n\n`riff` also [helpfully highlights conflicts and merge commits](#more-features).\n\nMuch like `git`, Riff sends its output to a pager, trying these in order:\n\n1. Whatever is specified in the `$PAGER` environment variable\n1. [moar](https://github.com/walles/moar) because it is nice\n1. `less` because it is ubiquitous\n\n# Usage\n\n```\ngit diff | riff\n```\n\nOr if you do...\n\n```\ngit config --global pager.diff riff\ngit config --global pager.show riff\ngit config --global pager.log riff\ngit config --global interactive.diffFilter \"riff --color=on\"\n```\n\n... then all future `git diff`, `git show` and `git log --patch` output will be\nrefined.\n\nOr you can use `riff` as an alias for `diff`:\n\n```\nriff file1.txt file2.txt\n```\n\n## Configuration\n\nYou can configure `riff` by setting the `RIFF` environment variable to one or\nmore (space separated) command line options.\n\nFor example, set `RIFF=--no-adds-only-special` to disable adds-only special\nhighlighting.\n\n# Installation\n\n## With [Homebrew](https://brew.sh)\n\n```\nbrew install riff\n```\n\n## With [Archlinux User Repository (AUR)](https://aur.archlinux.org/packages/riffdiff)\n\n```\nparu -S riffdiff\n```\n\n## From [the Rust Crate](https://crates.io/crates/riffdiff)\n\n```\ncargo install riffdiff\n```\n\n## Manual Install\n\n1. Go [here](https://github.com/walles/riff/releases/latest) and download the\n   correct binary for your platform\n\n   - If no binary exists for your platform, please [report\n     it](https://github.com/walles/riff/issues)\n\n1. `chmod a+x riff-*`\n1. `mv riff-* /usr/local/bin/riff`\n1. Optionally followed by this to have riff highlight `git` output by default:\n\n```\ngit config --global pager.diff riff\ngit config --global pager.show riff\ngit config --global pager.log riff\ngit config --global interactive.diffFilter \"riff --color=on\"\n```\n\n# See Also\n\n[This VSCode extension for improved Git commit message\nediting](https://marketplace.visualstudio.com/items?itemName=walles.git-commit-message-plus)\nis nice. Yes, I wrote it and I'm tooting my own horn here.\n\nGood choice if you (like me!) are [using VSCode for Git commit message\nediting](https://jonasbn.github.io/til/vscode/integrate_with_cli.html).\n\n# More Features\n\n`riff` can highlight conflict markers created by `git`:\n\n![Screenshot of riff highlighting conflict markers](screenshot-diff2-conflict.png 'riff \u003c file-with-conflict-markers.txt')\n\n`riff` highlighting a `git` merge commits highlighting\n\n![Screenshot of riff highlighting merge commits](screenshot-git-merge.png)\n\n# Development\n\nIf you put example input and output in the `testdata` directory, then `cargo test` will verify that they match.\n\nOn mismatches, you can run `testdata-examples.sh` to compare current output to\nthe expected output for all examples, and optionally update expectations.\n\nInvoke `ci.sh` to run the same thing as CI.\n\nInvoke `benchmark.py` to get numbers for how fast your current source code is\nversus earlier releases.\n\nInvoke `git log -p | cargo run --` to demo highlighting.\n\n## Making a new release\n\nJust invoke `./release.sh` and follow instructions.\n\nIf you want to test the release script without actually releasing anything, do:\n\n```\n./release.sh --dry\n```\n\n# TODO\n\n## Misc\n\n- `--help`: Only print installing-into-`$PATH` help if we aren't already being\n  executed from inside of the `$PATH`\n- Add test for never changing the number of lines in the input, that\n  messes up `git add -p` behavior.\n- Make sure we highlight the output of `git show --stat` properly\n- Given three files on the command line, we should pass them and any\n  options on to `diff3` and highlight the result\n\n# TODO future\n\n- Detect moved blocks and use a number as a prefix for both the add\n  and the remove part of the move. Highlight any changes just like\n  for other changes.\n\n# DONE\n\n- Make a main program that can read input from stdin and print it to\n  stdout.\n- Make the main program identify different kinds of lines by prefix\n  and color them accordingly. Use the same color scheme as `git`.\n- Make the main program identify blocks of lines that have been\n  replaced by another block of lines.\n- Make the Refiner not highlight anything if either old or new is\n  empty\n- Use \u003chttps://crates.io/crates/diffus\u003e to refine hunks\n- Build refined hunks and print them\n- Highlight `^diff`, `^index`, `^+++` and `^---` lines in bold white\n- Prefix all added / removed lines with the correct ANSI color code\n- Don't highlight the initial `+` / `-` on added / removed lines\n- Make sure we get the linefeeds right in diffs, try\n  `git show 28e074bd0fc246d1caa3738432806a94f6773185` with and without `riff`.\n- Visualize added line endings\n- Visualize removed line endings\n- Visualize removed linefeed at end of file properly\n- Visualize adding a missing linefeed at end of file properly\n- Visualize missing linefeed at end of file as part of the context\n  properly\n- Refine `ax`-\u003e`bx\\nc` properly\n- Strip all color from the input before handling it to enable users to\n  set Git's pager.diff and pager.show variables to 'riff' without also\n  needing to set color.diff=false.\n- If stdout is a terminal, pipe the output to a pager using the\n  algorithm described under `core.pager` in `git help config`.\n- You can do `git diff | riff` and get reasonable output.\n- Do not highlight anything if there are \"too many\" differences between the\n  sections. The point here is that we want to highlight changes, but if it's a\n  _replacement_ rather than a change then we don't want to highlight it.\n- Refine by word rather than by character\n  - Test case `git show 2ac5b06`: Should highlight all of both `some` and\n    `one or`.\n- Do some effort to prevent fork loops if people set `$PAGER` to `riff`\n- Add support for `--help`\n- Add support for `--version`\n- Print help and bail if stdin is a terminal\n- On exceptions, print the current version just like `--version`\n- On exceptions, print a link to the issue tracker\n- Add test case verifying that the `Inspired by` part of\n  `git show 77c8f77 -- bin/riff` is highlighted as an upside down L.\n- Find out how the LCS algorithm scales and improve the heuristic for\n  when not to call it.\n- Tune the upper bound on how large regions we should attempt to refine\n- Make a CI script\n- Set up CI calling the CI script\n- Document `ci.sh`'s existence\n- Figure out cross compiling to Linux and macOS ARM (look into `cross` which\n  uses Docker for cross compiling)\n- Make a release script\n- Document `release.sh`'s existence\n- Verify that the Linux binary works\n- Document install instructions\n- Make a public release\n- Remedy `release.sh` FIXMEs\n- Add a trailing whitespace analysis pass to the Refiner\n- Let the Refiner highlight whitespace errors among the added lines in\n  reverse red.\n- Highlight whitespace in added parts only\n- Add highlighting of non-leading tabs to the whitespace analysis\n- Profile and see if we can go faster\n- In `ci.sh`, add a test case verifying that our exception handler prints\n  backtraces in release builds (should fail when stripping the release binary)\n- In `ci.sh`, add a test case verifying that our exception handler prints line\n  numbers for the `riff` frames in the backtraces, in release builds. This\n  should fail when stripping the release binary.\n- Require line numbers in backtraces in release builds\n- Make the Linux binary smaller\n- Put argv contents in crash report\n- Handle plain non-git diff files\n- Given two files on the command line, we should pass them on to `diff` and\n  highlight the result.\n- Support `riff -b path1 path2` to diff files ignoring whitespace\n- Bound how-much-to-highlight restriction by number of characters highlighted\n  rather than by number of tokens highlighted\n- Get ourselves some kind of benchmark suite / example(s)\n- Do `git show 5e0a1b2b13528f40299e78e3bfa590d9f96637af` and scroll to the end.\n  How should we visualize the reformatting of the No-newline-at-eof code?\n- Do `git show 0f5dd84` and think about how to visualize one line\n  changing to itself with a comma at the end plus a bunch of entirely\n  new lines. Think of a constant array getting one or more extra\n  members.\n- Do `git show -b 77c8f77` and think about what rule we should use to\n  highlight the leading spaces of the `+ refined` and `+ page` lines\n  at the end of the file.\n- Do `git show 57f27da` and think about what rule we should use to get\n  the REVERSE vs reversed() lines highlighted.\n- Think about how to visualize an added line break together with some\n  indentation on the following line.\n- Make sure we can handle a `git` conflict\n  resolution diff. File format is described at\n  http://git-scm.com/docs/git-diff#_combined_diff_format.\n- Render ESC characters in the diff as Unicode ␛\n","funding_links":[],"categories":["Rust","Dev-Utilities","Source Code"],"sub_categories":["Diff Enhancers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalles%2Friff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalles%2Friff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalles%2Friff/lists"}