diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-03-14 09:07:53 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-03-14 09:07:53 -0700 |
commit | 5f82569cab3386306bca546b87d3919723449c90 (patch) | |
tree | fffe9a55852ab99c6f55c8ccf475d235ea3e8cbb /org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java | |
parent | 2f705ad240ba7731a105f9b438240fa7cd3c52a1 (diff) | |
download | jgit-5f82569cab3386306bca546b87d3919723449c90.tar.gz jgit-5f82569cab3386306bca546b87d3919723449c90.zip |
FS: Allow gitPrefix to be set and cached
This permits callers to modify the meaning of gitPrefix, which
may be useful if their application allows the user to select
the location where C Git is installed.
Bug: 337101
Change-Id: I07362a5772da4955e01406bdeb8eaf87416be1d6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java | 31 |
1 files changed, 11 insertions, 20 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 7e1b6434cb..5838fed6af 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 @@ -64,9 +64,6 @@ class FS_Win32 extends FS { && StringUtils.toLowerCase(osDotName).indexOf("windows") != -1; } - private File gitPrefix; - private boolean gitPrefixEvaluated; - public boolean supportsExecute() { return false; } @@ -85,27 +82,21 @@ class FS_Win32 extends FS { } @Override - public File gitPrefix() { - if (gitPrefixEvaluated) - return gitPrefix; - + protected File discoverGitPrefix() { String path = SystemReader.getInstance().getenv("PATH"); File gitExe = searchPath(path, "git.exe", "git.cmd"); if (gitExe != null) - 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 gitExe.getParentFile().getParentFile(); - gitPrefixEvaluated = true; - return gitPrefix; + // 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(); + return null; } @Override |