#diff #patience #line #algorithm #tool #level #token

bin+lib pratdiff

A colorfull diff tool based on the patience diff algorithm

5 releases

new 0.1.4 Jun 20, 2024
0.1.3 Jun 10, 2024
0.1.2 Jun 10, 2024
0.1.1 Jun 10, 2024
0.1.0 Jun 9, 2024

#408 in Filesystem

Download history 287/week @ 2024-06-07 41/week @ 2024-06-14

328 downloads per month

Apache-2.0

29KB
934 lines

A diff tool that provides line and token level colorization.

Sample Code Diff

Based on the Patience Diff algorithm described by Bram Cohen and then expanded upon by James Coglan in two blogs posts (algorithm and implementation).

FAQ

How do I install pratdiff?

Use cargo install pratdiff. You probably want to get cargo from rustup or brew.

How do I enable autocompletions?

The --completions flag takes a shell and outputs a completion script.

eval "$(pratdiff --completions=bash)"
pratdiff --completions=fish | source

Why did you bother doing this?

Cause I wanted a learning project and this seemed like a reasonable one.

Why did you name it pratdiff?

I wanted to insert an "r" into patdiff, and I kind of like "prat" as an oddly out of date insult.

Did you learn anything interesting?

The way that token level diffing uses the same algorithm as the line level diffing is pretty cool in my mind. I didn't think going into it that I would structure it that way and it all kinda just fell out.

Also, I learned that the tiny extension on patience diff I made to use non-unique lines if unique ones fail is a known algorithm called "histogram diff".

Dependencies

~4–13MB
~140K SLoC