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

Re: Problems with format-patch UTF-8 and a missing second empty line

From
Jeff King <peff@peff.net>
Date
Sep 15, 2011, 19:01 UTC
Message-ID
<20110915190132.GA17027@sigill.intra.peff.net>
In-Reply-To
<CAHz1FYgPuMHLC+f2mFqD73=NGXQSStRPDOsiCy-HtaWKbHu7NQ@mail.gmail.com>
On Thu, Sep 15, 2011 at 11:45:15AM +0200, Ingo Ruhnke wrote:
> Creating a patch of a commit including UTF-8 and no empty second line,
> like this:

I already responded about the bug with utf8-encoded subjects, but let me address the second half of your mail, too:

> Here the newline between ABC\nABC gets stripped out and replaced with
> a space when transferring the commit with format-patch from one
> repository to another.

This is by design. Git commit messages are intended to have a single-line subject, followed by a blank line, followed by more elaboration. A multi-line subject is treated as a single line that has been line-broken, and is subject to being reflowed onto a single line. This is done to help with commits imported from other version control systems which don't follow this pattern (the other option is truncating the subject and putting the other lines into the "body", but that often ends up quite unreadable).

If you really want to retain the newlines across "format-patch | am", use the "-k" option of both to preserve the subject (I don't recall the details, but I think you need a more recent version of git for format-patch to correctly encode this, but "am" can be from any version).

> Another small issue is that the filename of the patch will strip out
> any UTF-8 characters, Thus a commit message of "123Äöü456" will result
> in "0001-123-456.patch".

Yes, it's an attempt to strip out characters that some filesystems might not support well. We could probably enable high-bit characters with a config option (maybe even just using core.quotepath).

-Peff
Previous: Jeff KingNext: Jeff King
Message 3 of 6 in “Problems with format-patch UTF-8 and a missing second empty line”
  1. Ingo RuhnkeSep 15, 2011
  2. Jeff KingSep 15, 2011
  3. Jeff KingSep 15, 2011
  4. Jeff KingSep 15, 2011
  5. Alexey ShumkinSep 15, 2011
  6. Jeff KingSep 15, 2011

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.