From ec6ec3b10fb1ef8dd73a499d0b1f7a7d711b84dd Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Mon, 4 May 2015 11:45:22 +0200 Subject: [PATCH] FS_Win32: Avoid an IOException on Windows if bash is not in PATH Change-Id: I3145f74ecee9f5b368e7f4b9fd7cb906f407eff5 Signed-off-by: Sebastian Schuberth Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/util/FS_Win32.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 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 6f553ccfa..41e8113a4 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 @@ -111,18 +111,20 @@ public class FS_Win32 extends FS { if (gitExe != null) return resolveGrandparentFile(gitExe); - // 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" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - Charset.defaultCharset().name()); - if (w != null) { - // The path may be in cygwin/msys notation so resolve it right away - gitExe = resolve(null, w); - if (gitExe != null) - return resolveGrandparentFile(gitExe); + if (searchPath(path, "bash.exe") != null) { //$NON-NLS-1$ + // This isn't likely to work, but its worth trying: + // If bash is in $PATH, git should also be in $PATH. + String w = readPipe(userHome(), + new String[] { "bash", "--login", "-c", "which git" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + Charset.defaultCharset().name()); + if (w != null) { + // The path may be in cygwin/msys notation so resolve it right away + gitExe = resolve(null, w); + if (gitExe != null) + return resolveGrandparentFile(gitExe); + } } + return null; }