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

Re: [BUG REPORT] File names that contain UTF8 characters are unnecessarily escaped in 'git status .' messages

From
Jeff King <peff@peff.net>
Date
May 30, 2021, 21:44 UTC
Message-ID
<YLQHPu0bIy4qHEWP@coredump.intra.peff.net>
In-Reply-To
<20210529092752.kifzqt3haddzgsob@tb-raspi4>
On Sat, May 29, 2021 at 11:27:52AM +0200, Torsten Bögershausen wrote:
> I am not sure that there is a reliable way for Git to detect, if the
> terminal is capable of handling UTF-8.
> This should work reliable under Linux, Windows, Mac and all the supported
> Unix-ish platforms.

Yeah, I'm not sure how such a check would be done. On most Linux systems I've seen, $LANG will mention "en_US.UTF-8" or similar. But I've no idea how portable that convention is, not to mention that people may have more complex setups anyway (e.g., not setting $LANG but setting some of LC_*).

But more importantly, this is not even a UTF-8 problem. It is "can your terminal do something sensible with high-bit characters in filenames of your repositories". We don't know the encoding of those filenames (and you may even have a mix).

(And likewise "terminal" here is really "whatever consumes Git's output, be it the terminal or some program you've piped to).

Show 5 quoted lines
> Having said that, the default could be switched some day in the future.
> Before that is "save", there may be a transition phase,
> where users are warned that the default may change.
> Scripts calling git need to use `git -c core.quotepath=yes`, or no,
> whatever input they expect.

Yes. If we're going to do anything, I think it would be to say "most terminals and programs deal with high-bit characters OK these days, so switching the default is more likely to fix things than break them".

I suspect most scripts would be OK either way. They need to handle maybe-quoted filenames already, so it is really just a question of whether the consuming program is OK with the high bits. If so, we could probably get away with just a mention in the release notes, rather than an annoying transition phase (which is likely to simply confuse most users, who are unaware of the issue entirely).

But I'd feel more confident if whoever proposes such a change does some research on how piping such names into common tools and scripting languages works (both for utf8 and non-utf8 names).

-Peff
Previous: Torsten BögershausenNext: Yuri
Message 10 of 14 in “[BUG REPORT] File names that contain UTF8 characters are unnecessarily escaped in 'git status .' messages”
  1. YuriMay 26, 2021
  2. Junio C HamanoMay 26, 2021
  3. YuriMay 26, 2021
  4. Torsten BögershausenMay 27, 2021
  5. Jeff KingMay 27, 2021
  6. YuriMay 27, 2021
  7. Bagas SanjayaMay 28, 2021
  8. YuriMay 28, 2021
  9. Torsten BögershausenMay 29, 2021
  10. Jeff KingMay 30, 2021
  11. YuriMay 30, 2021
  12. Thomas GuyotMay 31, 2021
  13. Bagas SanjayaMay 31, 2021
  14. Junio C HamanoMay 30, 2021

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.