Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.gitattributes cannot represent a grammar name containing spaces #4496

Closed
4 tasks done
octogonz opened this issue Apr 15, 2019 · 3 comments
Closed
4 tasks done

.gitattributes cannot represent a grammar name containing spaces #4496

octogonz opened this issue Apr 15, 2019 · 3 comments

Comments

@octogonz
Copy link

Preliminary Steps

Please confirm you have...

Problem Description

I can specify a line like this in my .gitattributes file, and it works fine:

*.json            linguist-language=JSON5

But If I try to use a grammar name that contains spaces, it does NOT work:

*.json            linguist-language=JSON with Comments

The reason is that .gitattributes lines are a sequence of value pairs that are delimited by spaces. I examined Git's parser, and as far as I can tell, it actually provides no way to escape the value part of a name=value pair.

I also found an old Linguist FAQ document which suggests to put dashes instead of spaces, but that does NOT work either:

*.json            linguist-language=JSON-with-Comments

Substituting hyphens for spaces seems like a pretty good solution. Should we implement that? If so, where's the code?

Last modified on:

2019-04-15

octogonz added a commit to microsoft/rush-example that referenced this issue Apr 15, 2019
@lildude
Copy link
Member

lildude commented Apr 21, 2019

I also found an old Linguist FAQ document which suggests to put dashes instead of spaces, but that does NOT work either:

It certainly does 😁

screenie

Even a copy of your rush.json file (ignore the typo 😊) does - https://github.com/lildude/super-potato/blob/master/ruah.json

The problem you're hitting is a known limitation with the way GitHub caches the blobs: the cache, and thus syntax highlighting, isn't refreshed when you make changes to the .gitattributes. A file affected by a language override needs to be modified too.

@octogonz
Copy link
Author

Thank you very much @lildude ! I confirmed that the problem was the GitHub cache issue. After touching the file, the highlighting is now working properly.

I will close this issue. It would be helpful to document the .gitattributes syntax somewhere -- if I had confidence that my syntax was correct, then I would have tried harder to get it working before opening this issue. Unfortunately the linguist FAQ is apparently no longer published.

@lildude
Copy link
Member

lildude commented Apr 25, 2019

It would be helpful to document the .gitattributes syntax somewhere -- if I had confidence that my syntax was correct, then I would have tried harder to get it working before opening this issue.

Yeah, good idea. I think we can add it to https://github.com/github/linguist#using-gitattributes.

As for the FAQ... it's not yet been published 😉. #4271 is the PR (/me nudges @pchaigno)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants