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

Re: "add -p" + filenames with UTF-8 multibyte characters = "No changes"

From
TLTeemu Likonen <tlikonen@iki.fi>
Date
Feb 16, 2009, 05:13 UTC
Message-ID
<87ljs7ynf0.fsf@iki.fi>
In-Reply-To
<20090216033634.GA12461@coredump.intra.peff.net>
On 2009-02-15 22:36 (-0500), Jeff King wrote:
> I am not opposed to setting this as a default, but I think there may
> be some encoding issues to be dealt with. At the very least,
> format-patch generates messages without a content-type header. E.g.,:
> But what is the right encoding to specify? We can guess that it is
> whatever the commit message is in (defaulting to utf-8). It is by no
> means correct, but it would probably work pretty well in practice.

I have a small script which adds/rewrites MIME headers. It defaults to UTF-8/8bit:

    #!/bin/sh
    charset="${1:-UTF-8}"
    encoding="${2:-8bit}"
    formail -I "MIME-Version: 1.0" \
            -I "Content-Type: text/plain; charset=$charset" \
            -I "Content-Transfer-Encoding: $encoding" \
            -s
I have used the script this way:
    git format-patch --stdout [...] | add-mime-headers | \
        formail -s sh -c 'cat >$FILENO.patch'

It may be difficult and unreliable to try to detect the encoding of file content so maybe "git format-patch" could be taught an option like "--charset=<charset>". (And perhaps also a configuration variable.) That would just write MIME headers (charset) as the user wishes.

Previous: Teemu Likonen
Message 8 of 8 in “"add -p" + filenames with UTF-8 multibyte characters = "No changes"”
  1. Antonio García DomínguezFeb 15, 2009
  2. Teemu LikonenFeb 15, 2009
  3. Teemu LikonenFeb 15, 2009
  4. Jeff KingFeb 16, 2009
  5. Junio C HamanoFeb 16, 2009
  6. git-add -i/-p: learn to unwrap C-quoted pathsJunio C Hamano, Feb 17, 2009
  7. Teemu LikonenFeb 17, 2009
  8. Teemu LikonenFeb 16, 2009

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.