From 4ca2fc5ce7b2c47ea391b9ea57375baa798d3d2d Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 19 May 2015 09:35:18 +0200 Subject: [PATCH] Equalize discoverGitPrefix() implementations between POSIX and Win32 Change-Id: I936df151890d4bba9079d79c65b75a69c209523b Signed-off-by: Sebastian Schuberth --- .../src/org/eclipse/jgit/util/FS_POSIX.java | 22 ++++++++++--------- .../src/org/eclipse/jgit/util/FS_Win32.java | 12 +++++----- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java index 667b96979..e2f9bb826 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java @@ -141,16 +141,18 @@ protected File discoverGitPrefix() { return resolveGrandparentFile(gitExe); if (SystemReader.getInstance().isMacOS()) { - // On MacOSX, PATH is shorter when Eclipse is launched from the - // Finder than from a terminal. Therefore try to launch bash as a - // login shell and search using that. - // - 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 || w.length() == 0) - return null; - return resolveGrandparentFile(new File(w)); + if (searchPath(path, "bash") != null) { //$NON-NLS-1$ + // On MacOSX, PATH is shorter when Eclipse is launched from the + // Finder than from a terminal. Therefore try to launch bash as a + // login shell and search using that. + 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 || w.length() == 0) + return null; + gitExe = new File(w); + return resolveGrandparentFile(gitExe); + } } return null; 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 6e0c5e85f..5282733dd 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 @@ -117,12 +117,12 @@ protected File discoverGitPrefix() { 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 (w == null || w.length() == 0) + return 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;