Skip to content
Prev 387100 / 398502 Next

md5sum issues

This CR vs LF vs CRLF newline discrepancy has been around since the 70s and the CP/M operating system. And it remains an issue in over-the-wire internet text protocols today, which actually use the CRLF version like Windows. Sorry, UNIX... world domination of LF encoding failed.

The problem with pretending there is no issue as Duncan is advocating is that text is treated differently than binary, and every time you pretend it isn't it comes back to bite you. Applying binary algorithms like MD5 to text is one of these areas where your expectation that this will be successful is what creates the problem in the first place. A similar issue occurs in file encoding.. two files may both contain the word "Hello" but if they are encoded in UCS16 and UTF8 respectively then the MD5 results will be different.

Git does not (currently) support differences in encoding, but it does support text vs non-text (newline) differences because they are unavoidable. Pushing forward with your expectation that text files should compare the same in binary by assuming text will always be like UNIX text just defers the problem for another day.

Since I don't know what problem you are actually trying to solve, I cannot offer a concrete solution. But I would begin by not assuming that MD5 works the same on text and binary files... because it doesn't.
On February 3, 2021 2:48:56 AM PST, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: