summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2013-07-11 01:11:12 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2014-02-12 23:00:36 +0100
commit5a51779e845004c7b0b81bb1ab2fd0be1cb69595 (patch)
tree3fbd76c376be301524347fa418d586e21bbfa8db /org.eclipse.jgit
parentb434241e733443a414808b2d1b8397142749aa44 (diff)
downloadjgit-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')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java22
3 files changed, 30 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
index 8dc8276b3f..8d2cb1d8cd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
@@ -163,8 +163,9 @@ public class FileTreeIterator extends WorkingTreeIterator {
* @param fs
* file system
*/
- public FileEntry(final File f, FS fs) {
+ public FileEntry(File f, FS fs) {
this.fs = fs;
+ f = fs.normalize(f);
attributes = fs.getAttributes(f);
if (attributes.isSymbolicLink())
mode = FileMode.SYMLINK;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
index b57176b481..633865ed4d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -921,8 +921,8 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
return false;
} else {
if (mode == FileMode.SYMLINK.getBits())
- return !new File(readContentAsString(current()))
- .equals(new File(readContentAsString(entry)));
+ return !new File(readContentAsNormalizedString(current()))
+ .equals(new File((readContentAsNormalizedString(entry))));
// Content differs: that's a real change, perhaps
if (reader == null) // deprecated use, do no further checks
return true;
@@ -971,19 +971,19 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
}
}
- private String readContentAsString(DirCacheEntry entry)
+ private String readContentAsNormalizedString(DirCacheEntry entry)
throws MissingObjectException, IOException {
ObjectLoader open = repository.open(entry.getObjectId());
byte[] cachedBytes = open.getCachedBytes();
- return RawParseUtils.decode(cachedBytes);
+ return FS.detect().normalize(RawParseUtils.decode(cachedBytes));
}
- private static String readContentAsString(Entry entry) throws IOException {
+ private static String readContentAsNormalizedString(Entry entry) throws IOException {
long length = entry.getLength();
byte[] content = new byte[(int) length];
InputStream is = entry.openInputStream();
IO.readFully(is, content, 0, (int) length);
- return RawParseUtils.decode(content);
+ return FS.detect().normalize(RawParseUtils.decode(content));
}
private long computeLength(InputStream in) throws IOException {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index 9e964fc363..dcece62894 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -780,4 +780,26 @@ public abstract class FS {
return new Attributes(this, path, exists, isDirectory, canExecute,
isSymlink, isFile, createTime, lastModified, -1);
}
+
+ /**
+ * Normalize the unicode path to composed form.
+ *
+ * @param file
+ * @return NFC-format File
+ * @since 3.3
+ */
+ public File normalize(File file) {
+ return file;
+ }
+
+ /**
+ * Normalize the unicode path to composed form.
+ *
+ * @param name
+ * @return NFC-format string
+ * @since 3.3
+ */
+ public String normalize(String name) {
+ return name;
+ }
}