Browse Source

Merge "Refactor detection of OS X to SystemReader"

tags/v2.1.0.201209190230-r
Matthias Sohn 11 years ago
parent
commit
d0433a9bab

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java View File

private static boolean isValidPathSegment(CanonicalTreeParser t) { private static boolean isValidPathSegment(CanonicalTreeParser t) {
String osName = SystemReader.getInstance().getProperty("os.name"); String osName = SystemReader.getInstance().getProperty("os.name");
boolean isWindows = "Windows".equals(osName); boolean isWindows = "Windows".equals(osName);
boolean isOSX = "Darwin".equals(osName) || "Mac OS X".equals(osName);
boolean isOSX = SystemReader.getInstance().isMacOS();
boolean ignCase = isOSX || isWindows; boolean ignCase = isOSX || isWindows;


int ptr = t.getNameOffset(); int ptr = t.getNameOffset();

+ 2
- 17
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java View File



import java.io.File; import java.io.File;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
if (gitExe != null) if (gitExe != null)
return gitExe.getParentFile().getParentFile(); return gitExe.getParentFile().getParentFile();


if (isMacOS()) {
if (SystemReader.getInstance().isMacOS()) {
// On MacOSX, PATH is shorter when Eclipse is launched from the // On MacOSX, PATH is shorter when Eclipse is launched from the
// Finder than from a terminal. Therefore try to launch bash as a // Finder than from a terminal. Therefore try to launch bash as a
// login shell and search using that. // login shell and search using that.


@Override @Override
public boolean isCaseSensitive() { public boolean isCaseSensitive() {
if (isMacOS())
return false;
else
return true;
return !SystemReader.getInstance().isMacOS();
} }


@Override @Override
proc.command(argv); proc.command(argv);
return proc; 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);
}
} }

+ 15
- 0
org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java View File

import java.io.File; import java.io.File;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale; import java.util.Locale;
return DateFormat.getDateTimeInstance(dateStyle, timeStyle); 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);
}

} }

Loading…
Cancel
Save