Skip to content

raygard/hdiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

hdiff

hdiff is a version of diff that implements the histogram algorithm as in jgit. It duplicates the output of jgit's histogram diff, and usually duplicates (or nearly duplicates) output of git --histogram.

It operates in a manner similar to POSIX diff, but only supports the default diff output and "unified" output formats, and can only compare files (not files to directories or directories to directories), though it does accept - for either filename to signify stdin.

hdiff does not support other diff options such as -b (relaxing whitespace comparison) or -r (recursive directory compare), etc.

If enough interest is indicated in the Issues tab, I may consider trying to implement more features.

The code is standard C99, but also needs POSIX extensions to get file modification time in nanoseconds.

There is a fairly complete explanation of the algorithm at the end of the file.

I have also written a couple of posts on this on my blog.

Building

gcc -O2 -std=c99 -Wall -Wextra -W -Wpointer-arith -Wstrict-prototypes -pedantic -D_POSIX_C_SOURCE=200809L hdiff.c -s -o hdiff

Using -O3 works but produces a bogus "warning: ‘kblo’ may be used uninitialized [-Wmaybe-uninitialized]".

License

Note that the 0BSD license does not require you to keep the license with the code. Please feel free to copy and re-use the code if you wish. An attribution to me is nice but not legally required.

About

A "histogram diff" implementation in C99

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages