private void setCoreAutoCrlfAttribute(@NotNull VirtualFile aRoot) {
   try {
     GitConfigUtil.setValue(
         myProject,
         aRoot,
         GitConfigUtil.CORE_AUTOCRLF,
         GitCrlfUtil.RECOMMENDED_VALUE,
         "--global");
   } catch (VcsException e) {
     // it is not critical: the user just will get the dialog again next time
     LOG.warn("Couldn't globally set core.autocrlf in " + aRoot, e);
   }
 }
    private ReturnResult checkUserName() {
      Project project = myPanel.getProject();
      GitVcs vcs = GitVcs.getInstance(project);
      assert vcs != null;

      Collection<VirtualFile> notDefined = new ArrayList<VirtualFile>();
      Map<VirtualFile, Pair<String, String>> defined =
          new HashMap<VirtualFile, Pair<String, String>>();
      Collection<VirtualFile> allRoots =
          new ArrayList<VirtualFile>(
              Arrays.asList(ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs)));

      Collection<VirtualFile> affectedRoots = getSelectedRoots();
      for (VirtualFile root : affectedRoots) {
        try {
          Pair<String, String> nameAndEmail = getUserNameAndEmailFromGitConfig(project, root);
          String name = nameAndEmail.getFirst();
          String email = nameAndEmail.getSecond();
          if (name == null || email == null) {
            notDefined.add(root);
          } else {
            defined.put(root, nameAndEmail);
          }
        } catch (VcsException e) {
          LOG.error("Couldn't get user.name and user.email for root " + root, e);
          // doing nothing - let commit with possibly empty user.name/email
        }
      }

      if (notDefined.isEmpty()) {
        return ReturnResult.COMMIT;
      }

      GitVersion version = vcs.getVersion();
      if (System.getenv("HOME") == null
          && GitVersionSpecialty.DOESNT_DEFINE_HOME_ENV_VAR.existsIn(version)) {
        Messages.showErrorDialog(
            project,
            "You are using Git "
                + version
                + " which doesn't define %HOME% environment variable properly.\n"
                + "Consider updating Git to a newer version "
                + "or define %HOME% to point to the place where the global .gitconfig is stored \n"
                + "(it is usually %USERPROFILE% or %HOMEDRIVE%%HOMEPATH%).",
            "HOME Variable Is Not Defined");
        return ReturnResult.CANCEL;
      }

      if (defined.isEmpty() && allRoots.size() > affectedRoots.size()) {
        allRoots.removeAll(affectedRoots);
        for (VirtualFile root : allRoots) {
          try {
            Pair<String, String> nameAndEmail = getUserNameAndEmailFromGitConfig(project, root);
            String name = nameAndEmail.getFirst();
            String email = nameAndEmail.getSecond();
            if (name != null && email != null) {
              defined.put(root, nameAndEmail);
              break;
            }
          } catch (VcsException e) {
            LOG.error("Couldn't get user.name and user.email for root " + root, e);
            // doing nothing - not critical not to find the values for other roots not affected by
            // commit
          }
        }
      }

      GitUserNameNotDefinedDialog dialog =
          new GitUserNameNotDefinedDialog(project, notDefined, affectedRoots, defined);
      dialog.show();
      if (dialog.isOK()) {
        try {
          if (dialog.isGlobal()) {
            GitConfigUtil.setValue(
                project,
                notDefined.iterator().next(),
                GitConfigUtil.USER_NAME,
                dialog.getUserName(),
                "--global");
            GitConfigUtil.setValue(
                project,
                notDefined.iterator().next(),
                GitConfigUtil.USER_EMAIL,
                dialog.getUserEmail(),
                "--global");
          } else {
            for (VirtualFile root : notDefined) {
              GitConfigUtil.setValue(project, root, GitConfigUtil.USER_NAME, dialog.getUserName());
              GitConfigUtil.setValue(
                  project, root, GitConfigUtil.USER_EMAIL, dialog.getUserEmail());
            }
          }
        } catch (VcsException e) {
          String message = "Couldn't set user.name and user.email";
          LOG.error(message, e);
          Messages.showErrorDialog(myPanel.getComponent(), message);
          return ReturnResult.CANCEL;
        }
        return ReturnResult.COMMIT;
      }
      return ReturnResult.CLOSE_WINDOW;
    }