Better Elixir diffs with difftastic

10 Feb 2025

Difftastic is a structural diffing tool that understands syntax, made by Wilfred Hughes.

Difftastic is a CLI diff tool that compares files based on their syntax, not line-by-line. Difftastic produces accurate diffs that are easier for humans to read.

Most of my day to day coding is done in Elixir and I’ve configured git diff to call difftastic. This means that I use difftastic to compare changes in Elixir code multiple times per day.

It works great for regular Elixir code and HEEx templates, but it did not work so great for ~H sigils. Being a software developer I decided to take a look and try to fix this.

Difftastic makes heavy use of tree-sitter, and both projects are written in Rust. I am not very familiar with Rust, but Difftastic codebase is extremely well organised so I was able to find my way around in reasonable time and open a pull request with the fix.

The following picture shows the the same ~H sigil diff before and after the changes:

Difftastic can now highlight changes inside Elixir ~H sigils properly

The pull request has now been merged so anyone using difftastic along with Elixir will soon benefit from this fix. Open source software is truly amazing.