skeeto / w64devkit

Portable C and C++ Development Kit for x64 (and x86) Windows
The Unlicense
2.7k stars 185 forks source link

Use a `diff` version that can ignore CR/LF differences #45

Open xparq opened 1 year ago

xparq commented 1 year ago

As it turns out, no matter the -w and friends, diff just won't get over differences only between LF and CR+LF.

It can be a real interop. issue in a mixed env like this (at least it cost me quite some time today to finally realize what the trouble was), so maybe we could somehow use a different diff, with more muscle (like --strip-trailing-cr), or -- better yet -- we could get the nice BusyBox-w32 upstream guy to add this life-saver of a feature.

(Honestly, after some googling, I'm kinda puzzled that I seem to be the only one toppling over this. :) Maybe I'm doing something wrong.)

Peter0x44 commented 1 year ago

As a workaround, you can use dos2unix/unix2dos on the patch first, probably. Just mentioning it in case you weren't aware.

or -- better yet -- we could get the nice BusyBox-w32 upstream guy to add this life-saver of a feature.

Why not make an issue on that repo instead, then?

rmyorston commented 1 year ago

GNU diff on Windows uses text mode by default and has a --binary flag to revert to binary mode. The default is a bit like using --strip-trailing-cr, but with less tedious typing.

I've made diff in busybox-w32 do something similar.

New prerelease binaries are available with this feature (PRE-4856 or above). These aren't a drop-in replacement for busybox-w32 as supplied with w64devkit. (You almost certainly don't want to the use built-in make.)

xparq commented 1 year ago

@Peter0x44:

dos2unix was exactly what I was doing as a workaround.

Why not make an issue on that repo instead, then?

Maybe I was under time pressure. Maybe I mentioned it here as a reminder. (As, indeed, I myself forgot it quickly, amidst other things on fire around me.) Maybe I wanted to increase the chance of it getting there by leaving it up to anyone, not just me. Maybe I wasn't even sure it's the right thing, and wanted to have it linger first. Maybe I assumed that people on this project are much closer to BB Ron Yorston than me (and, lo and behold, he just replied above indeed! :) ) Etc. Or maybe I have some sort of a special inhibition that prevents me from submitting that particular issue there (where I actually did submit others in the past).

skeeto commented 1 year ago

Like Peter0x44 mentioned, when faced with this I use dos2unix (or ff=unix in Vim) to normalize diff inputs. You may run into trouble on the other end as well, where busybox-w32 "patch" converts CRLF inputs to LF. I've had similar trouble with "git am" which does not support sources checked in with CRLF line endings.

Thanks for the new feature, Ron! w64devkit will pick this up from the next busybox-w32 release.

xparq commented 1 year ago

@rmyorston, thanks, just tried, with -b (as I originally intended to) -- perfect!