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

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

From
Jeff King <peff@peff.net>
Date
Nov 12, 2008, 10:43 UTC
Message-ID
<20081112104318.GA20120@coredump.intra.peff.net>
In-Reply-To
<85647ef50811111112o5449c12elfc571e46e607cfd0@mail.gmail.com>
On Tue, Nov 11, 2008 at 10:12:46PM +0300, Constantine Plotnikov wrote:
Show 9 quoted lines
> 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 don't actually use any encodings except UTF-8, so maybe there is some subtle reason not to do so that I don't understand, but I would have expected all of the format placeholders to respect any --encoding parameter.

If that is the desired behavior, this should not be too hard to make a patch for:

  1. in pretty_print_commit, move the code path for userformat to just
     after the re-encoding
  2. pass the re-encoded buffer to format_commit_message, where it will
     be put into the context struct
  3. use the re-encoded buffer in parse_commit_header

Maybe it would make a good exercise for somebody who wants to dig into git a little deeper? Volunteers?

Show 5 quoted lines
> 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.

This actually annoyed me earlier today. What got me was that '%s%n%n%b' doesn't necessarily give you the exact commit message; if it's a one-liner (i.e., body is blank), then you end up with an extra newline.

Again, this should be a pretty easy exercise to add. Volunteers?
-Peff
Previous: Constantine PlotnikovNext: Jeff King
Message 2 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.