/**
  * Checks Git version and updates the myVersion variable. In the case of exception or unsupported
  * version reports the problem. Note that unsupported version is also applied - some functionality
  * might not work (we warn about that), but no need to disable at all.
  */
 public void checkVersion() {
   final String executable = myAppSettings.getPathToGit();
   try {
     myVersion = GitVersion.identifyVersion(executable);
     if (!myVersion.isSupported()) {
       log.info("Unsupported Git version: " + myVersion);
       final String SETTINGS_LINK = "settings";
       final String UPDATE_LINK = "update";
       String message =
           String.format(
               "The <a href='"
                   + SETTINGS_LINK
                   + "'>configured</a> version of Git is not supported: %s.<br/> "
                   + "The minimal supported version is %s. Please <a href='"
                   + UPDATE_LINK
                   + "'>update</a>.",
               myVersion,
               GitVersion.MIN);
       VcsNotifier.getInstance(myProject)
           .notifyError(
               "Unsupported Git version",
               message,
               new NotificationListener.Adapter() {
                 @Override
                 protected void hyperlinkActivated(
                     @NotNull Notification notification, @NotNull HyperlinkEvent e) {
                   if (SETTINGS_LINK.equals(e.getDescription())) {
                     ShowSettingsUtil.getInstance()
                         .showSettingsDialog(myProject, getConfigurable().getDisplayName());
                   } else if (UPDATE_LINK.equals(e.getDescription())) {
                     BrowserUtil.browse("http://git-scm.com");
                   }
                 }
               });
     }
   } catch (Exception e) {
     if (getExecutableValidator()
         .checkExecutableAndNotifyIfNeeded()) { // check executable before notifying error
       final String reason = (e.getCause() != null ? e.getCause() : e).getMessage();
       String message = GitBundle.message("vcs.unable.to.run.git", executable, reason);
       if (!myProject.isDefault()) {
         showMessage(message, ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes());
       }
       VcsBalloonProblemNotifier.showOverVersionControlView(myProject, message, MessageType.ERROR);
     }
   }
 }
  @NotNull
  private Pair<CheckoutMode, File> getTargetDirAndMode(
      @NotNull AgentPluginConfig config,
      @NotNull VcsRoot root,
      @NotNull CheckoutRules rules,
      @NotNull File checkoutDir)
      throws VcsException {
    GitVersion version = config.getGitVersion();
    if (config.isUseSparseCheckout() && !version.isLessThan(UpdaterImpl.GIT_WITH_SPARSE_CHECKOUT)) {
      String targetDir = getSingleTargetDir(rules);
      if (targetDir != null) {
        return Pair.create(CheckoutMode.SPARSE_CHECKOUT, new File(checkoutDir, targetDir));
      }
    }

    validateCheckoutRules(root, rules);
    File targetDir = getTargetDir(root, rules, checkoutDir);
    return Pair.create(CheckoutMode.MAP_REPO_TO_DIR, targetDir);
  }
  /** Test availability of the connection */
  private void testConnection() {
    final String executable = myGitField.getText();
    if (myAppSettings != null) {
      myAppSettings.setPathToGit(executable);
    }
    final GitVersion version;
    try {
      version = GitVersion.identifyVersion(executable);
    } catch (Exception e) {
      Messages.showErrorDialog(
          myProject, e.getMessage(), GitBundle.getString("find.git.error.title"));
      return;
    }

    if (version.isSupported()) {
      Messages.showInfoMessage(
          myProject, version.toString(), GitBundle.getString("find.git.success.title"));
    } else {
      Messages.showWarningDialog(
          myProject,
          GitBundle.message("find.git.unsupported.message", version.toString(), GitVersion.MIN),
          GitBundle.getString("find.git.success.title"));
    }
  }