Mark minified/non-human-readable file types as binary #3865

Closed
opened 2025-12-29 18:31:40 +01:00 by adam · 1 comment
Owner

Originally created by @glennmatthews on GitHub (Jul 16, 2020).

Proposed Changes

Use the .gitattributes file to mark non-human-readable file types (notably, minified JS and CSS files under project-static) as binary. I suggest the following extensions as a starting point:

diff --git a/.gitattributes b/.gitattributes
index dfdb8b77..41149c76 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,5 @@
 *.sh text eol=lf
+*.pack.js binary
+*.min.js binary
+*.min.css binary
+*.css.map binary

Justification

These files are not human-readable, and typically contain dozens to hundreds of kB of text-like data without any newlines, meaning that commands like git grep and git show that happen to intersect with these files can result in flooding the terminal with what is, for most intents and purposes, garbage.

By marking them as binary blobs via .gitattributes, their contents are not included by default in these commands, resulting in much less obtrusive output such as:

Binary file netbox/project-static/select2-bootstrap-0.1.0-beta.10/select2-bootstrap.min.css matches

diff --git a/netbox/project-static/bootstrap-3.4.1-dist/css/bootstrap-theme.css.map b/netbox/project-static/bootstrap-3.4.1-dist/css/bootstrap-theme.css.map
new file mode 100644
index 00000000..949d0973
Binary files /dev/null and b/netbox/project-static/bootstrap-3.4.1-dist/css/bootstrap-theme.css.map differ
Originally created by @glennmatthews on GitHub (Jul 16, 2020). ### Proposed Changes Use the `.gitattributes` file to mark non-human-readable file types (notably, minified JS and CSS files under `project-static`) as binary. I suggest the following extensions as a starting point: ```diff diff --git a/.gitattributes b/.gitattributes index dfdb8b77..41149c76 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,5 @@ *.sh text eol=lf +*.pack.js binary +*.min.js binary +*.min.css binary +*.css.map binary ``` ### Justification These files are not human-readable, and typically contain dozens to hundreds of kB of text-like data without any newlines, meaning that commands like `git grep` and `git show` that happen to intersect with these files can result in flooding the terminal with what is, for most intents and purposes, garbage. By marking them as binary blobs via `.gitattributes`, their contents are not included by default in these commands, resulting in much less obtrusive output such as: `Binary file netbox/project-static/select2-bootstrap-0.1.0-beta.10/select2-bootstrap.min.css matches` ```diff diff --git a/netbox/project-static/bootstrap-3.4.1-dist/css/bootstrap-theme.css.map b/netbox/project-static/bootstrap-3.4.1-dist/css/bootstrap-theme.css.map new file mode 100644 index 00000000..949d0973 Binary files /dev/null and b/netbox/project-static/bootstrap-3.4.1-dist/css/bootstrap-theme.css.map differ ```
adam added the status: acceptedtype: housekeeping labels 2025-12-29 18:31:40 +01:00
adam closed this issue 2025-12-29 18:31:40 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 17, 2020):

I pinged the other maintainers on Slack and no one was opposed. Go for it.

@jeremystretch commented on GitHub (Jul 17, 2020): I pinged the other maintainers on Slack and no one was opposed. Go for it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3865