{"thread":{"id":"61470","subject":"git format-patch displays weird chars when filename includes non-ascii chars","startedAt":"2024-05-14T15:32:29Z","lastAt":"2024-05-15T05:40:25Z","messageCount":4,"participants":["Yongmin","brian m. carlson","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"494721","messageId":"ea41a92d-35df-4b71-be70-a736d620b21f@app.fastmail.com","threadId":"61470","inReplyTo":null,"subject":"git format-patch displays weird chars when filename includes non-ascii chars","fromName":"Yongmin","fromEmail":"revi@omglol.email","sentAt":"2024-05-14T15:31:43Z","receivedAt":"2024-05-14T15:32:29Z","isPatch":false,"sender":{"key":"revi@omglol.email","avatar":null},"body":"Hi everybody,\n\nWhen the file name has non-ascii characters, the file name gets mangled somehow. Is this anything from my config side error or something gone weird with git?\n\n Steps to reproduce;\n$ git init\n$ echo 'BlahBlah' > 테스트.txt\n$ git add 테스트.txt\n$ git commit -m 'test commit'\n$ git format-patch --root\n0001-test-commit.patch\n$ cat 0001-test-commit.patch\n\nFrom d2aa2b2f5aa290edec6a5fd141318a479ac9de8e Mon Sep 17 00:00:00 2001\nFrom: Yongmin Hong <revi@omglol.email>\nDate: Tue, 14 May 2024 15:15:52 +0000\nSubject: [PATCH] test commit\n\n---\n\"\\355\\205\\214\\354\\212\\244\\355\\212\\270.txt\" | 1 +\n1 file changed, 1 insertion(+)\ncreate mode 100644 \"\\355\\205\\214\\354\\212\\244\\355\\212\\270.txt\"\n\ndiff --git \"a/\\355\\205\\214\\354\\212\\244\\355\\212\\270.txt\" \"b/\\355\\205\\214\\354\\212\\244\\355\\212\\270.txt\"\nnew file mode 100644\nindex 0000000..86724be\n--- /dev/null\n+++ \"b/\\355\\205\\214\\354\\212\\244\\355\\212\\270.txt\"\n@@ -0,0 +1 @@\n+BlahBlah\n-- \n2.32.7\n\nI searched a bit with the keyword 'format-patch ascii' but couldn't find anything useful.\nThanks in advance!\n----\nrevi | 레비\n- [he/him](https://en.pronouns.page/@revi)\n- [What time is it in my timezone](https://issuetracker.revi.xyz/u/time)\nhttps://revi.xyz\n"},{"id":"494747","messageId":"ZkPNHqAUemfdfaFD@tapette.crustytoothpaste.net","threadId":"61470","inReplyTo":"ea41a92d-35df-4b71-be70-a736d620b21f@app.fastmail.com","subject":"Re: git format-patch displays weird chars when filename includes non-ascii chars","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2024-05-14T20:44:14Z","receivedAt":"2024-05-14T20:44:16Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2024-05-14 at 15:31:43, Yongmin wrote:\n> Hi everybody,\n> \n> When the file name has non-ascii characters, the file name gets mangled somehow. Is this anything from my config side error or something gone weird with git?\n> \n>  Steps to reproduce;\n> $ git init\n> $ echo 'BlahBlah' > 테스트.txt\n> $ git add 테스트.txt\n> $ git commit -m 'test commit'\n> $ git format-patch --root\n> 0001-test-commit.patch\n> $ cat 0001-test-commit.patch\n> \n> From d2aa2b2f5aa290edec6a5fd141318a479ac9de8e Mon Sep 17 00:00:00 2001\n> From: Yongmin Hong <revi@omglol.email>\n> Date: Tue, 14 May 2024 15:15:52 +0000\n> Subject: [PATCH] test commit\n> \n> ---\n> \"\\355\\205\\214\\354\\212\\244\\355\\212\\270.txt\" | 1 +\n> 1 file changed, 1 insertion(+)\n> create mode 100644 \"\\355\\205\\214\\354\\212\\244\\355\\212\\270.txt\"\n> \n> diff --git \"a/\\355\\205\\214\\354\\212\\244\\355\\212\\270.txt\" \"b/\\355\\205\\214\\354\\212\\244\\355\\212\\270.txt\"\n\nIn some cases, Git uses escaped strings (often octal[0]) to avoid\nproblems with encoding when sending patches over email or producing\nunambiguous output.  For example, the file name \"\\r\\n.txt\" would\ndefinitely break sending over email.\n\nIn addition, while it appears that you're using UTF-8, which is great,\nGit does not require file names to be in UTF-8, and it's valid to\nspecify 0xfe and 0xff (among other byte values) in file names in Git.\nHowever, if we wrote those bytes in the body of an email, many users\nwould be upset when reviewing the patches, since they will usually want\nto write their emails in UTF-8, and it's possible the patches might get\nmishandled or mangled by a mail server or mail client.\n\nThus, Git prefers to encode names in a way that is unambiguous and\ndoesn't lead to mangling.  It is inconvenient that legitimate UTF-8 file\nnames don't get rendered properly, though.  I don't _believe_ there's an\noption to show the regular UTF-8, but I could be wrong.\n\n[0] I don't know why we chose octal and I'd much prefer hexadecimal, but\nI wonder if it may have originally been to pipe to printf(1), which\nPOSIX requires to accept octal, but unfortunately not hexadecimal,\nescapes.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"},{"id":"494749","messageId":"xmqq1q643whe.fsf@gitster.g","threadId":"61470","inReplyTo":"ZkPNHqAUemfdfaFD@tapette.crustytoothpaste.net","subject":"Re: git format-patch displays weird chars when filename includes non-ascii chars","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-05-14T21:38:21Z","receivedAt":"2024-05-14T21:38:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> Thus, Git prefers to encode names in a way that is unambiguous and\n> doesn't lead to mangling.  It is inconvenient that legitimate UTF-8 file\n> names don't get rendered properly, though.  I don't _believe_ there's an\n> option to show the regular UTF-8, but I could be wrong.\n\n$ git config --global core.quotepath false\n\n"},{"id":"494757","messageId":"9fd0e8d0-07c3-4461-b8c3-c2e54e27c9ce@app.fastmail.com","threadId":"61470","inReplyTo":"xmqq1q643whe.fsf@gitster.g","subject":"Re: git format-patch displays weird chars when filename includes non-ascii chars","fromName":"Yongmin","fromEmail":"revi@omglol.email","sentAt":"2024-05-15T05:40:04Z","receivedAt":"2024-05-15T05:40:25Z","isPatch":false,"sender":{"key":"revi@omglol.email","avatar":null},"body":"On 2024-05-15 (Wed) 06:38:21+09:00, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> $ git config --global core.quotepath false\n\nThanks! It now works as desired.\n\n----\nrevi | 레비\n- he/him <https://en.pronouns.page/@revi>\n- What time is it in my timezone? <https://issuetracker.revi.xyz/u/time>\nhttps://revi.xyz\n"}]}