Super Charged Git Diffs with Difftastic
I actually enjoy using git
for my code reviews to read what has changed, rather than using the Github UI and it's all because of a fantastic tool called Difftastic. git
's default diff output is ugly to say the least. It's made to be human readable, but really it's meant for making patches for git to ingest with git apply
. If you haven't seen it before it looks something like this:
It shows you what file has changed, between what commits, it's file perms, the lines that changed, and then the changes themselves with lines that have changed. It's very much meant to be parsed by a computer and coincidentally be read by a human.
The problem with this is that git is not aware of the programming language being changed here. It just knows, via a line diffing algorithm, that a change happened on the line, not how in any meaningful way.
We as programmers could, with a bit of looking see that the input type for the query
parameter changed to impl Into<String>
. However, we work with structured text all day! The change has meaning, it is not the whole line that changed, it is the type alone that changed.
For years I would use diff-so-fancy or later Delta to make these diffs more readable, but even though they were better at highlighting the changes between lines, they mainly showed me the lines that changed like git
would by default with some extra highlighting on a spot to show the change in a line. Once I saw Difftastic it blew by mind. Let's take a look at the example above again with Difftastic:
It's the same exact diff, but so much easier to read and less cognitive overhead playing spot the difference. The text impl Into<>
was added on the line and nothing else was changed. This alone has made reading changes so much easier. The fact that it's language aware means that I can see the information I care about so much easier.
I can't recommend it enough for every day usage to find what changed in your piles of YAML you chuck into the cloud, your code, or just about any text file you'd want to commit. If you want more examples you should check out it's website, because this is only a taste of what it can do.