From 934567c537fe6008dab0decf3876a76b69ee0b8c Mon Sep 17 00:00:00 2001 From: "Kirill.Likhodedov" Date: Fri, 28 Dec 2012 20:51:08 +0400 Subject: [PATCH] [git] executable detector: fix for default project When there is no myPathToGit, and Settings is open before opening any project, GitVcs is not activated, and there is git.exe in the Settings instead of fairly detected executable. Solve it by returning to the previous logic: detect the executable right away in getPathToGit. Remove redundant getPathToGitAtStartup. Remove calling detect from GitVcs#activate since it will be automatically called from getPathToGit(). --- plugins/git4idea/src/git4idea/GitVcs.java | 7 ++----- .../config/GitVcsApplicationSettings.java | 17 ++--------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/plugins/git4idea/src/git4idea/GitVcs.java b/plugins/git4idea/src/git4idea/GitVcs.java index 12ab13e48880..e63cf01cfdba 100644 --- a/plugins/git4idea/src/git4idea/GitVcs.java +++ b/plugins/git4idea/src/git4idea/GitVcs.java @@ -363,11 +363,8 @@ public class GitVcs extends AbstractVcs { private void checkExecutableAndVersion() { boolean executableIsAlreadyCheckedAndFine = false; - String pathToGit = myAppSettings.getPathToGitAtStartup(); - if (pathToGit == null) { - myAppSettings.setPathToGit(new GitExecutableDetector().detect()); - } - else if (!pathToGit.contains(File.separator)) { // no path, just sole executable, with a hope that it is in path + String pathToGit = myAppSettings.getPathToGit(); + if (!pathToGit.contains(File.separator)) { // no path, just sole executable, with a hope that it is in path // subject to redetect the path if executable validator fails if (!myExecutableValidator.isExecutableValid()) { myAppSettings.setPathToGit(new GitExecutableDetector().detect()); diff --git a/plugins/git4idea/src/git4idea/config/GitVcsApplicationSettings.java b/plugins/git4idea/src/git4idea/config/GitVcsApplicationSettings.java index fa3ef96986bf..88dbb0a05917 100644 --- a/plugins/git4idea/src/git4idea/config/GitVcsApplicationSettings.java +++ b/plugins/git4idea/src/git4idea/config/GitVcsApplicationSettings.java @@ -59,25 +59,12 @@ public class GitVcsApplicationSettings implements PersistentStateComponentThis method differs from {@link #getPathToGit()} only in the @Nullable annotation: initially the path can be null, - * but after VCS is initialized for the first time, correct path is set in {@link git4idea.GitVcs} and is never null, - * so we want the @NotNull annotation there.

- *

This method should be called only from {@link git4idea.GitVcs#activate()}.

- * - * @return Path to Git or null if the path was not written to the config yet. - */ - @Nullable - public String getPathToGitAtStartup() { - return myState.myPathToGit; - } - public void setPathToGit(String pathToGit) { myState.myPathToGit = pathToGit; }