bugGNU patch - Bugs: bug #50962, ignore CRLF when canonicalize (-l)...

 
 

bug #50962: ignore CRLF when canonicalize (-l) is set to true

Submitter:  Laszlo Boszormenyi (GCS) <gcs>
Submitted:  Sun 07 May 2017 09:32:37 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 07 Jun 2018 10:53:44 AM UTC, comment #3: 

Patch 732366_ignore_CRLF.patch needs a test case.

Andreas Gruenbacher <agruen>
Group administrator
Thu 07 Jun 2018 10:33:16 AM UTC, comment #2: 

Now, the line endings check can be done together with striping whitespace.

But this will require a redesign. Currently, line endings are checked after the chunk match already failed. To get both checks, they'd have to be checked earlier.

(file #44319)

Anonymous
Thu 07 Jun 2018 04:27:32 AM UTC, comment #1: 

"you may end up with mixed line encodings" is a problem as this is never intended, and patch should not allow it to happen this easily .

We actually have two separate cases here:

  • Patchfile and target file have different line endings -- a user error, patch should bail out or convert them.
    • It's impossible to do conversion reliable in all casesI highly doubt that conversion is always possible and/or desired. patch shouldn't try to second-guess the user.
  • Differences between patchfile "-" line and the corresponding target line comprising only whitespace (e.g. extraneous line breaks) -- okay with --ignore-whitespace.


AFAICS, the UX problem that lead to this ticket is that the error message fails to convey that it means that "patchfile and target file have different line endings", which is a user's error that they should fix before trying again.

So, just fixing the error message to say: "hunk and target have different line endings" -- should be enough to clarify things for the users.

Ivan Pozdeev <native_api>
Sun 07 May 2017 09:32:37 AM UTC, original submission:  

Patch fails to apply a patch if the original file and the patch have different 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.

Original author: tony mancill

Laszlo Boszormenyi (GCS) <gcs>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #44319:  0001-Clarify-the-line-endings-error-message.patch added by None (865B - application/octet-stream)
file #40607:  732366_ignore_CRLF.patch added by gcs (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by agruen (Posted a comment)
  • -email is unavailable- added by native_api (Posted a comment)
  • -email is unavailable- added by gcs (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-06-07 None Attached File- Added 0001-Clarify-the-line-endings-error-message.patch, #44319
    2017-05-07 gcs Attached File- Added 732366_ignore_CRLF.patch, #40607

    Back to the top

    Powered by Savane 3.14-d582.
    Corresponding source code