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

Re: Should the --encoding argument to log/show commands make any guarantees about their output?

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 17, 2015, 16:42 UTC
Message-ID
<xmqqzj3y2snq.fsf@gitster.dls.corp.google.com>
In-Reply-To
<557E91D2.3000908@googlemail.com>
Jan-Philip Gehrcke <jgehrcke@googlemail.com> writes:
Show 7 quoted lines
> I was surprised to see that the output of
>
>     git log --encoding=utf-8 "--format=format:%b"
>
> can contain byte sequences that are invalid in UTF-8. Note: I am using
> git 2.1.4 and the %b format specifier represents the commit message
> body.

Yeah, if the original was bad and cannot be sanely expressed in UTF-8, you have two options. You can show the contents as raw bytes recorded in the object with a warning so that the user can use it as such (e.g. perhaps the original was indeed an iso8859-2 but was incorrectly marked as UTF-8, or something like that, and a human that is more intelligent than a tool _could_ guess and attempt to recover). Or you can error out and refuse to produce output.

We deliberately made a design choice to take the former option.
Previous: Torsten BögershausenNext: Jan-Philip Gehrcke
Message 5 of 9 in “Should the --encoding argument to log/show commands make any guarantees about their output?”
  1. Jan-Philip GehrckeJun 15, 2015
  2. Torsten BögershausenJun 15, 2015
  3. Jan-Philip GehrckeJun 16, 2015
  4. Torsten BögershausenJun 16, 2015
  5. Junio C HamanoJun 17, 2015
  6. Jan-Philip GehrckeJun 17, 2015
  7. Jeff KingJun 17, 2015
  8. Junio C HamanoJun 17, 2015
  9. Torsten BögershausenJun 17, 2015

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.