From 76d25273cc6faf134898771db60fae4b9e27f5d9 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Sun, 27 Mar 2011 20:44:38 +0200 Subject: [PATCH] Fix broken git prefix detection If JGit got a cygwin path it would fail to resolve directories relative to it. Also add system property to debug problems with the FS utilities. Enable debug using -Djgit.fs.debug=1 Furthermore use -Djgit.gitprefix= to set the git prefix manually. Change-Id: I5a58ee45c2d2ae5322f87fd6972526169b2918c8 Signed-off-by: Robin Rosenberg --- org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 11 +++++++++-- .../src/org/eclipse/jgit/util/FS_Win32.java | 8 ++++++-- 2 files changed, 15 insertions(+), 4 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 5a48513b6..d3bfd6fce 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -286,7 +286,9 @@ protected static String readPipe(File dir, String[] command, String encoding) { } } } catch (IOException e) { - // ignore + if (SystemReader.getInstance().getProperty("jgit.fs.debug") != null) + System.err.println(e); + // Ignore error (but report) } return null; } @@ -295,7 +297,12 @@ protected static String readPipe(File dir, String[] command, String encoding) { public File gitPrefix() { Holder p = gitPrefix; if (p == null) { - p = new Holder(discoverGitPrefix()); + String overrideGitPrefix = SystemReader.getInstance().getProperty( + "jgit.gitprefix"); + if (overrideGitPrefix != null) + p = new Holder(new File(overrideGitPrefix)); + else + p = new Holder(discoverGitPrefix()); gitPrefix = p; } return p.value; 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 b441d2066..58f7fb4bf 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 @@ -106,8 +106,12 @@ protected File discoverGitPrefix() { String w = readPipe(userHome(), // new String[] { "bash", "--login", "-c", "which git" }, // Charset.defaultCharset().name()); - if (w != null) - return new File(w).getParentFile().getParentFile(); + if (w != null) { + // The path may be in cygwin/msys notation so resolve it right away + gitExe = resolve(null, w); + if (gitExe != null) + return gitExe.getParentFile().getParentFile(); + } return null; }