Better diffs in gerrit code review

Code review is critical for quality code. There are many ways to do it and many tools to help with the process, such as gerrit, phabricator, reviewboard and github code review.

We use gerrit, which is nice. But there’s one annoying problem: when a change author rebases a change and pushes the rebased patch for review the patch set diff is nearly useless. That either makes the reviewer’s job much harder or leads to people avoiding rebases. Unfortunately the existing ticket about the issue is four years old.

I spent some time on fixing it: Our gerrit shows a hunk in the diff from A to B only if it isn’t in the diff between their parent commits, or if there is a conflict. This reliably hides unrelated changes, like those from rebases, while erring on the side of showing too much in case of conflicting edits or large hunks.

Unfortunately the patch isn’t ready for upstream: It doesn’t work with unified diff view or with gerrit’s new change screen (the new side-by-side view can’t have the left and right side be different without highlighting the change). Also it’s not configurable.

Feel free to contact me if you’re interested in the details or want to pick this up!