Merge "Fix NPE FS_Win32 when looking up git executable and home directory avoiding redundant code"
This commit is contained in:
commit
86759c23c2
|
@ -90,7 +90,7 @@ protected File discoverGitPrefix() {
|
||||||
String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$
|
String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$
|
||||||
File gitExe = searchPath(path, "git.exe", "git.cmd"); //$NON-NLS-1$ //$NON-NLS-2$
|
File gitExe = searchPath(path, "git.exe", "git.cmd"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
if (gitExe != null)
|
if (gitExe != null)
|
||||||
return gitExe.getParentFile().getParentFile();
|
return resolveGrandparentFile(gitExe);
|
||||||
|
|
||||||
// This isn't likely to work, if bash is in $PATH, git should
|
// This isn't likely to work, if bash is in $PATH, git should
|
||||||
// also be in $PATH. But its worth trying.
|
// also be in $PATH. But its worth trying.
|
||||||
|
@ -102,7 +102,16 @@ protected File discoverGitPrefix() {
|
||||||
// The path may be in cygwin/msys notation so resolve it right away
|
// The path may be in cygwin/msys notation so resolve it right away
|
||||||
gitExe = resolve(null, w);
|
gitExe = resolve(null, w);
|
||||||
if (gitExe != null)
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +124,8 @@ protected File userHomeImpl() {
|
||||||
String homeDrive = SystemReader.getInstance().getenv("HOMEDRIVE"); //$NON-NLS-1$
|
String homeDrive = SystemReader.getInstance().getenv("HOMEDRIVE"); //$NON-NLS-1$
|
||||||
if (homeDrive != null) {
|
if (homeDrive != null) {
|
||||||
String homePath = SystemReader.getInstance().getenv("HOMEPATH"); //$NON-NLS-1$
|
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$
|
String homeShare = SystemReader.getInstance().getenv("HOMESHARE"); //$NON-NLS-1$
|
||||||
|
|
Loading…
Reference in New Issue