import com.intellij.util.PairConsumer;
import git4idea.GitVcs;
import git4idea.config.GitConfigUtil;
+import git4idea.config.GitVersion;
+import git4idea.config.GitVersionSpecialty;
import git4idea.i18n.GitBundle;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryManager;
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(GitVcs.getInstance(project))));
+ ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs)));
Collection<VirtualFile> affectedRoots = myPanel.getRoots();
for (VirtualFile root : affectedRoots) {
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) {
*/
package git4idea.config;
+import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.annotations.NotNull;
/**
*/
KNOWS_STATUS_PORCELAIN {
@Override
- public boolean existsIn(@NotNull GitVersion
- version) {
+ public boolean existsIn(@NotNull GitVersion version) {
return version.isLaterOrEqual(new GitVersion(1, 7, 0, 0));
}
+ },
+
+ DOESNT_DEFINE_HOME_ENV_VAR {
+ @Override
+ public boolean existsIn(@NotNull GitVersion version) {
+ return SystemInfo.isWindows && version.isOlderOrEqual(new GitVersion(1, 7, 0, 2));
+ }
};
public abstract boolean existsIn(@NotNull GitVersion version);