From e9c811d0d08a9c2c748311a13a86b481941a55ce Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Fri, 18 May 2012 16:52:50 +0200 Subject: [PATCH] Allow detection of case insensitive file systems Change-Id: I03f59d07bcc3338ef8d392cbd940799186ca03bd Signed-off-by: Matthias Sohn Signed-off-by: Christian Halstrick --- .../tst/org/eclipse/jgit/api/AddCommandTest.java | 10 ++++++++++ .../tst/org/eclipse/jgit/api/CommitCommandTest.java | 10 ++++++++++ org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 7 +++++++ .../src/org/eclipse/jgit/util/FS_POSIX.java | 8 ++++++++ .../src/org/eclipse/jgit/util/FS_Win32.java | 6 ++++++ 5 files changed, 41 insertions(+) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java index fd74098496..ab2027ce72 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java @@ -631,6 +631,11 @@ public class AddCommandTest extends RepositoryTestCase { public boolean canExecute(File f) { return true; } + + @Override + public boolean isCaseSensitive() { + return false; + } }; Git git = Git.open(db.getDirectory(), executableFs); @@ -671,6 +676,11 @@ public class AddCommandTest extends RepositoryTestCase { public boolean canExecute(File f) { return false; } + + @Override + public boolean isCaseSensitive() { + return false; + } }; config = db.getConfig(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java index e558d61782..20d62f5316 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java @@ -109,6 +109,11 @@ public class CommitCommandTest extends RepositoryTestCase { public boolean canExecute(File f) { return true; } + + @Override + public boolean isCaseSensitive() { + return true; + } }; Git git = Git.open(db.getDirectory(), executableFs); @@ -149,6 +154,11 @@ public class CommitCommandTest extends RepositoryTestCase { public boolean canExecute(File f) { return false; } + + @Override + public boolean isCaseSensitive() { + return true; + } }; config = db.getConfig(); 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 0dfa51187c..535d1cd26a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -135,6 +135,13 @@ public abstract class FS { */ public abstract boolean supportsExecute(); + /** + * Is this file system case sensitive + * + * @return true if this implementation is case sensitive + */ + public abstract boolean isCaseSensitive(); + /** * Determine if the file is executable (or not). *

diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java index f04bb6fe0c..36d3b9484a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java @@ -85,6 +85,14 @@ abstract class FS_POSIX extends FS { super(src); } + @Override + public boolean isCaseSensitive() { + if (isMacOS()) + return false; + else + return true; + } + @Override public ProcessBuilder runInShell(String cmd, String[] args) { List argv = new ArrayList(4 + args.length); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java index 58f7fb4bf8..3b6704497c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java @@ -53,6 +53,7 @@ import java.util.Arrays; import java.util.List; class FS_Win32 extends FS { + static boolean isWin32() { final String osDotName = AccessController .doPrivileged(new PrivilegedAction() { @@ -88,6 +89,11 @@ class FS_Win32 extends FS { return false; } + @Override + public boolean isCaseSensitive() { + return false; + } + @Override public boolean retryFailedLockFileCommit() { return true; -- 2.39.5