public static @NotNull GitVersion parse(@NotNull String output, @Nullable Type type) throws ParseException {
    if (StringUtil.isEmptyOrSpaces(output)) {
      throw new ParseException("Empty git --version output: " + output, 0);
    }
    Matcher m = FORMAT.matcher(output.trim());
    if (!m.matches()) {
      throw new ParseException("Unsupported format of git --version output: " + output, 0);
    }
    int major = getIntGroup(m, 1);
    int minor = getIntGroup(m, 2);
    int rev = getIntGroup(m, 3);
    int patch = getIntGroup(m, 4);

    if (type == null) {
      if (SystemInfo.isWindows) {
        String suffix = getStringGroup(m, 5);
        if (StringUtil.toLowerCase(suffix).contains("msysgit") || //NON-NLS
            StringUtil.toLowerCase(suffix).contains("windows")) { //NON-NLS
          type = Type.MSYS;
        }
        else {
          type = Type.CYGWIN;
        }
      }
      else {
        type = Type.UNIX;
      }
    }

    return new GitVersion(major, minor, rev, patch, type);
  }
public static @NotNull GitVersion parse(@NotNull String output, @Nullable Type type)