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

Re: Feature request: better error messages when UTF-8 bites

From
Johannes Sixt <j6t@kdbg.org>
Date
Jul 28, 2022, 05:42 UTC
Message-ID
<4b09bf98-dae2-491e-9858-801a9bcdd2fa@kdbg.org>
In-Reply-To
<f5a49da29fd0e5577083f1006d394158@ch.pkts.ca>
Am 27.07.22 um 22:21 schrieb CH:
Show 28 quoted lines
> Somehow when copying and pasting a commit from a website to the command
> line, a UTF-8 Byte Order Mark (BOM)
> [https://en.wikipedia.org/wiki/Byte_order_mark] was appended to one of
> the commit ids.  BOMs are invisible, as are many other UTF-8 code
> points.  The upshot was that Git didn't like it, and complained bitterly:
> 
>> $ strace -etrace=execve -s 200 git diff
>> 038179704f0066aa815d5429221cf381ff4ef289 
>> 47346a462d8ba40b9a8b073e351c362522c46aa6
>>
>> execve("/usr/bin/git", ["git", "diff",
>> "038179704f0066aa815d5429221cf381ff4ef289\357\273\277",
>> "47346a462d8ba40b9a8b073e351c362522c46aa6"], 0x7fffec3c4bb0 /* 80 vars
>> */) = 0
>>
>> fatal: ambiguous argument '038179704f0066aa815d5429221cf381ff4ef289':
>> unknown revision or path not in the working tree.
>> Use '--' to separate paths from revisions, like this:
>> 'git <command> [<revision>...] -- [<file>...]'
>> +++ exited with 128 +++
> 
> Feature request:
> ================
> 
> When printing the "fatal: ambiguous argument '......': ....", perhaps
> escape (url or otherwise) the ambiguous argument when printing it in the
> error message, or maybe add a sentence about non-ASCII characters being
> found.
That's not going to fly, IMHO, because when I type
   git diff todo/René
I would not want to see
fatal: ambiguous argument 'todo/Ren\303\251': unknown ...

I'm convinced that there are thousands of users who use non-ASCII branch and file names that they also frequently mis-type. They'd all be greeted with unintelligible nerdy gibberish.

I may be able to change my mind if ambiguous input (in the sense of "is not what it seems to be") leads to a security hazard that is unique to Git.

-- Hannes
Previous: CHNext: Thomas Guyot
Message 2 of 4 in “Feature request: better error messages when UTF-8 bites”
  1. CHJul 27, 2022
  2. Johannes SixtJul 28, 2022
  3. Thomas GuyotJul 28, 2022
  4. Torsten BögershausenJul 28, 2022

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.