Closed Taz03 closed 1 month ago
we still want all files LF so the config was fine, except we don't want to edit binary files because it'll make then corrupt. And also want .bat files to be CRLF.
And both of those changes are done in this pr
Yeah, auto normalization to LF is good @surajkumar, no worries. :relaxed: :heart:
But you have to configure it properly. You can't force everything to LF, some win files won't work properly, and also git is not smart enough for every type of binary, and might corrupt them with changing line endings, so you might need to be explicit what to do with each binary. Also, if there is no file extension, you want to be explicit as well.
* text=auto
text
This attribute marks the path as a text file, which enables end-of-line conversion: When a matching file is added to the index, the file’s line endings are normalized to LF in the index. Conversely, when the file is copied from the index to the working directory, its line endings may be converted from LF to CRLF depending on the eol attribute, the Git config, and the platform (see explanation of eol below).
Text does normalization to LF automatically.
Set to string value "auto"
When text is set to "auto", Git decides by itself whether the file is text or binary. If it is text and the file was not already in Git with CRLF endings, line endings are converted on checkin and checkout as described above. Otherwise, no conversion is done on checkin or checkout.
Auto automatically decides if text or binary, and performs normalization to LF automatically only on text files, unless it's already in git with CRLF ending. (And we obviously don't want LF normalization on binaries, because it makes no sense, and it might corrupt those files)
So basically, this line is everything you need. It also does normalization on index (staging area) and doesn't force it in your working directory like eol=lf. Which means people can work with whatever software they prefer, and endings they want, but when committing, it will be normalized. If some binaries are not recognized, or file has no extension, you can manually specify that it is binary with this pattern *.jpg binary
Example config, since it's smarter to be explicit, and sometimes it is needed:
# This will do normalization to LF on index (staging area)
* text=auto
*.java text
*.html text
*.css text
# Explicit for linux files
*.sh text eol=lf
# Explicit stuff for win files
*.bat text eol=crlf
# Just to make sure git doesn't corrupt our binaries accidentally, we mark those as binary,
and,
# it will not perform LF normalizaton. It's a good practice.
*.gif binary
*.jpg binary
*.jpeg binary
*.png binary
# No extensions, so we set them manually
/gradlew text eol=lf
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
No data about Duplication
Looks like this is biting us back, the reason we changed it LF was because on windows systems, when running spotless, it would change everything CLRF. The hard fix was forcing LF because nobody reads the docs lol
https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gitattributes.html
Here's some documentation on .gitattributes
Since this is causing issues with other files, consider stealing sections of this: