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
Make Emacs use the encoding and line endings configured at the Git level #1782
Comments
Try whether removing |
When I set (setq magit-git-standard-options
'("-c"
"core.preloadindex=true"
"pager.diff=true")) magit can't find git repository for this file (without "pager.diff=true" ok, but incorrect cp1251-encoded symbols displaying). |
I think you need one (setq magit-git-standard-options
'("-c" "core.preloadindex=true"
"-c" "pager.diff=true")) |
Ok, now magit works well thank you, but for both |
I am afraid it will be a while until I can do something about this. Currently Magit just encodes all of its buffers in unicode and it would be hard to change that. Especially when considering that the same may contain snippets from various files, not all of which necessarily use the same encoding. I recommend you instead tell Git to checkout as unicode, if that is possible. Something similar can be done for line endings, I don't know whether the equivalent is possible for the coding system. If it is support then I would expect that also to affect diff output, not just checked out files. |
... if that is feasible. |
@kostafey could you please point me to a public repository that I can use to experiment. |
The output of one So this has to be done at the git level. I believe the
Of course you might have to be more precise than just I cannot actually verify that this works until I get my hands onto a real-word repository containing files using such encodings. |
That is the main problem, because of my-very-strange compiler restrictions, I have to use cp1251.
https://github.com/kostafey/test_cp1251
This doesn't solve the problem for me. |
Does it not work at all, or does it work but you cannot use it because of the compiler restriction? Edit: Just tried myself. Doesn't seem to work at all... |
It seems, I'm doing something wrong. Should I change the file encodings manually? |
What are you doing wrong? This is what I get: $ file file.txt
file.txt: UTF-8 Unicode text, with CRLF line terminators
$ git diff
diff --git a/file.txt b/file.txt
index b8f917d..497db3a 100644
--- a/file.txt
+++ b/file.txt
@@ -1,2 +1,2 @@
-<F2><E5><EA><F1><F2> <F2><E5><EA><F1><F2> <F2><E5><EA><F1><F2>
+<F2><E5><EA><F1><F2> <F2><E5><EA><F1><F2> <F2><E5><EA><F1><F2>foo^M
text text text
$ git -c "pager.diff=iconv -f windows-1251 -t utf-8" diff
diff --git a/file.txt b/file.txt
index b8f917d..497db3a 100644
--- a/file.txt
+++ b/file.txt
@@ -1,2 +1,2 @@
-текст текст текст
+текст текст текстfoo
text text text After adding the filter definition to I also found msysgit/msysgit#113, which I believe means that this approach is supposed to work. |
I've got the same result. But it's a git console. And what about magit? |
Same in Magit. I suggest you post the filter configuration above on (e.g.) Stackoverflow. Maybe someone there can help you figure out why it doesn't work. Or maybe this isn't the right approach at all. I just don't know. The issue isn't really specific to Magit so I would not mention that. By the way the |
Since I have to edit files in cp1251 encoding, I'd like to versioning them.
Magit diff buffer shows cp1251-encoded text wrong.
To fix it in bare git via
git diff
I can use:in my
.git/config
.So, is it possible to solve this problem in magit diff buffers?
The text was updated successfully, but these errors were encountered: