Closed hardliner66 closed 4 years ago
what about doing this via .gitattributes
?
what do you mean?
we can use .gitattributes
to enforce a specific end-lines style, regardless of editor or platform
and this will not depend on a pre-commit hook fat someone may have forgotten to configure before sending us their patch
Ah, now I get what you mean.
The thing is, I already have autocrlf enabled which already takes care of line endings on windows.
Currently everytime I format my code with cargo-fmt, git tells me my files have changed because of the new-lines. If I commit those, after the next pull git automatically changes the line endings of changed or new files back because of autocrlf.
There is no need to enforce consistant line endings on each individuals machine as long as they are consistant inside the repo.
exactly, and that's what .gitattributes should take care of
I'm currently using auto-crlf in git. With newline_style "Unix" I always have "changed" files in git because the newlines don't match. Setting it to "Native" would solve that for me, but everyone who uses auto-crlf false will than have the same problem.
I think it would be better to leave the newlines as is while formatting because git already handles that conversion.