summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java38
2 files changed, 34 insertions, 9 deletions
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 50b77fec8e..9c5a1e32d3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -1356,7 +1356,7 @@ public abstract class FS {
String v;
try {
v = readPipe(gitExe.getParentFile(),
- new String[] { "git", "--version" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { gitExe.getPath(), "--version" }, //$NON-NLS-1$
Charset.defaultCharset().name());
} catch (CommandFailedException e) {
LOG.warn(e.getMessage());
@@ -1375,7 +1375,8 @@ public abstract class FS {
String w;
try {
w = readPipe(gitExe.getParentFile(),
- new String[] { "git", "config", "--system", "--edit" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { gitExe.getPath(), "config", "--system", //$NON-NLS-1$ //$NON-NLS-2$
+ "--edit" }, //$NON-NLS-1$
Charset.defaultCharset().name(), env);
} catch (CommandFailedException e) {
LOG.warn(e.getMessage());
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 c9d2770b18..fb63dc02bb 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
@@ -54,6 +54,8 @@ import org.slf4j.LoggerFactory;
public class FS_POSIX extends FS {
private static final Logger LOG = LoggerFactory.getLogger(FS_POSIX.class);
+ private static final String DEFAULT_GIT_LOCATION = "/usr/bin/git"; //$NON-NLS-1$
+
private static final int DEFAULT_UMASK = 0022;
private volatile int umask = -1;
@@ -138,24 +140,46 @@ public class FS_POSIX extends FS {
String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$
File gitExe = searchPath(path, "git"); //$NON-NLS-1$
- if (gitExe == null) {
- if (SystemReader.getInstance().isMacOS()) {
+ if (SystemReader.getInstance().isMacOS()) {
+ if (gitExe == null
+ || DEFAULT_GIT_LOCATION.equals(gitExe.getPath())) {
if (searchPath(path, "bash") != null) { //$NON-NLS-1$
// 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.
- String w;
try {
- w = readPipe(userHome(),
+ String w = readPipe(userHome(),
new String[]{"bash", "--login", "-c", "which git"}, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Charset.defaultCharset().name());
+ if (!StringUtils.isEmptyOrNull(w)) {
+ gitExe = new File(w);
+ }
} catch (CommandFailedException e) {
LOG.warn(e.getMessage());
- return null;
}
- if (!StringUtils.isEmptyOrNull(w)) {
- gitExe = new File(w);
+ }
+ }
+ if (gitExe != null
+ && DEFAULT_GIT_LOCATION.equals(gitExe.getPath())) {
+ // If we still have the default git exe, it's an XCode wrapper
+ // that may prompt the user to install the XCode command line
+ // tools if not already present. Avoid the prompt by returning
+ // null if no XCode git is there.
+ try {
+ String w = readPipe(userHome(),
+ new String[] { "xcode-select", "-p" }, //$NON-NLS-1$ //$NON-NLS-2$
+ Charset.defaultCharset().name());
+ if (StringUtils.isEmptyOrNull(w)) {
+ gitExe = null;
+ } else {
+ File realGitExe = new File(new File(w),
+ DEFAULT_GIT_LOCATION.substring(1));
+ if (!realGitExe.exists()) {
+ gitExe = null;
+ }
}
+ } catch (CommandFailedException e) {
+ gitExe = null;
}
}
}