]> source.dussan.org Git - jgit.git/commitdiff
Refactor detection of OS X to SystemReader 15/7115/4
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Thu, 2 Aug 2012 22:46:39 +0000 (00:46 +0200)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Tue, 21 Aug 2012 22:36:09 +0000 (00:36 +0200)
Change-Id: I34e9ba4a26f7af5b88140c070f02a7990f1941af

org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java

index 6e417b33b3b4fcebfbce7ce12f86e8304ab7c58c..1d8c0d01b632d8de31d77605b7cdb6861e7eeaf5 100644 (file)
@@ -1024,7 +1024,7 @@ public class DirCacheCheckout {
        private static boolean isValidPathSegment(CanonicalTreeParser t) {
                String osName = SystemReader.getInstance().getProperty("os.name");
                boolean isWindows = "Windows".equals(osName);
-               boolean isOSX = "Darwin".equals(osName) || "Mac OS X".equals(osName);
+               boolean isOSX = SystemReader.getInstance().isMacOS();
                boolean ignCase = isOSX || isWindows;
 
                int ptr = t.getNameOffset();
index 36d3b9484a36b8da2e6ae599f766fcdbf78408c8..742afe1354cba151f0df6a329e9ed15d49874f87 100644 (file)
@@ -44,8 +44,6 @@ package org.eclipse.jgit.util;
 
 import java.io.File;
 import java.nio.charset.Charset;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -58,7 +56,7 @@ abstract class FS_POSIX extends FS {
                if (gitExe != null)
                        return gitExe.getParentFile().getParentFile();
 
-               if (isMacOS()) {
+               if (SystemReader.getInstance().isMacOS()) {
                        // On MacOSX, PATH is shorter when Eclipse is launched from the
                        // Finder than from a terminal. Therefore try to launch bash as a
                        // login shell and search using that.
@@ -87,10 +85,7 @@ abstract class FS_POSIX extends FS {
 
        @Override
        public boolean isCaseSensitive() {
-               if (isMacOS())
-                       return false;
-               else
-                       return true;
+               return !SystemReader.getInstance().isMacOS();
        }
 
        @Override
@@ -105,14 +100,4 @@ abstract class FS_POSIX extends FS {
                proc.command(argv);
                return proc;
        }
-
-       private static boolean isMacOS() {
-               final String osDotName = AccessController
-                               .doPrivileged(new PrivilegedAction<String>() {
-                                       public String run() {
-                                               return System.getProperty("os.name");
-                                       }
-                               });
-               return "Mac OS X".equals(osDotName) || "Darwin".equals(osDotName);
-       }
 }
index 4181a2fb296a9fdfcaf0b74323d2e79bb152b693..4298fbcf748570304aabe2d735aef92639af445e 100644 (file)
@@ -49,6 +49,8 @@ package org.eclipse.jgit.util;
 import java.io.File;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Locale;
@@ -237,4 +239,17 @@ public abstract class SystemReader {
                return DateFormat.getDateTimeInstance(dateStyle, timeStyle);
        }
 
+       /**
+        * @return true if we are running on Mac OS X
+        */
+       public boolean isMacOS() {
+               String osDotName = AccessController
+                               .doPrivileged(new PrivilegedAction<String>() {
+                                       public String run() {
+                                               return getProperty("os.name");
+                                       }
+                               });
+               return "Mac OS X".equals(osDotName) || "Darwin".equals(osDotName);
+       }
+
 }