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
recognize .gitattributes, at least "encoding" field #96
Comments
Thanks mmarkk. Do you happen to have an example file I can use for testing? I'll see what we can do. |
2011/10/30 David Aguilar
Segmentation fault |
I was hoping you could send me a URL a document I could download in CP-1251. Yes, sorry, I'm very lazy. I have a rough idea of how we could do this. Supporting the .gitattributes parsing/rules generation is just a matter of coding. That could be kinda fun; dulwich and similar projects may have already written code we can reuse. Once we have a way to classify paths as being affected by an attribute then we can use that encoding when writing the .patch file that we feed to git apply/apply-index. I think that should work. mmarkk, does the diff output look correct with these files? Does git always output utf-8 or is cola also displaying the diff incorrectly too? Sorry for so many questions. Also, are you on Linux/win32/darwin? I know the unicode stuff in msysgit isn't completely there yet, which is why I ask. |
Similar issue here: openSuse 11.4, git-cola v1.7.6. Standard encoding is UTF-8, encoding for the files in question is Latin1 (ISO-8859-1). Staging hunks/lines in git-cola works in principle, but only when the hunk/lines don't contain non-ASCII characters (such a character in the context is sufficient to make things break). Here's a simple test working directory to reproduce the issue: It contains a file "test" with two unstaged changes. The first contains a non-ASCII character and cannot be staged. Specifying the encoding via ".gitattributes" fixes the same issue in git-gui. Interestingly using "git add -p" on the command line always works, even without the ".gitattributes". |
http://dl.dropbox.com/u/4266905/cp1251.txt
Git diff show "incorrectly", as git does know nothing about source encoding
Both display incorreclty, but: (http://linux.die.net/man/5/gitattributes): : Viewing files in GUI tools I'm still using Ubuntu 12.04 now, still the same problem. |
What we can do is follow gitk's lead and have a similar variable to turn on the feature if it turns out to have performance implications. Thanks for the examples. It's certainly possible to teach git-cola about .gitattribute encodings. The easy first step was to assume utf-8 everywhere, which is how things work right now. If you have control over your environment, I would suggest using utf-8 over latin-1, but in principle, yes this needs to be fixed. Patches and pull requests are certainly welcome! Hopefully this can be done with too many intrusive changes. |
Staging hunks/lines in git-cola works in principle, but only when the hunk/lines don't contain non-ASCII characters That's good. That means that supporting this should only affect the patch/apply parts of the code. This is very good. I'll see what I can find today. |
Teach the diff viewer to display diffs using the encoding specified in .gitattributes. This is the first half of the work needed to properly support .gitattributes for file encodings as described in issue #96. Set `cola.fileattributes` to true to enable this feature. The diffs are now displayed correctly for non-utf8 files. Diffs cannot yet be applied, but this is the first step. Signed-off-by: David Aguilar <davvid@gmail.com>
Thanks for those test repos! That really helped. I'd really appreciate it if you guys could give it a whirl. If it looks good then I'll start thinking about the next git-cola release and hopefully Ubuntu can pick it up soon. You'll need to do this in your repo to enable the feature:
The per-file attributes are checked once per cola session (for performance) so you will need to restart git-cola if you are actively making changes to |
Thanks David! Used this version for a day and everything worked as advertised. So far I haven't noticed any performance impact either, but I haven't had any really large change sets. |
I have .gitattributes with this:
So, in git GUI, "interactive add" woks out of the box, but not in git cola, as I have russian lines.
Also, git cola displays wrong symbols in these lines.
The text was updated successfully, but these errors were encountered: