Merge "Cache gitPrefix in FS_Win32"
This commit is contained in:
commit
09d2b9f0ed
|
@ -64,6 +64,9 @@ public String run() {
|
|||
&& StringUtils.toLowerCase(osDotName).indexOf("windows") != -1;
|
||||
}
|
||||
|
||||
private File gitPrefix;
|
||||
private boolean gitPrefixEvaluated;
|
||||
|
||||
public boolean supportsExecute() {
|
||||
return false;
|
||||
}
|
||||
|
@ -83,11 +86,14 @@ public boolean retryFailedLockFileCommit() {
|
|||
|
||||
@Override
|
||||
public File gitPrefix() {
|
||||
if (gitPrefixEvaluated)
|
||||
return gitPrefix;
|
||||
|
||||
String path = SystemReader.getInstance().getenv("PATH");
|
||||
File gitExe = searchPath(path, "git.exe", "git.cmd");
|
||||
if (gitExe != null)
|
||||
return gitExe.getParentFile().getParentFile();
|
||||
|
||||
gitPrefix = gitExe.getParentFile().getParentFile();
|
||||
else {
|
||||
// This isn't likely to work, if bash is in $PATH, git should
|
||||
// also be in $PATH. But its worth trying.
|
||||
//
|
||||
|
@ -95,9 +101,11 @@ public File gitPrefix() {
|
|||
new String[] { "bash", "--login", "-c", "which git" }, //
|
||||
Charset.defaultCharset().name());
|
||||
if (w != null)
|
||||
return new File(w).getParentFile().getParentFile();
|
||||
gitPrefix = new File(w).getParentFile().getParentFile();
|
||||
}
|
||||
|
||||
return null;
|
||||
gitPrefixEvaluated = true;
|
||||
return gitPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue