summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2013-01-22 08:28:49 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2013-01-22 08:28:49 -0500
commit86759c23c2fa0c5cbbc82d224e72a7742423c8fb (patch)
treef40889f7ae35d12885fce5beef5e11236701d204
parent910a69d4c8a892a71f4ac1f8c54f7d91887001d5 (diff)
parent8315439401ffb725270c32ebd7d341f3cb26e27f (diff)
downloadjgit-86759c23c2fa0c5cbbc82d224e72a7742423c8fb.tar.gz
jgit-86759c23c2fa0c5cbbc82d224e72a7742423c8fb.zip
Merge "Fix NPE FS_Win32 when looking up git executable and home directory avoiding redundant code"
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java16
1 files changed, 13 insertions, 3 deletions
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 ce62628e85..73f9161ca3 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
@@ -90,7 +90,7 @@ class FS_Win32 extends FS {
String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$
File gitExe = searchPath(path, "git.exe", "git.cmd"); //$NON-NLS-1$ //$NON-NLS-2$
if (gitExe != null)
- return gitExe.getParentFile().getParentFile();
+ return resolveGrandparentFile(gitExe);
// This isn't likely to work, if bash is in $PATH, git should
// also be in $PATH. But its worth trying.
@@ -102,7 +102,16 @@ class FS_Win32 extends FS {
// 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 resolveGrandparentFile(gitExe);
+ }
+ return null;
+ }
+
+ private static File resolveGrandparentFile(File grandchild) {
+ if (grandchild != null) {
+ File parent = grandchild.getParentFile();
+ if (parent != null)
+ return parent.getParentFile();
}
return null;
}
@@ -115,7 +124,8 @@ class FS_Win32 extends FS {
String homeDrive = SystemReader.getInstance().getenv("HOMEDRIVE"); //$NON-NLS-1$
if (homeDrive != null) {
String homePath = SystemReader.getInstance().getenv("HOMEPATH"); //$NON-NLS-1$
- return new File(homeDrive, homePath);
+ if (homePath != null)
+ return new File(homeDrive, homePath);
}
String homeShare = SystemReader.getInstance().getenv("HOMESHARE"); //$NON-NLS-1$