Git messages with french accents

2019-08-13 12:31发布

I use to commit my personnal projects with french messages, including UTF-8 accents.

I was working on these projects on a Linux Arch install, and then pulled them on another new Arch install.

But now when I want to look at the git log of one of these projects, it doesn't render the french accents correctly.

Example with a choosen commit:

$ git log -n1 --pretty=format:"%h %s" 8e72413
8e72413 Ajout<C3><A9> le param<C3><A8>tre TabStop

But when I pipe it with cat, it works like a charm:

$ git log -n1 --pretty=format:"%h %s" 8e72413 | cat
8e72413 Ajouté le paramètre TabStop

It works well too when I read it using Vim, using the following similar command:

:r! git log -n1 --pretty=format:"%h %s" 8e72413

The same problem is happening if I use either xterm or urxvt, and my locale settings are well configured (as well with my old install on which I was working), with LANG=fr_FR.UTF-8. Of course, my old Arch install is still working well, without this issue, with the same repository.

What did I miss? I really don't remember anything I could have done on my old install to make it work properly.

1条回答
疯言疯语
2楼-- · 2019-08-13 13:15

The problem is that my locale config was not so well configured :

$ locale
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=

I didn't see the important point : LC_ALL was not set to fr_FR.UTF-8.


EDIT:

Actually, the problem was more trivial than that : I just forgot that I added the following alias: alias git='LANG=en_US.UTF-8 git'

Indeed, changing the value of LC_ALL is not a solution.

I made this alias because vim-fugitive is not working well with git displayed in french language...

查看更多
登录 后发表回答