]> source.dussan.org Git - jgit.git/commitdiff
Fix broken git prefix detection 39/2939/3
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 27 Mar 2011 18:44:38 +0000 (20:44 +0200)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Mon, 28 Mar 2011 05:41:34 +0000 (07:41 +0200)
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=<path> to set the git prefix
manually.

Change-Id: I5a58ee45c2d2ae5322f87fd6972526169b2918c8
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java

index 5a48513b670c0627b2e9baf49b1f605adec23036..d3bfd6fce57ce24cbe7ac5fedde4043a8ca82699 100644 (file)
@@ -286,7 +286,9 @@ public abstract class FS {
                                }
                        }
                } 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 @@ public abstract class FS {
        public File gitPrefix() {
                Holder<File> p = gitPrefix;
                if (p == null) {
-                       p = new Holder<File>(discoverGitPrefix());
+                       String overrideGitPrefix = SystemReader.getInstance().getProperty(
+                                       "jgit.gitprefix");
+                       if (overrideGitPrefix != null)
+                               p = new Holder<File>(new File(overrideGitPrefix));
+                       else
+                               p = new Holder<File>(discoverGitPrefix());
                        gitPrefix = p;
                }
                return p.value;
index b441d2066fd00fa1a2d83b6b686181ececfba914..58f7fb4bf858f9f9a0f1f811a49e19d99b4a3d7f 100644 (file)
@@ -106,8 +106,12 @@ class FS_Win32 extends FS {
                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;
        }