Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The .gitattribues files specifies certain extensions as binary (like *.jpg ) to provider easier diffs.
However, the web font formats .woff
and .woff2
are missing. So for webfonts you must supply --binary to get a usable diff.
Proposed resolution
3 line change to .gitattributes to mark .woff, .woff2 and eot as binary.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#35 | git_2711855_34.patch | 625 bytes | MeenakshiG |
#6 | classify_eot_woff_woff2_as_binary-2711855-6.patch | 267 bytes | toomanypets |
#2 | 2711855-woff.diff | 245 bytes | derheap |
Comments
Comment #2
derheap CreditAttribution: derheap as a volunteer commentedComment #3
derheap CreditAttribution: derheap as a volunteer commentedComment #4
derheap CreditAttribution: derheap as a volunteer commentedComment #5
tstoecklerThanks for the patch! I think the proper fix is for Drupal to stop treating arbitrary files as text files. That is trying to be achieved in #2333243: Relax .gitattributes global rule. Thus, I am closing this as duplicate, because I think your problem would be fixed by that issue as well. Please re-open in case I'm incorrect.
Comment #6
toomanypets CreditAttribution: toomanypets commented@tstoeckler -- #2333243: Relax .gitattributes global rule has been committed and does not address this problem. Tested today. Attaching new patch to include .eot files as well.
Comment #7
neclimdulI don't see a problem with this patch since they're probably common enough for site builders but I wasn't able to recreate it. For the sake of understanding the problem, is it possible you've got a global setting that it defaulting everything to text?
Comment #8
toomanypets CreditAttribution: toomanypets commented@neclimdul If there's a global setting somewhere I can not find it. See https://www.drupal.org/node/2333243#comment-11448493 for test methodology.
Comment #9
neclimdulLets discuss here.
Comment #10
neclimdulSo both seem to be treating the file as binary and I would expect not corrupting the file. The difference seems to only be triggering
Include binary diff in patches instead of "binary files differ."
Comment #11
toomanypets CreditAttribution: toomanypets commentedRegarding #10, correct. And this renders the patch for a binary file useless.
Comment #12
neclimdulAgain not against this, but the git process for files like this is to add --binary option to your git diff command.
There isn't any corruption and this is a standard git behavior so pull it down to minor.
Comment #13
toomanypets CreditAttribution: toomanypets commentedI suppose we have explicity specified other binary file types as binary in the .gitattributes file as a matter of convenience, so that we do not have to remember to use the --binary option when our changes include binary files.
It becomes even more convenient, and mitigates errors, when both binary and text files are added or modified. For example, I might make several changes to a theme: include a new font file, modify an existing image, add a new css file, and modify an existing template. Some of the files are binary, and some are not.
This became an annoyance when I ran into problems with this patch:
https://www.drupal.org/node/2716557#comment-11284831
It is malformed, and the changes include both binary and text files.
I agree this is minor, but an annoyance nevertheless!
Comment #14
RainbowArrayWe manually specify a number of different image file formats as binary. This is great, because it avoids everybody in the world knowing to do git add --binary. I guarantee you, most of the folks who will need to do this (front-end developers and site builders) do not know they need to do this, and expecting that seems wrong. Font files are pretty commonly needed for sites. What's the harm in adding this to gitattributes so that this is an easy thing and not a hard thing?
The alternative is that projects will not use core's gitattributes file and will instead override it, which means any future updates to gitattributes won't get applied to sites. So... better to be friendly and add .woff, woff2, and .eot to the list of binary files. Particularly because we already have .ttf, which is also a font file.
Comment #15
RainbowArrayIf we're able to backport this to 8.2.x and even 8.1.x, that would be great. It seems harmless enough.
Comment #16
KrisBulman CreditAttribution: KrisBulman commentedAgreed, fonts easily become corrupted with git. If new versions are added and fonts are not treated as binary, you will see the following in console..
If
*.ttf -text diff
(TrueType) is included now then webfonts using todays web standards should be as well.Comment #17
toomanypets CreditAttribution: toomanypets commentedAdding .otf as well. Ran into that one today.
Comment #18
toomanypets CreditAttribution: toomanypets commentedComment #21
toomanypets CreditAttribution: toomanypets commentedStill needs review by someone other than me, then change status to RTBC.
Comment #22
rootworkThe patch certainly applies and does what it's supposed to do. Do we need a subsystem maintainer's sign-off?
Comment #23
cilefen CreditAttribution: cilefen as a volunteer commentedPlease alphabetize the attributes then I see nothing blocking this if it makes lives easier. Thank you.
Comment #24
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs commentedComment #25
cilefen CreditAttribution: cilefen as a volunteer commentedHi Meenakshi Gupta:
Thank you for helping out. We use needs work when there is a patch needing changes.
Comment #26
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs commented@cilefen after alphabetizing the attributes
Comment #27
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs commentedComment #28
toomanypets CreditAttribution: toomanypets commented@Meenakshi, please reverse png and phar.
Comment #29
toomanypets CreditAttribution: toomanypets commentedComment #30
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs commented@toomanypets done !
Comment #31
tstoecklerPerfect, thanks @Meenakshi Gupta !
Let's get this in.
Comment #33
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs commentedComment #35
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs commentedComment #36
tstoecklerThanks @Meenakshi Gupta for your persistence. You really hit some bad luck there. Still good to go.
Comment #38
neclimdulrandom failure, green again.
Comment #40
star-szrRandom fail in Drupal\KernelTests\Core\Cache\DatabaseBackendTest.
Comment #44
catchCommitted/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!