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

Re: [PATCH/RFC v2] Document format of basic Git objects

From
Jeff King <peff@peff.net>
Date
Feb 20, 2012, 16:11 UTC
Message-ID
<20120220161101.GA27105@sigill.intra.peff.net>
In-Reply-To
<CACsJy8CEeZPf55idLB9NE-rf--ySmZh_9gkMc_zo0VmiVftMUg@mail.gmail.com>
On Mon, Feb 20, 2012 at 08:55:28PM +0700, Nguyen Thai Ngoc Duy wrote:
Show 7 quoted lines
> > Author-ident is typically utf-8 already, so you cannot assume "ASCII".
> 
> I wonder if anyone puts non utf-8 strings in there, or could we
> enforce utf-8 (i.e. validate and reject non utf-8 strings) and accept
> encoded word syntax (rfc 2047) with the help of the new
> $GIT_IDENT_ENCODING variable. The "accept ..." part can wait until
> someone is hit by "utf-8 only" check and steps up.

I was just having a similar discussion with libgit2 folks, who were wondering if there would ever be non-utf8 in there. When we call "reencode_commit_message", it looks like we do the whole object. In other words, your author name _must_ match any encoding you specify in the "encoding" header.

I.e., if you do:
  # latin1 é
  e=`printf '\xe9'`
  export GIT_AUTHOR_NAME="P${e}ff King"
  git init
  git config i18n.commitencoding iso8859-1
  touch foo && git add foo &&
  git commit --allow-empty -m "more latin1 ${e}ncoding"

both the name and the message should show fine on your utf8 terminal if you do this:

  git config i18n.logoutputencoding utf8
  git show

And similarly, we do the right thing in format-patch, both with and without logoutputencoding set:

  $ git format-patch --root --stdout | grep -Ei "^(from|subject):"
  From: =?iso8859-1?q?P=E9ff=20King?= <peff@peff.net>
  Subject: [PATCH] =?iso8859-1?q?more=20latin1=20=E9ncoding?=
  $ git config i18n.logoutputencoding utf8
  $ git format-patch --root --stdout | grep -Ei "^(from|subject):"
  From: =?utf8?q?P=C3=A9ff=20King?= <peff@peff.net>
  Subject: [PATCH] =?utf8?q?more=20latin1=20=C3=A9ncoding?=
(where 0xc3a9 is the utf8 equivalent of latin1 0xe9).

So I have no idea if people are using it or not, but it is actually usable.

-Peff
Previous: Nguyen Thai Ngoc DuyNext: Philip Oakley
Message 9 of 17 in “Document format of basic Git objects”
  1. Document format of basic Git objectsNguyễn Thái Ngọc Duy, Feb 15, 2012
  2. Jonathan NiederFeb 15, 2012
  3. Junio C HamanoFeb 15, 2012
  4. Junio C HamanoFeb 16, 2012
  5. Document format of basic Git objectsNguyễn Thái Ngọc Duy, Feb 19, 2012
  6. Junio C HamanoFeb 19, 2012
  7. Junio C HamanoFeb 19, 2012
  8. Nguyen Thai Ngoc DuyFeb 20, 2012
  9. Jeff KingFeb 20, 2012
  10. Manually decoding a git objectPhilip Oakley, Feb 19, 2012
  11. 徐迪Feb 20, 2012
  12. Philip OakleyFeb 20, 2012
  13. Thomas RastFeb 20, 2012
  14. Philip OakleyFeb 20, 2012
  15. Thomas RastFeb 20, 2012
  16. 徐迪Feb 20, 2012
  17. Philip OakleyFeb 20, 2012

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.