[Haskell-cafe] Cabal revision online form silently converts file to Windows line endings, breaking patches

Peter Simons simons at nospf.cryp.to
Tue May 14 11:05:00 UTC 2019


Hi guys,

 > The diff program has an option to --ignore-trailing-space
 > (-Z for short) that will totally ignore changes of `\n`
 > to `\n\r` and vice versa. And so you will see only
 > 'actual' changes.

more importantly, patch(1) has an option --ignore-whitespace
that helps applying patches to a revised Cabal file which
suddenly comes along with CRLF line endings. Using that flag
with diff(1) when creating the patch is a good idea, but it
won't make the patch resistant against failures when it's
applied to a modified Cabal file.

 > Another generally useful option is --ignore-space-change
 > (-b for short) that will ignore indentation changes.
 > Another option that you may use is --ignore-all-space.

This option is actually somewhat dangerous when applied in
cases where the underlying source relies on layout to convey
structure, because changes in indention will be lost with
that flag enabled.

Generally speaking, Hackage's policy of adding CRLFs to
edited files seems like a bad idea. The least intrusive
choice would be to follow whatever line-ending convention
the original Cabal file has and to adhere to that.

Anyway, I'll throw in a historical footnote for good
measure: [1]

Best regards,
Peter


[1] https://github.com/commercialhaskell/all-cabal-files/issues/11



More information about the Haskell-Cafe mailing list