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

Possible bug: "git log" ignores "--encoding=UTF-8" option if --pretty=format:%e%n%s%n is used

From
CPConstantine Plotnikov <constantine.plotnikov@gmail.com>
Date
Nov 11, 2008, 19:12 UTC
Message-ID
<85647ef50811111112o5449c12elfc571e46e607cfd0@mail.gmail.com>

If encoding is forced for git log with "--encoding=UTF-8", it seems to be ineffective for the formatted output. Is it intentional?

Lets consider the following scenario (script is for bash, git 1.5.4.3 and 1.6.0.2):

git init echo initial >test.txt git add test.txt echo -e \\0320\\0242\\0320\\0265\\0321\\0201\\0321\\0202 >msg-UTF-8.txt git commit -F msg-UTF-8.txt echo updated >test.txt git add test.txt echo -e \\0322\\0345\\0361\\0362 >msg-windows-1251.txt git config i18n.commitencoding Windows-1251 git commit -F msg-windows-1251.txt git log --encoding=Windows-1251 >log1.txt git log --encoding=UTF-8 >log2.txt git log --encoding=Windows-1251 --pretty=format:%e%n%s%n >log3.txt git log --encoding=UTF-8 --pretty=format:%e%n%s%n >log4.txt

In the both cases the string is the russian string meaning test in different encoding.

If we compare log1.txt and log2.txt, we will see that the same encoding specified is used for both commits in the log.

If we compare log3.txt and log4.txt, we will see that the same the contents of the file is completely identical. The native encoding is used for each commit. So the first listed commit is encoded using Windows-1251 and the second one using UTF-8. However in the description of the %s %b options nothing is said about which encoding is used and implied behavior is that they are affected by --encoding option.

I suggest documenting that the placeholders %s and %b use native commit encoding and introducing the placeholders %S and %B options that use encoding specified on the command line or the default log encoding.

I also suggest adding %g and %G placeholders (%m placeholder is already occupied) that print the entire commit message instead of just the subject or the body. Currently the tools have to join the entire message from two parts when they are just interested in the entire message.

Regards, Constantine

Next: Jeff King
Message 1 of 8 in “Possible bug: "git log" ignores "--encoding=UTF-8" option if --pretty=format:%e%n%s%n is used”
  1. Constantine PlotnikovNov 11, 2008
  2. Jeff KingNov 12, 2008
  3. Jeff KingNov 12, 2008
  4. Constantine PlotnikovNov 12, 2008
  5. Junio C HamanoNov 13, 2008
  6. Jeff KingNov 13, 2008
  7. Junio C HamanoNov 13, 2008
  8. Jeff KingNov 13, 2008

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.