git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git gui blame utf-8 bugs

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 14, 2007, 12:39 UTC
Message-ID
<m3k5nhqwkn.fsf@roke.D-201>
In-Reply-To
<20071214064709.GH14735@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 17 quoted lines
> Finn Arne Gangstad <finnag@pvv.org> wrote:
> > git gui has some utf-8 bugs:
> 
> It has several.  :-)
>  
> > If you do git gui blame <file>, and the file contains utf-8 text,
> > the lines are not parsed as utf-8, but seemingly as iso-8859-1 instead.
> 
> Right.  git-gui is keying off the environment setting for LANG, so I
> guess its set to iso-8859-1 on your system but you are working with a
> utf-8 file.  We've talked about using something like .gitattributes
> to store encoding hints, or to just put a global gui setting in
> ~/.gitconfig but neither has had any patches written for it.
> 
> UTF-8 is seemingly the most common encoding that git-gui is mangling
> so maybe we should be defaulting to utf-8 until someone codes a
> more intelligent patch.
Currently there is no config variable for default encoding of file
contents (of blobs) and of filenames (of trees) because those do not
matter for core git.  But they do matter for GUI.
 
Show 14 quoted lines
> > Also, the hovering comment is INITIALLY shown garbled (both Author and
> > commit message), but if you click on a line, so that the commit
> > message is shown in the bottom window, the hovering message is
> > magically corrected to utf-8.
> > 
> > The text in the lower window (showing specific commits) seems to
> > always be handled correctly.
> 
> That's a "feature".  :-)
> 
> What's happening here is the initial hovering message is obtained
> from the machine formatted output from `git blame --incremental`
> and in that format there is no encoding header so I'm just ignoring
> any encoding problems.

So the correct solution would be to enhance "git blame --incremental" to output 'encoding' header when needed (when commit has encoding header and it is different from log output encoding).

Show 7 quoted lines
> Later when you click on a line it does `git cat-file commit $sha1`
> and gets the proper encoding, and corrects the strings it originally
> had gotten from git-blame.  So the hovering message "fixes" itself
> later on.
> 
> Maybe here too we should be defaulting to utf-8 instead of the
> native encoding.

I think this is a good idea, as git repositories are meant to be cross-operating system (which means cross-delault-encodings) compatible.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Shawn O. PearceNext: Finn Arne Gangstad
Message 3 of 4 in “git gui blame utf-8 bugs”
  1. Finn Arne GangstadDec 12, 2007
  2. Shawn O. PearceDec 14, 2007
  3. Jakub NarebskiDec 14, 2007
  4. Finn Arne GangstadDec 17, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.