Skip to contentSkip to conversation

OS X and umlauts in file names

DISCUSSION Thomas Singer 9 participants 20 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I'm on an English OS X 10.6.2 and I created a sample file with umlauts in its name (Überlänge.txt). When I try to stage the file in the terminal, I can't complete the file name by typing the Ü and hitting the tab key, but I can complete it by typing an U and hitting the tab key. Unfortunately, after executing

git stage Überlänge.txt

I invoked

git status

and it still shows the file as new file. Should I set some environment variable to be able to work with files containing umlauts in the name?

Thanks in advance,
Tom

#1 lore raw
Quoted 7 lines · Thomas Singer

I'm on an English OS X 10.6.2 and I created a sample file with umlauts in its name (Überlänge.txt). When I try to stage the file in the terminal, I can't complete the file name by typing the Ü and hitting the tab key, but I can complete it by typing an U and hitting the tab key. Unfortunately, after executing

git stage Überlänge.txt

This is because of OS X's unicode normalisation. Try any of the many threads on the topic, e.g.,

http://thread.gmane.org/gmane.comp.version-control.git/70688

The short version is that this Ü is in fact decomposed into an U-umlaut duo.

Considering that this leads to endless fun[*] not just with git, and that we German speakers have an easy way out (Ueberlaenge), I can only suggest that you avoid umlauts wherever possible to preserve the sanity of your users.

[*] I once had an SVN repo with two different directories both called Übungen. Took me a while to figure out what was going on.

Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.ch
#2 lore raw

Hi Thomas,

Thanks for the feed-back. I know the problem from SVN, too, but I had the hope, that Git was smarter than SVN for this topic. IIRC, one could get SVN working "somehow" with umlauts on OS X by setting some environment variable. Unfortunately, I don't remember the details any more.

Basically, getting it "somehow" to work on OS X is just one minor step. IMHO Git should standardize on file names in the repository and do the platform-specific conversion independent of any locale setting, if needed. Then and only then it would be possible to get the same characters out of the repository, no matter whether the file was added or checked out on OS X, Linux or Windows.

At the moment we've got a problem report regarding our SmartGit GUI client:
the user says, on command line it[1] works (German OS X) but not with SmartGit, for me it doesn't even work on the command line (English OS X). As you may know, Java uses characters for file names, the Java runtime internally converts from the platform-specific byte-representation on disk to characters. I can't simply tunnel the file name as byte array to the invoked Git command - I simply don't know how to transform the characters of the file name to a representation the Git command line client will understand[2].

Tom

[1] e.g. to stage or commit files with umlauts in the file name
[2] executing an external command in Java also "only" works with strings (aka characters), not with byte sequences

Quoted 26 lines · Thomas Rast
Quoted 7 lines · Thomas Singer

I'm on an English OS X 10.6.2 and I created a sample file with umlauts in its name (Überlänge.txt). When I try to stage the file in the terminal, I can't complete the file name by typing the Ü and hitting the tab key, but I can complete it by typing an U and hitting the tab key. Unfortunately, after executing

git stage Überlänge.txt

This is because of OS X's unicode normalisation. Try any of the many threads on the topic, e.g.,

http://thread.gmane.org/gmane.comp.version-control.git/70688

The short version is that this Ü is in fact decomposed into an U-umlaut duo.

Considering that this leads to endless fun[*] not just with git, and that we German speakers have an easy way out (Ueberlaenge), I can only suggest that you avoid umlauts wherever possible to preserve the sanity of your users.

[*] I once had an SVN repo with two different directories both called Übungen. Took me a while to figure out what was going on.

#3 lore raw
Quoted 4 lines · Thomas Singer

I can't simply tunnel the file name as byte array to the
invoked Git command - I simply don't know how to transform the characters of the file name to a representation the Git command line client will understand[2].

Ouch - so git is respecting whatever name the user and/or OS have picked, but Java wants to canonicalize it, and whatever scheme it uses does not match OSX? That must hurt Java usage on OSX a lot. Sure they have a workaround...?

Suggestions:

1 - Configure Java to canonicalize in the same style as OSX. Actually, OSX's canonicalization is somewhat arbitrary so I think it exposes a call to canonicalize a string "the right way".

2 - Many git calls accept filenames via STDIN - Java will surely write binary there...

3 - xargs with its -z parameter can complement #2

hth,

