mantish/ company / blog
Join the waitlist

Why I built Mantish

GitHub, GitLab and Azure DevOps show which lines changed. I wanted to see what actually happened to the code. This is the story of Mantish and the diff algorithms behind it.

Piotr Janowski6 min read

GitHub, GitLab and Azure DevOps show which lines changed. For years, what I really wanted to know was what actually happened to the code: was a method moved, renamed or extracted into another class, or did only the formatting change? Mantish grew out of that need.

Where the idea came from

The first ideas for the app came in 2019. As I gained experience, I spent more and more time reviewing code and less and less time writing it. As a full-stack developer I reviewed C#, Angular and Vue code, as well as Azure Pipelines definitions. That was when I noticed that the tools I used - Azure DevOps, Bitbucket, VS Code and JetBrains Rider - did little to help with the review itself.

Diffs were often cluttered with formatting changes that made the real change hard to spot. When I wanted to look at a method someone had called, because I suspected they had used it wrong, I couldn't jump to it from the review - I had to open the project in JetBrains Rider. Rider had no review view, so I simply browsed the commit there and still wrote my comments in Azure DevOps. I still remember one habit of mine: in Azure DevOps I filtered the index.ts files and marked them all as Reviewed straight away. Reading barrel files wasn't worth my time.

One tool did it better. Devart's Code Compare showed moved blocks of code, which made reviews much easier. I wanted something like that, but in pull request reviews.

The first attempt

So I decided to write my own code review app. I was working in C#, so I could use Roslyn directly. I spent two months studying text-differencing algorithms: from the Hunt-McIlroy algorithm, through Myers' algorithm, to LCS. After six months I had a prototype, but I didn't have the spare time to finish it. The requirements and ideas stayed written down in Trello.

Coming back in 2025

In 2025 I came back to the idea, as I had more time after work for my own projects. I started where I had left off: with algorithms for comparing code. I built several prototypes and checked which one worked best.

It quickly turned out that no single algorithm works everywhere. Each prototype handled one kind of file well and another badly. In the end I decided to combine several of them, so that each does what it is best at.

How Mantish compares code

Histogram diff - comparing lines

The foundation is histogram diff, an extension of patience diff. It anchors the comparison on the lines that occur least often in the file. Thanks to that, braces, blank lines and repeated pieces of code don't get matched with each other, and the diff is much easier to read. On top of that, I compare lines ignoring indentation, so if someone pulled code out of a try block, you can still see it is the same code, not code deleted and added again.

Myers - repetitive content and changes within a line

Histogram diff struggles, however, with stretches where almost everything repeats, such as JSON, YAML or generated code. That is where Myers' algorithm comes in - the same one Git uses by default. At first I used the classic LCS computed with dynamic programming, but its memory grows with the product of the two files' lengths, and on large files it could take more than a gigabyte. I had to replace it - LCS is now used only for very small fragments, up to four lines. I also use Myers to find differences within a line, at the level of words and single characters, to highlight exactly what changed.

Syntax trees - moves and renames

Comparing lines alone wasn't enough, because it says nothing about a method being moved or renamed - and that was one of my most important goals. So I also compare syntax trees, using an algorithm based on GumTree. I tried GumTree 2, 2.1 and 3. In the end I built an implementation based on GumTree 3.0, combined with ChangeDistiller and RM-ASTDiff. First I match identical pieces of code, then those with a similar structure but a different name, and finally the rest, based on how similar they are. For C#, the syntax tree comes from Roslyn; for the other languages I wrote my own parsers.

As a result, a review shows not only which lines changed, but what actually happened to the code: what was moved, what was renamed, and what is only a formatting change that can be skipped.

In short

AlgorithmWhat I use it for
GumTree 3.0 + ChangeDistiller + RM-ASTDiffcomparing syntax trees: moves, renames, structure
Histogram diffthe base line comparison, also inside methods and in files without a syntax tree
Myerslarge stretches of repetitive content (e.g. JSON, YAML, generated code) and changes within a line - words and characters
LCSvery small fragments, up to four lines
File before and after the change → Is there a parser for this language?; Is there a parser for this language? → GumTree 3.0 + ChangeDistiller + RM-ASTDiff (yes); Is there a parser for this language? → Histogram diff line comparison (no); GumTree 3.0 + ChangeDistiller + RM-ASTDiff → Diff in the review (moves, renames); GumTree 3.0 + ChangeDistiller + RM-ASTDiff → Histogram diff line comparison (method bodies); Histogram diff line comparison → LCS (small fragment); Histogram diff line comparison → Myers (repetitive content e.g. JSON, YAML); Histogram diff line comparison → Changed lines (the rest); LCS → Changed lines; Myers → Changed lines; Changed lines → Myers on words and characters precise highlighting; Myers on words and characters precise highlighting → Diff in the reviewyesnomoves,renamesmethod bodiessmall fragmentrepetitive contente.g. JSON, YAMLthe restFile before and after the changeIs there a parserfor this language?GumTree 3.0+ ChangeDistiller + RM-ASTDiffHistogram diffline comparisonDiff in the reviewLCSMyersChanged linesMyers on words and charactersprecise highlighting

How I checked that it works

I worked intensively, on the algorithm alone, for 4 months. Polishing it took another 4 and, honestly, is still going on. How did I know whether changes were recognised the way I wanted? I went through other people's public pull requests and looked at how GitHub, GitLab, Bitbucket and Azure DevOps presented them, what I didn't like about it, and how I would show it myself. I reviewed hundreds of pull requests by hand, improving the algorithm after each batch. After those first 4 months I was happy with the result and could move on to the next stage: reducing noise.

Example: code extracted into a new class

Below is the same file from a pull request in the playground repository, first on GitHub, then in Mantish. Part of the PlaceAsync method was extracted into a new OrderWorkflow class. GitHub shows this as a dozen or so deleted lines and two new ones, including the call workflow.PlaceAsync(...), so the reviewer has to work out on their own where that code went. Mantish recognises that the code was extracted into OrderWorkflow.cs and says so directly.

GitHub: the extracted part of PlaceAsync reads as a dozen deleted lines on the left and two new lines on the right
GitHub: the extracted part of PlaceAsync reads as a dozen deleted lines on the left and two new lines on the right
Mantish: the same block marked "Extracted to OrderWorkflow.cs · with changes", and the new line marked "Extracted call"
Mantish: the same block marked "Extracted to OrderWorkflow.cs · with changes", and the new line marked "Extracted call"

What's next

In the next post I'll describe how I approached noise reduction - how Mantish tells apart changes that really change something from formatting and other trivia. If you want to see how it works in practice, visit mantish.dev.

Further reading

Was this post helpful?