Consider JavaScript files as binary in .gitattributes
See original GitHub issueIs your feature request related to a problem? Please describe.
Very often in this repository, the jQuery JavaScript library is referenced in HTML files with SRI (Subresource Integrity), meaning that a hash of the file is provided as an attribute. Therefore it is crucial that JavaScript files are not modified when pushed to the repository. Git settings like core.autocrlf
(defaults to true
under Git tools for Windows) can therefore cause issues that are not immediately noted. The more SRI we use, the more often this problem might occur.
Describe the solution you’d like
If *.js
files would be considered as binary in ´.gitattributes´, they should not be altered when being pushed to the repository.
Additional context
Suggested fix: add *.js binary
in .gitattributes
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Why does Git treat this text file as a binary file?
sql file), but git treats it as a binary file, even if it has only ASCII/UTF8 data on it. The reason, is that...
Read more >Git Attributes
One cool trick for which you can use Git attributes is telling Git which files are binary (in cases it otherwise may not...
Read more >Git - gitattributes Documentation
A gitattributes file is a simple text file that gives attributes to pathnames. ... Git decides by itself whether the file is text...
Read more >Git file force as binary
I've added a .gitattributes file to the repo, which includes the line style.min.css binary . My understanding is this line should force Git...
Read more >Please Add .gitattributes To Your Git Repository
gitattributes file allows you to specify the files and paths attributes that should be used by git when performing git actions, such as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
ah, our replies overlapped 😉 Yes, just “hardcoding”
jquery.js
andjquery.min.js
into.gitattributes
might be even better since it only affects those libraries where we are actually using SRI currently. Probablyjquery*.js eol=lf
is good enough (subject to verifying that it works)?I see, thanks for clarifying. So we do hard-code hashes in our sources 😃 In that case I agree it’s problematic to allow CRLF conversion for those files.
However like @javiercn points out, we wouldn’t want to set
.gitattributes
to treat every single.js
file in the repo as binary, since that would break our normal workflows for seeing diffs for.js
files that we do actually edit. Instead, I suggest there should be more targeted.gitattributes
rules pointing just to the exact problematic files (or perhaps narrow this rule down to files calledjquery.js
anywhere in the repo).