m

Signature · 5 lines
 [email protected]
 [email protected] -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
#4 lore raw
In reply to Thomas Singer

Hi,

Quoted 4 lines · Thomas Singer

Basically, getting it "somehow" to work on OS X is just one minor step. IMHO Git should standardize on file names in the repository and do the platform-specific conversion independent of any locale setting, if needed.

That is contrary to the design of Git which honors content (byte-wise!) as much as possible, and treats file names very much as content.

There were beginnings of supporting OSX' brain-damaged filename mangling, but an obnoxious OSX fan worked very hard on trying to defend the OSX design and to decry Git's respect for the raw bytes on this list, so hard that even the nicest developers had no fun working on this issue anymore.

This little background may help you understand why there is no solution implemented in Git yet. And maybe quite a few developers are reluctant to discuss the issue and possible solutions due to said sad story, too.

Ciao,
Dscho

#5 lore raw

I agree, that getting it done correctly could be a long and hard (maybe incompatible) way. Neglecting the problem or blaming platform specific "anomalies" does not help to solve that serious real-world problem for the end-user. IMHO, telling a user to not use non-US-ASCII characters in file names to stay platform-independent seems not to be state-of-the-art and would exclude a lot of users world-wide. Finally, everyone would expect Git to be better than CVS, also at this point.

But what about getting it working "somehow" on OS X in a few minutes? What should I do to be able to stage/commit/work with files containing umlauts in their name on my English OS X (by specifying the file names) as it seems to work magically on a German OS X? Is this topic already /documented/ somewhere (I couldn't find something)?

Thanks in advance,
Tom

Quoted 29 lines · Johannes Schindelin

Hi,

Quoted 4 lines · Thomas Singer

Basically, getting it "somehow" to work on OS X is just one minor step. IMHO Git should standardize on file names in the repository and do the platform-specific conversion independent of any locale setting, if needed.

That is contrary to the design of Git which honors content (byte-wise!) as much as possible, and treats file names very much as content.

There were beginnings of supporting OSX' brain-damaged filename mangling, but an obnoxious OSX fan worked very hard on trying to defend the OSX design and to decry Git's respect for the raw bytes on this list, so hard that even the nicest developers had no fun working on this issue anymore.

This little background may help you understand why there is no solution implemented in Git yet. And maybe quite a few developers are reluctant to discuss the issue and possible solutions due to said sad story, too.

Ciao,
Dscho
--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to Johannes Schindelin
Quoted 10 lines · Johannes Schindelin
Quoted 4 lines · Thomas Singer

Basically, getting it "somehow" to work on OS X is just one minor step. IMHO Git should standardize on file names in the repository and do the platform-specific conversion independent of any locale setting, if needed.

That is contrary to the design of Git which honors content (byte-wise!) as much as possible, and treats file names very much as content.

Quoted 8 lines

There were beginnings of supporting OSX' brain-damaged filename mangling, but an obnoxious OSX fan worked very hard on trying to defend the OSX design and to decry Git's respect for the raw bytes on this list, so hard that even the nicest developers had no fun working on this issue anymore.

This little background may help you understand why there is no solution implemented in Git yet. And maybe quite a few developers are reluctant to discuss the issue and possible solutions due to said sad story, too.

To be more exact the problem is not that MacOS X uses denormalized form (does file mangling). This would be the problem only in cross-platform development (where some developers would work from different operating system).

The problem is that the name under which Git creates file is different from the name MacOS X lists file (in readdir etc.).

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#7 lore raw
In reply to Thomas Singer
Quoted 4 lines · Thomas Singer

I'm on an English OS X 10.6.2 and I created a sample file with umlauts in its name (Überlänge.txt). When I try to stage the file in the terminal, I can't complete the file name by typing the Ü and hitting the tab key, but I can complete it by typing an U and hitting the tab key.

You've already got a bug before involving git at all. You create a file "Überlänge.txt", but OS X writes "U:berla:nge.txt" (typing the combining character umlaut as : so that you can see the difference), and the directory listing doesn't contain any files that start with Ü, so the terminal already can't find the file you created. Obviously, git is going to have all the problems that the OS-provided readline library has, and you're not going to be able to get predictable results in any case where user-supplied filenames are compared with directory listings.

Part of the problem is that OS X does a canonicalization that is not what anybody else does, so you hit the problem every single time, but the fundamental issue is that there isn't any way to tell, when you create a file, what name that file will be listed under.

Note that this isn't a matter of characters to byte sequences. OS X actually uses different characters for the filename in its listings than you've used.

If there's a difference between German and English versions, I suspect that it's actually that you're not using a German keyboard with a key that, under OS X, produces the two-character sequence U:, but using some method that produces the single character Ü. I'd guess that your SmartGit problem is that Java is converting the U: that the user typed into Ü, and passing it to the OS, which turns it back into U: and then doesn't list the file that Java thinks the user asked for.

-Daniel
*This .sig left intentionally blank*

#8 lore raw

I've did following:

toms-mac-mini:git-umlauts tom$ ls
Überlänge.txt
toms-mac-mini:git-umlauts tom$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: "U\314\210berla\314\210nge.txt"
#
toms-mac-mini:git-umlauts tom$ git stage "U\314\210berla\314\210nge.txt"
fatal: pathspec 'U\314\210berla\314\210nge.txt' did not match any files

Note, that I copy-pasted the file name which 'git status' showed to the stage command. IMHO, this should work, especially, because different people said Git would treat the file name as byte-array without interpreting it in some kind.

From the user with the German OS X (for which the staging is said to work), I've got the output of 'env' and hence also tried

export LANG=de_DE.UTF-8

before doing the above steps, but with the same results. :(

Signature · 1 line
Tom
Quoted 35 lines · Daniel Barkalow
Quoted 4 lines · Thomas Singer

I'm on an English OS X 10.6.2 and I created a sample file with umlauts in its name (Überlänge.txt). When I try to stage the file in the terminal, I can't complete the file name by typing the Ü and hitting the tab key, but I can complete it by typing an U and hitting the tab key.

You've already got a bug before involving git at all. You create a file "Überlänge.txt", but OS X writes "U:berla:nge.txt" (typing the combining character umlaut as : so that you can see the difference), and the directory listing doesn't contain any files that start with Ü, so the terminal already can't find the file you created. Obviously, git is going to have all the problems that the OS-provided readline library has, and you're not going to be able to get predictable results in any case where user-supplied filenames are compared with directory listings.

Part of the problem is that OS X does a canonicalization that is not what anybody else does, so you hit the problem every single time, but the fundamental issue is that there isn't any way to tell, when you create a file, what name that file will be listed under.

Note that this isn't a matter of characters to byte sequences. OS X actually uses different characters for the filename in its listings than you've used.

If there's a difference between German and English versions, I suspect that it's actually that you're not using a German keyboard with a key that, under OS X, produces the two-character sequence U:, but using some method that produces the single character Ü. I'd guess that your SmartGit problem is that Java is converting the U: that the user typed into Ü, and passing it to the OS, which turns it back into U: and then doesn't list the file that Java thinks the user asked for.

-Daniel
*This .sig left intentionally blank*

#9 lore raw
Quoted 22 lines · Thomas Singer

I've did following:

 toms-mac-mini:git-umlauts tom$ ls
 Überlänge.txt
 toms-mac-mini:git-umlauts tom$ git status
 # On branch master
 #
 # Initial commit
 #
 # Changes to be committed:
 #   (use "git rm --cached <file>..." to unstage)
 #
 #     new file:   "U\314\210berla\314\210nge.txt"
 #
 toms-mac-mini:git-umlauts tom$ git stage "U\314\210berla\314\210nge.txt"
 fatal: pathspec 'U\314\210berla\314\210nge.txt' did not match any files

Note, that I copy-pasted the file name which 'git status' showed to the stage command. IMHO, this should work, especially, because different people said Git would treat the file name as byte-array without interpreting it in some kind.

Quoted 6 lines

From the user with the German OS X (for which the staging is said to work), I've got the output of 'env' and hence also tried

 export LANG=de_DE.UTF-8

before doing the above steps, but with the same results. :(

The problem you are having is not because of the *encoding*, it's the Normalization form that's messing things up. The fact is that in Unicode there are two ways to represent many -- but not all -- accented characters.

- "composed": one code point for the accented character)
- "decomposed": two code points: one for the base letter, one or more combining characters for the accents.

The composed code points are really just backward compatibility to legacy encodings (like LATIN-1). If you want to actually support (rather than just tolerate) unicode you have to know how to deal with the decomposed form, and once you can do that there's little point beyond backward compatibility in continuing to use composed form internally.

The Subversion people have run into this same problem because they made the same error of assuming that any given sequence of glyphs has only one possible representation as unicode code points and thus only one representation as UTF-8 bytes. Dionisos has done written up the issues involved here:

http://svn.apache.org/repos/asf/subversion/trunk/notes/unicode-composition-for-filenames

// Ben

#10 lore raw
In reply to Thomas Singer
Quoted 2 lines · Thomas Singer

 toms-mac-mini:git-umlauts tom$ git stage "U\314\210berla\314\210nge.txt"
 fatal: pathspec 'U\314\210berla\314\210nge.txt' did not match any files

does a find * | xargs git add work?

cheers,

m

Signature · 5 lines
 [email protected]
 [email protected] -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
#11 lore raw
Quoted 6 lines · Martin Langhoff
Quoted 2 lines · Thomas Singer

 toms-mac-mini:git-umlauts tom$ git stage "U\314\210berla\314\210nge.txt"
 fatal: pathspec 'U\314\210berla\314\210nge.txt' did not match any files

does a find * | xargs git add work?

Also, you can try with find * -print0 | git-update-index --add --stdin -z . Find should report the exact filename that the OS has, and git should add it as it is.

Background: git-add used to be a trivial shell script wrapping around git-update-index. If you have a git checkout, try:

git show f25933987f29070e9cd79dfddf03018010e82e80:git-add.sh

If git cannot track this file in a pure OSX world, there is a good chance it's a bug in git.

In in this narrow test case (single machine, running OSX) git *must* be able to do the right thing. If you work on multi-platform projects however, there is a good chance a Windows or Linux user will commit a file with a name that _when you checkout on OSX_, OSX will save with a different (but "equivalent") name due to its funny decomposition rules. And all sorts of "fun" will ensue.

cheers,

m

Signature · 5 lines
 [email protected]
 [email protected] -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
#12 lore raw
In reply to Thomas Singer
Quoted 14 lines · Thomas Singer

I've did following:

 toms-mac-mini:git-umlauts tom$ ls Überlänge.txt
 toms-mac-mini:git-umlauts tom$ git status # On branch master
 #
 # Initial commit
 #
 # Changes to be committed:
 #   (use "git rm --cached <file>..." to unstage) #
 #     new file:   "U\314\210berla\314\210nge.txt" #

Wait, what's the problem here? It's staged according to the above, just commit it.

j.

#17 lore raw
In reply to Thomas Singer
Quoted 16 lines · Thomas Singer

I've did following:

toms-mac-mini:git-umlauts tom$ ls
Überlänge.txt
toms-mac-mini:git-umlauts tom$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: "U\314\210berla\314\210nge.txt"
#
toms-mac-mini:git-umlauts tom$ git stage "U\314\210berla\314\210nge.txt"
fatal: pathspec 'U\314\210berla\314\210nge.txt' did not match any files

Try $'U\314\210berla\314\210nge.txt' instead.
"U\314\210berla\314\210nge.txt" is the same as
"U\\314\\210berla\\314\\210nge.txt" to the shell.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#18 lore raw

Hi Andreas,

Thank you for this hint. When trying

toms-mac-mini:git-umlauts tom$ git stage $'U\314\210berla\314\210nge.txt'

git shows me no error or other output, but invoking 'git status' again shows no difference, the file is still showing up as new file.

I've also tried to use double backslashes, but I could not enter a backslash in the OS X Terminal (works fine in other applications). :(

Signature · 1 line
Tom
Quoted 25 lines · Andreas Schwab
Quoted 16 lines · Thomas Singer

I've did following:

toms-mac-mini:git-umlauts tom$ ls
Überlänge.txt
toms-mac-mini:git-umlauts tom$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: "U\314\210berla\314\210nge.txt"
#
toms-mac-mini:git-umlauts tom$ git stage "U\314\210berla\314\210nge.txt"
fatal: pathspec 'U\314\210berla\314\210nge.txt' did not match any files

Try $'U\314\210berla\314\210nge.txt' instead.
"U\314\210berla\314\210nge.txt" is the same as
"U\\314\\210berla\\314\\210nge.txt" to the shell.

Andreas.

#19 lore raw
In reply to Thomas Singer
Quoted 6 lines · Thomas Singer

I'm on an English OS X 10.6.2 and I created a sample file with umlauts in its name (Überlänge.txt). When I try to stage the file in the terminal, I can't complete the file name by typing the Ü and hitting the tab key, but I can complete it by typing an U and hitting the tab key. Unfortunately, after executing

Quoted 8 lines

 git stage Überlänge.txt

I invoked

 git status

and it still shows the file as new file. Should I set some environment variable to be able to work with files containing umlauts in the name?

Works for me on 10.6.2:

kore:~/foo (master)$ echo Überlänge.txt > Überlänge.txt kore:~/foo (master)$ git stage Überlänge.txt kore:~/foo (master)$ git st
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: "U\314\210berla\314\210nge.txt"
#
kore:~/foo (master)$ git commit -m initial [master (root-commit) f23e23f] initial

 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 "U\314\210berla\314\210nge.txt"

kore:~/foo (master)$ git st
# On branch master
nothing to commit (working directory clean)

Doesn't matter whether LANG and/or LC_* are set or not for me.

j.

#13 lore raw
In reply to Jay Soffian
Quoted 11 lines · Jay Soffian
Quoted 10 lines

toms-mac-mini:git-umlauts tom$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: "U\314\210berla\314\210nge.txt"
#

Quoted 2 lines

Wait, what's the problem here? It's staged according to the above, just commit it.

You are completely right and I feel quite foolish.

What about this one:

toms-mac-mini:git-umlauts tom$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: "U\314\210berla\314\210nge.txt"
#
toms-mac-mini:git-umlauts tom$ git rm --cached "U\314\210berla\314\210nge.txt"
fatal: pathspec 'U\314\210berla\314\210nge.txt' did not match any files

Signature · 2 lines
Thanks in advance,
Tom
#14 lore raw
Quoted 18 lines · Thomas Singer
Quoted 10 lines · Jay Soffian
Quoted 10 lines

toms-mac-mini:git-umlauts tom$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: "U\314\210berla\314\210nge.txt"
#

Quoted 2 lines

Wait, what's the problem here? It's staged according to the above, just commit it.

You are completely right and I feel quite foolish.

What about this one:

Quoted 12 lines

toms-mac-mini:git-umlauts tom$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: "U\314\210berla\314\210nge.txt"
#
toms-mac-mini:git-umlauts tom$ git rm --cached "U\314\210berla\314\210nge.txt"
fatal: pathspec 'U\314\210berla\314\210nge.txt' did not match any files

OK, I've found it. This works (I have to complete the file name after having typed an U):

toms-mac-mini:git-umlauts tom$ git rm --cached Überlänge.txt

Signature · 1 line
Tom
#15 lore raw
Quoted 7 lines · Thomas Singer
Quoted 2 lines

toms-mac-mini:git-umlauts tom$ git rm --cached "U\314\210berla\314\210nge.txt"
fatal: pathspec 'U\314\210berla\314\210nge.txt' did not match any files

OK, I've found it. This works (I have to complete the file name after having typed an U):

toms-mac-mini:git-umlauts tom$ git rm --cached Überlänge.txt

Tom,

have you tried calling git-update-index --add
--stdin -z? Your original email stated

Quoted 1 line

we've got a problem report regarding our SmartGit GUI client

so it sounds like you are building a porcelain. In that case, the sanest approach is to invoke git-update-index and write to its stdin.

cheers,

m

Signature · 5 lines
 [email protected]
 [email protected] -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
#16 lore raw
Quoted 2 lines · Martin Langhoff

have you tried calling git-update-index --add
--stdin -z? Your original email stated

No, we don't do such a massive change immediately before a release.

Quoted 4 lines
Quoted 1 line

we've got a problem report regarding our SmartGit GUI client

so it sounds like you are building a porcelain. In that case, the sanest approach is to invoke git-update-index and write to its stdin.

We will try this out after release.

For those who are interested: I've got it working on OS X and Git was not the problem, but Java. A longer time ago directory.list() or directory.listFiles() returned the file names with decomposed characters (as they are stored on OS X hard disk). Now (don't know which Java update introduced this change) these methods return file names with composed characters, so I had to decompose them before handing them to the git executable call.

Nevertheless, the cross-platform-problem remains: if you add files with umlauts in their names on non-OS X, you will not be able to use them on OS X.

Signature · 1 line
Tom