Review Board

beta

Normalize line endings when patching files

Updated 1 year, 6 months ago

Christian Hammond Reviewers
trunk reviewboard
78, 143
None Review Board SVN
This is a simpler fix than the CRLF patches sitting around. Instead of fixing line endings when we parse the files (and trying hard to preserve line endings), just normalize at patch time to \n. Since we're not actually doing anything with the resulting file aside from displaying it, this is a good enough fix and is safe.

We don't want to normalize when parsing the diff because that would modify the raw diff file. We should be leaving that alone.
Added test cases for each combination of source file and diff line endings that we need to test. Before this change, the unit tests were failing when trying to patch a non-CRLF file with a CRLF diff or vice-versa. Now all unit tests pass.
Ship it!
Posted 1 year, 6 months ago (July 3rd, 2007, 12:12 a.m.)

   

  
Loading diff fragment...
It might be nice to move these to a separate function (so they're listed separately if they fail), but no biggie.
  1. Christian Hammond 1 year, 6 months ago (July 3rd, 2007, 12:18 a.m.)
    Yeah, wondered about that. I'll do that and then commit.