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

Re: [PATCH] Use FIX_UTF8_MAC to enable conversion from UTF8-MAC to UTF8

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jan 22, 2008, 07:16 UTC
Message-ID
<alpine.LFD.1.00.0801212304460.2957@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.1.00.0801212025050.2957@woody.linux-foundation.org>
On Mon, 21 Jan 2008, Linus Torvalds wrote:
Show 14 quoted lines
> 
> I do suspect that if you really want to make this portable, and able to 
> handle an expanding d_name[] too, I think you need to make sure you 
> allocate a big-enough one. And if you worry about d_name perhaps being a 
> pointer, that really does mean that you'd need to convert the 
> system-supplied "struct dirent" into a "git_dirent_t" that you can 
> control.
> 
> That said, I think this patch has a bigger problem, namely just 
> fundamentally that
> 
> 	char *utf8 = reencode_string(entry, "UTF8", "UTF8-MAC");
> 
> is just unbelievably slow. That's just not how it should be done.

Having thought about this some more, I'm starting to suspect that the "readdir()" wrapper thing won't work very well.

Yes, it will work on OS X, but for all the wrong reasons. It works there just because of the stupid normalization that OS X does both on filename input and output, so if we hook into readdir() and munge the name there, we'll still be able to use the munged name for lstat() and open().

However, we'll never be able to test it on a sane Unix system, and it won't ever be able to handle the case of a filesystem actually being Latin1 but git being asked to try to transparently convert it to utf-8 in order to work with others.

Because most of those readdir() calls will just be fed back not just to the filesystem as lstat() calls later, but also to the recursive directory traversal itself, so if we munge the name, we're also going to screw name lookup.

Again, as an OSX-only workaround it's probably acceptable, and perhaps that's the only thing to look at right now. But it does strike me as a design mistake to do it at that level.

It would be conceptually nicer to do it in "add_file_to_index()" instead. Ie anything that creates a "struct cache_entry" would do the conversion.

So it would be good if somebody looked at what happens if you do the OSX hack in add_file_to_index() instead, and see if it works there..

		Linus
Previous: Linus TorvaldsNext: Junio C Hamano
Message 11 of 22 in “Use FIX_UTF8_MAC to enable conversion from UTF8-MAC to UTF8”
  1. Use FIX_UTF8_MAC to enable conversion from UTF8-MAC to UTF8Mark Junker, Jan 21, 2008
  2. Mark JunkerJan 21, 2008
  3. Mark JunkerJan 21, 2008
  4. Mark JunkerJan 21, 2008
  5. Junio C HamanoJan 21, 2008
  6. Mark JunkerJan 21, 2008
  7. Junio C HamanoJan 21, 2008
  8. Mark JunkerJan 21, 2008
  9. H. Peter AnvinJan 22, 2008
  10. Linus TorvaldsJan 22, 2008
  11. Linus TorvaldsJan 22, 2008
  12. Junio C HamanoJan 22, 2008
  13. Robin RosenbergJan 22, 2008
  14. Dmitry PotapovJan 22, 2008
  15. Dmitry PotapovJan 22, 2008
  16. Nicolas PitreJan 22, 2008
  17. Linus TorvaldsJan 22, 2008
  18. Johannes SchindelinJan 21, 2008
  19. Junio C HamanoJan 21, 2008
  20. Mark JunkerJan 21, 2008
  21. Johannes SchindelinJan 21, 2008
  22. Johannes SchindelinJan 21, 2008

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.