Skip to content

Use LF line endings for LKGs#7536

Closed
billti wants to merge 1 commit into
masterfrom
buildNewlines
Closed

Use LF line endings for LKGs#7536
billti wants to merge 1 commit into
masterfrom
buildNewlines

Conversation

@billti
Copy link
Copy Markdown
Member

@billti billti commented Mar 16, 2016

Building with LF line endings makes the ./lib folder (which we publish to NPM) a little over 200KB smaller than building with CRLF.

As a useful aside, it also means if one person builds the LKG on a Windows machine, and the next person on a Mac/Unix machine, that the diff isn't the entire file contents (unless you suppress whitespace changes while diff'ing).

@weswigham
Copy link
Copy Markdown
Member

You could consider adding ./lib/**/* text eol=lf to the .gitattributes file to enforce this line ending scheme on clone.

@RyanCavanaugh
Copy link
Copy Markdown
Member

👍

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Mar 16, 2016

Why not use LF all the time?

@DanielRosenwasser
Copy link
Copy Markdown
Member

IIRC, our .gitattributes say check in/out as-is, so committing it as line feeds will keep it that way.

@DanielRosenwasser
Copy link
Copy Markdown
Member

Also, mentioning that this fixes #6630.

Assuming only LKG triggers turning off debug mode, this looks fine. :shipit:

@billti
Copy link
Copy Markdown
Member Author

billti commented Mar 16, 2016

Couple of good points here. There are generally 2 flows:

  • Someone builds locally and both publishes and checks in. In that case, how they check in/out the files doesn't matter (as they overwrote them when building locally), so we need to build with LF.
  • Someone pulls the repo to get the latest and then publishes. In that case, it doesn't matter how we build locally if they just checked out the files they are publishing.

This changes addresses the first, @weswigham makes a good point and that would address the second. I'll update the .gitattributes.

@mhegazy Are you stating we should just use LF all the time (as in, for all files we build)? My concern there was I've seen many folks open/edit in historical tools such as Notepad for quick changes locally, which often don't handle LF line endings well. If we think this is a non-issue, I'm happy to make all build have LF line endings.

As a broader topic - why do we remove all conversion on our source and check-in/out "as-is"? Why not just normalize all src files (i.e. are LF in the repo, but OS specific when checked out)? Thus .gitattributes would look something like:

* text=auto
lib/* eol=lf

@RyanCavanaugh
Copy link
Copy Markdown
Member

We have to keep things as-is so that our test cases don't get normalized -- this would cause the potential for bugs to slip through where tests passed on one OS but not the other (say, if we broke ASI only in the case where it was LF-only)

@billti
Copy link
Copy Markdown
Member Author

billti commented Mar 16, 2016

Ah, fair enough. Thanks @RyanCavanaugh (though we could still exclude just the tests dir only from normalization perhaps?)

FWIW: Making our ./lib directory be LF only by adding the line lib/* text eol=lf to .gitattributes makes that directory 430K smaller.

@RyanCavanaugh
Copy link
Copy Markdown
Member

If it's possible to make /tests/ be as-is and everything else be OS-specific, that'd be great. I don't think we knew about that option of .gitattributes when we set up the repo.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jun 15, 2016

already addressed by #9026

@mhegazy mhegazy closed this Jun 15, 2016
@billti billti deleted the buildNewlines branch February 1, 2017 22:55
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants