diff --git a/plugins/git4idea/src/git4idea/config/GitVersion.java b/plugins/git4idea/src/git4idea/config/GitVersion.java index bc0d25ee3c40..5a1ed5a498b8 100644 --- a/plugins/git4idea/src/git4idea/config/GitVersion.java +++ b/plugins/git4idea/src/git4idea/config/GitVersion.java @@ -35,7 +35,8 @@ import java.util.regex.Pattern; * The version of Git. Note that the version number ignores build and commit hash. * The class is able to distinct MSYS and CYGWIN Gits under Windows assuming that msysgit adds the 'msysgit' suffix to the output * of the 'git version' command. - * This is not a very good way to distinguish msys and cygwin since in old versions of msys they didn't add the suffix. + * This is not a very good way to distinguish msys and cygwin since in old versions of msys they didn't add the suffix. + * * Note: this class has a natural ordering that is inconsistent with equals. */ public final class GitVersion implements Comparable { @@ -68,7 +69,7 @@ public final class GitVersion implements Comparable { public static final GitVersion NULL = new GitVersion(0, 0, 0, 0, Type.NULL); private static final Pattern FORMAT = Pattern.compile( - "git version (\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:\\.(msysgit))?[\\.\\-\\d\\w]*", Pattern.CASE_INSENSITIVE); + "git version (\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?(.*)", Pattern.CASE_INSENSITIVE); private static final Logger LOG = Logger.getInstance(GitVersion.class.getName()); @@ -112,7 +113,7 @@ public final class GitVersion implements Comparable { int minor = getIntGroup(m, 2); int rev = getIntGroup(m, 3); int patch = getIntGroup(m, 4); - boolean msys = (m.groupCount() >= 5) && m.group(5) != null && m.group(5).equalsIgnoreCase("msysgit"); + boolean msys = (m.groupCount() >= 5) && m.group(5) != null && m.group(5).toLowerCase().contains("msysgit"); Type type; if (SystemInfo.isWindows) { type = msys ? Type.MSYS : Type.CYGWIN; diff --git a/plugins/git4idea/tests/git4idea/tests/GitVersionTest.java b/plugins/git4idea/tests/git4idea/tests/GitVersionTest.java index 1934a9f5ad4d..1940bd942485 100644 --- a/plugins/git4idea/tests/git4idea/tests/GitVersionTest.java +++ b/plugins/git4idea/tests/git4idea/tests/GitVersionTest.java @@ -36,7 +36,8 @@ public class GitVersionTest { new TestGitVersion("git version 1.6.4", 1, 6, 4, 0), new TestGitVersion("git version 1.7.3.3", 1, 7, 3, 3), new TestGitVersion("git version 1.7.3.5.gb27be", 1, 7, 3, 5), - new TestGitVersion("git version 1.7.4-rc1", 1, 7, 4, 0) + new TestGitVersion("git version 1.7.4-rc1", 1, 7, 4, 0), + new TestGitVersion("git version 1.7.7.5 (Apple Git-24)", 1, 7, 7, 5) }; private static final TestGitVersion[] msysTests = {