aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2010-12-28 17:15:18 +0100
committerRobin Rosenberg <robin.rosenberg@dewire.com>2010-12-31 11:48:34 +0100
commit797ebba30707259f7a4bc06baa40360ab79d2ff8 (patch)
treeea089758d503ecacccdd0adfa409c292681f3c71 /org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java
parent240769e023c4ea6c8394c25d58fdca7f0bb82948 (diff)
downloadjgit-797ebba30707259f7a4bc06baa40360ab79d2ff8.tar.gz
jgit-797ebba30707259f7a4bc06baa40360ab79d2ff8.zip
Add support for getting the system wide configuration
These settings are stored in <prefix>/etc/gitconfig. The C Git binary is installed in <prefix>/bin, so we look for the C Git executable to find this location, first by looking at the PATH environment variable and then by attemting to launch bash as a login shell to find out. Bug: 333216 Change-Id: I1bbee9fb123a81714a34a9cc242b92beacfbb4a8 Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
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.java20
1 files changed, 20 insertions, 0 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 4e35e6ee4b..2cf8bf9554 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
@@ -45,6 +45,7 @@
package org.eclipse.jgit.util;
import java.io.File;
+import java.nio.charset.Charset;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -76,4 +77,23 @@ class FS_Win32 extends FS {
public boolean retryFailedLockFileCommit() {
return true;
}
+
+ @Override
+ public File 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();
+
+ return null;
+ }
}