threads / discuss / 10770

git-gui messes up the diff view on non ASCII characters

Subject: git-gui messes up the diff view on non ASCII characters

## tl;dr

4 messages between Nov 9, 2007 and Nov 11, 2007.

replies: 3people: 4as markdown or json

Peter Baumann· Nov 9, 2007, 15:49 UTC · lore

I'm managing some UTF-8 encoded LaTeX files in git, which include some non ASCII characters like the german ä,ö and ü. If I view the diff with git-diff on an UTF8 enabled terminal, all looks nice. So does the diff view in gitk after I commited my changes. Only git-gui shows some "strange" characters, so I assume it is an encoding problem.

I have to admit that I'm totally unaware how this should work, but at least I think my configuration is correct here, because otherwise git-diff or gitk would show the same behaviour. Is there anything which could be done to make git-gui happy, too?

-Peter
Michele Ballabio· Nov 9, 2007, 21:30 UTC · re: Peter Baumann · lore

Re: git-gui messes up the diff view on non ASCII characters

On Friday 09 November 2007, Peter Baumann wrote:
Show 10 quoted lines
> I'm managing some UTF-8 encoded LaTeX files in git, which include some
> non ASCII characters like the german ä,ö and ü. If I view the diff with
> git-diff on an UTF8 enabled terminal, all looks nice. So does the diff
> view in gitk after I commited my changes. Only git-gui shows some
> "strange" characters, so I assume it is an encoding problem.
> 
> I have to admit that I'm totally unaware how this should work, but at
> least I think my configuration is correct here, because otherwise git-diff
> or gitk would show the same behaviour. Is there anything which could be
> done to make git-gui happy, too?

It's a known issue, and already on Shawn's ToDo list. I have to add that viewing untracked UTF8 files in git-gui works just fine. Weird.

Shawn O. Pearce· Nov 11, 2007, 05:59 UTC · re: Michele Ballabio · lore

Re: git-gui messes up the diff view on non ASCII characters

Michele Ballabio <barra_cuda@katamail.com> wrote:
Show 14 quoted lines
> On Friday 09 November 2007, Peter Baumann wrote:
> > I'm managing some UTF-8 encoded LaTeX files in git, which include some
> > non ASCII characters like the german ä,ö and ü. If I view the diff with
> > git-diff on an UTF8 enabled terminal, all looks nice. So does the diff
> > view in gitk after I commited my changes. Only git-gui shows some
> > "strange" characters, so I assume it is an encoding problem.
> > 
> > I have to admit that I'm totally unaware how this should work, but at
> > least I think my configuration is correct here, because otherwise git-diff
> > or gitk would show the same behaviour. Is there anything which could be
> > done to make git-gui happy, too?
> 
> It's a known issue, and already on Shawn's ToDo list. I have to add that
> viewing untracked UTF8 files in git-gui works just fine. Weird.

Cute. That's because in the untracked case we open the file and let the platform's chosen encoding be used to convert it into the text viewer. In the tracked diff case we force the encoding to be in binary.

Now gitk works because it assumes the diff is in the same character encoding as the commit message itself. Since commit messages are typically in UTF-8 (as that is the Git default encoding) then a UTF-8 encoded file shows correctly in gitk.

What's the right behavior here? Just assume the platform encoding is correct for the file we are showing and show it? Assume the commit encoding configured in i18n.commitencoding is the correct one for the file content? Something else?

-- 
Shawn.
Johannes Schindelin· Nov 11, 2007, 11:20 UTC · re: Shawn O. Pearce · lore

Re: git-gui messes up the diff view on non ASCII characters

Hi,
On Sun, 11 Nov 2007, Shawn O. Pearce wrote:
Show 30 quoted lines
> Michele Ballabio <barra_cuda@katamail.com> wrote:
> > On Friday 09 November 2007, Peter Baumann wrote:
> > > I'm managing some UTF-8 encoded LaTeX files in git, which include some
> > > non ASCII characters like the german ä,ö and ü. If I view the diff with
> > > git-diff on an UTF8 enabled terminal, all looks nice. So does the diff
> > > view in gitk after I commited my changes. Only git-gui shows some
> > > "strange" characters, so I assume it is an encoding problem.
> > > 
> > > I have to admit that I'm totally unaware how this should work, but at
> > > least I think my configuration is correct here, because otherwise git-diff
> > > or gitk would show the same behaviour. Is there anything which could be
> > > done to make git-gui happy, too?
> > 
> > It's a known issue, and already on Shawn's ToDo list. I have to add that
> > viewing untracked UTF8 files in git-gui works just fine. Weird.
> 
> Cute.  That's because in the untracked case we open the file and
> let the platform's chosen encoding be used to convert it into the
> text viewer.  In the tracked diff case we force the encoding to
> be in binary.
> 
> Now gitk works because it assumes the diff is in the same character
> encoding as the commit message itself.  Since commit messages are
> typically in UTF-8 (as that is the Git default encoding) then a
> UTF-8 encoded file shows correctly in gitk.
> 
> What's the right behavior here?  Just assume the platform encoding
> is correct for the file we are showing and show it?  Assume the
> commit encoding configured in i18n.commitencoding is the correct
> one for the file content?  Something else?
My twopence: assume utf-8, but make it a _git-gui_ config variable.

Ciao, Dscho

← back to recent threads