Package: patch Version: 2.7.5-1+b2 Followup-For: Bug #732366 Hi,
I ran into this bug as well trying to apply patches against a newer upstream version that opted to switch some source files from LF to CFLF line endings. The current behavior of --ignore-whitespace in patch is to strip a trailing LF only. The attached patch for "patch" will also ignore the CRLF sequence. It hasn't been tested extensively, and as noted in the description of the patch, you may end up with mixed line encodings. However it seems preferable to having to hand-edit the patches to append line endings, or having to update the line-ending of the sources to match the patch. Cheers, tony
Description: ignore CRLF when canonicalize (-l) is set to true This is a workaround for "different line endings" errors that arise when applying patches generated on systems using a different line ending than the sources. Hopefully it will help folks avoid this error: . Hunk #<x> FAILED at <y> (different line endings). . Note that this code only addresses the comparison code and will almost certainly result in patched files with mixed line-endings. There other utilities - e.g. dos2unix that can address that (as would additional work on patch). Author: tony mancill <tmanc...@debian.org> Bug-Debian: https://bugs.debian.org/732366 Forwarded: no Last-Update: 2017-05-06 --- patch-2.7.5.orig/src/patch.c +++ patch-2.7.5/src/patch.c @@ -1732,6 +1732,9 @@ similar (char const *a, size_t alen, cha /* Ignore presence or absence of trailing newlines. */ alen -= alen && a[alen - 1] == '\n'; blen -= blen && b[blen - 1] == '\n'; + /* Also ignore CR in a CRLF sequence or as a bare trailing CR */ + alen -= alen && a[alen - 1] == '\r'; + blen -= blen && b[blen - 1] == '\r'; for (;;) {
signature.asc
Description: PGP signature