Преглед на файлове

Merge "Cache gitPrefix in FS_Win32"

tags/v0.12.1
Shawn Pearce преди 13 години
родител
ревизия
09d2b9f0ed
променени са 1 файла, в които са добавени 19 реда и са изтрити 11 реда
  1. 19
    11
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java

+ 19
- 11
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java Целия файл

@@ -64,6 +64,9 @@ class FS_Win32 extends FS {
&& StringUtils.toLowerCase(osDotName).indexOf("windows") != -1;
}

private File gitPrefix;
private boolean gitPrefixEvaluated;

public boolean supportsExecute() {
return false;
}
@@ -83,21 +86,26 @@ class FS_Win32 extends FS {

@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();

// This isn't likely to work, if bash is in $PATH, git should
// also be in $PATH. But its worth trying.
//
String w = readPipe(userHome(), //
new String[] { "bash", "--login", "-c", "which git" }, //
Charset.defaultCharset().name());
if (w != null)
return new File(w).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.
//
String w = readPipe(userHome(), //
new String[] { "bash", "--login", "-c", "which git" }, //
Charset.defaultCharset().name());
if (w != null)
gitPrefix = new File(w).getParentFile().getParentFile();
}

return null;
gitPrefixEvaluated = true;
return gitPrefix;
}

@Override

Loading…
Отказ
Запис