Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix snapshots and tests line-ending in Windows #2166

Merged
merged 1 commit into from
Nov 3, 2019

Conversation

edwin0cheng
Copy link
Member

@edwin0cheng edwin0cheng commented Nov 3, 2019

When running cargo test in Windows, there are some test and snapshots generated which are LF line-endings.

This PR try to force git to use LF for these files.

@edwin0cheng edwin0cheng changed the title Fix snapshots line-ending in Windows Fix snapshots and tests line-ending in Windows Nov 3, 2019
@matklad
Copy link
Member

matklad commented Nov 3, 2019

bors r+

bors bot added a commit that referenced this pull request Nov 3, 2019
2166: Fix snapshots and tests line-ending in Windows r=matklad a=edwin0cheng

When running `cargo test` in Windows, there are some test and snapshots generated which are `LF` line-endings. 

This PR try to force `git` to use `LF` for these files.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
@bors
Copy link
Contributor

bors bot commented Nov 3, 2019

Build succeeded

@bors bors bot merged commit c26fb1a into rust-lang:master Nov 3, 2019
@edwin0cheng edwin0cheng deleted the fix-snapshot-line-ending branch November 4, 2019 17:37
Comment on lines -1 to +2
crates/ra_syntax/tests/data/** -text
crates/ra_syntax/test_data/** -text eof=LF
crates/ra_ide_api/src/snapshots/** -text eof=LF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no way this could have worked, if you read the documentation:

  • eof doesn't exist, eol does
  • eol only works on text files
    • this makes sense, since it's lossy in general, and only text files can accept the lossiness as "CRLF and LF are two ways to represent the same thing" (line endings

If the goal here was to hide files from git grep, I'm afraid there is no way to do that without leaving the door open to CRLF (\r\n) corruption.

Honestly looking at #1115 I have no idea what's going on. Most likely some buggy tool produced \r\n instead of \n for line endings, which didn't match the correct (\n) ones git was dutifully using.

If it's the other way around, then the autocrlf setting is being set to the cursed option that generates \r\n on the fly from files committed as \n (which is not something you should never need or use - only outdated stuff like notepad.exe needs it).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only outdated stuff like notepad.exe needs it

Even Notepad supports Unix line endings now: https://www.theregister.com/2018/05/08/windows_notepad_unix_linux_macos/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants