diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-07-11 01:11:12 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-02-12 23:00:36 +0100 |
commit | 5a51779e845004c7b0b81bb1ab2fd0be1cb69595 (patch) | |
tree | 3fbd76c376be301524347fa418d586e21bbfa8db /org.eclipse.jgit.java7 | |
parent | b434241e733443a414808b2d1b8397142749aa44 (diff) | |
download | jgit-5a51779e845004c7b0b81bb1ab2fd0be1cb69595.tar.gz jgit-5a51779e845004c7b0b81bb1ab2fd0be1cb69595.zip |
Normalize paths on OS X
Java normalizes paths to NFC, but other source may not, e.g Eclipse.
Bug: 413390
Change-Id: I08649ac58c9b3cb8bf12794703e4137b1b4e94d5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.java7')
-rw-r--r-- | org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java | 16 | ||||
-rw-r--r-- | org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FileUtil.java | 20 |
2 files changed, 36 insertions, 0 deletions
diff --git a/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java b/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java index e8307fc2b0..0879e8021f 100644 --- a/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java +++ b/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java @@ -156,4 +156,20 @@ public class FS_POSIX_Java7 extends FS_POSIX { public Attributes getAttributes(File path) { return FileUtil.getFileAttributesPosix(this, path); } + + /** + * @since 3.3 + */ + @Override + public File normalize(File file) { + return FileUtil.normalize(file); + } + + /** + * @since 3.3 + */ + @Override + public String normalize(String name) { + return FileUtil.normalize(name); + } } diff --git a/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FileUtil.java b/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FileUtil.java index 78dc2c3934..c958494d04 100644 --- a/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FileUtil.java +++ b/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FileUtil.java @@ -222,4 +222,24 @@ class FileUtil { } } + public static File normalize(File file) { + if (SystemReader.getInstance().isMacOS()) { + // TODO: Would it be faster to check with isNormalized first + // assuming normalized paths are much more common + String normalized = Normalizer.normalize(file.getPath(), + Normalizer.Form.NFC); + return new File(normalized); + } + return file; + } + + public static String normalize(String name) { + if (SystemReader.getInstance().isMacOS()) { + if (name == null) + return null; + return Normalizer.normalize(name, Normalizer.Form.NFC); + } + return name; + } + } |