-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Remove trailing whitespaces from codebase #12980
base: main
Are you sure you want to change the base?
Conversation
I generally agree that trailing whitespace bad, it its good to remove it, so I am generally supportive of this. However I think we want to avoid modifying sources that were not authored as part of emscripten. So can you start be reverting any changes in Also please revert other things that are either tool outputs or copies of third party files: cmake/Modules/FindOpenAL.cmake There may be more but lets start with that.... that should make the change a little easier to review too. As an aside, my advice for those who dislike trailing whitespace (as I do) is not to configure your editor automatically remove all whitespace when you save. This can be quite annoying when you are editing files from an external project that you do not control. You don't want to unwittingly remove whitespace generating unexpected diffs. Instead I find it much more effective to map a key to remove trailing whitespace when you choose to. For example I map |
I have updated the command. The paths you requested are now excluded.
For reviewing it may be easier if you run the above command yourself. I don't mind if you don't merge this PR in its current form. |
ff38095
to
6c517ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking much smaller.. just a few more to revert.
I will wait for #12982 before updating this. |
faa7f12
to
ebc699c
Compare
I updated the command and ran it again. I have checked in the script in case you need to run it again later. You can ask the new contributors to run this script before making a PR. https://github.com/aminya/emscripten/blob/remove-trailing-whitespace/trailing_whitespace_remover.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more exclusions for you...
I'm not sure we need special scripts checked in to f
ebc699c
to
98fab11
Compare
I would definitely keep the script. In the future, new contributors should run it to make sure that no trailing whitespace creeps in. It is also needed for the other open PRs. They may contain some whitespace. |
cfc730c
to
2e9a520
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split out .gitattributes change and the addition of trailing_whitespace_remover.sh into separate PRs. I would rather discuses both of those separately, in isolation from the bulk of this change which is that actual whitespace removal.
I think we are almost there on the exclusions now!
cd072a1
to
81313c1
Compare
# line endings | ||
* text=auto eol=lf | ||
*.{cmd,[cC][mM][dD]} text eol=crlf | ||
*.{bat,[bB][aA][tT]} text eol=crlf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have any files with mixed case extensions like this. I think just adding cmd
and bat
to the list below should be fine.
* text=auto eol=lf | ||
*.{cmd,[cC][mM][dD]} text eol=crlf | ||
*.{bat,[bB][aA][tT]} text eol=crlf | ||
*.{vcxproj,vcxproj.filters} text eol=crlf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a newline at EOF.
@@ -0,0 +1,31 @@ | |||
git grep -I --name-only -z -e '' -- . \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put this in tools directory? And give it a #!
line.
@@ -11,3 +11,9 @@ system/ linguist-vendored | |||
|
|||
AUTHORS merge=union | |||
ChangeLog.md merge=union | |||
|
|||
# line endings | |||
* text=auto eol=lf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, this means that for almost all files, developers will see unix line endings, even on windows? Why is that desirable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any executable file that is supposed to run on Linux must be LF, and any executable that wants to run on Windows must be CRLF.
If someone clones this repository on Windows and then opens it in WSL, the line-endings will break because they become CRLF by default if no option is specified.
So, to fix these issues, one convention should be chosen. The easiest one is to specify CRLF for Windows executables and make everything else LF.
My addition is based on this:
https://rehansaeed.com/gitattributes-best-practices/
I can change the code to be less forceful for consistent line-ending. However, this only covers .sh
files. It is usually common to use hash bangs for executables and not the file extension, and so those files will become faulty if they are accessed from another operating system.
# Set default behaviour to automatically normalize line endings.
* text=auto
# Force batch scripts to always use CRLF line endings so that if a repo is accessed
# in Windows via a file share from Linux, the scripts will work.
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
# Force bash scripts to always use LF line endings so that if a repo is accessed
# in Unix via a file share from Windows, the scripts will work.
*.sh text eol=lf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is just to support WSL users who are using a kind of hybrid environment I'm not sure it worth it. I would have though that WSL users already have to savy enough to setup global settings.
In any case, can we split out this PR so we can discuss the .gitattributes
separately. It seems like its worth further discussion and I don't want to block to this PR.
Only affects new files
using trailing_whitespace_remover.sh
81313c1
to
7931b71
Compare
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
I noticed that this codebase is polluted with a lot of trailing whitespace which is very annoying for those who use modern editors that automatically remove the spaces, and so I decided to fix this issue.
This PR removes those by running the following bash command:
https://github.com/aminya/emscripten/blob/remove-trailing-whitespace/trailing_whitespace_remover.sh
I have checked in the script in case you need to run it again later. You can ask the new contributors to run this script before making a PR.