diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java
index 8556b790634b..f4be63494bea 100644
--- a/plugins/git4idea/src/git4idea/GitUtil.java
+++ b/plugins/git4idea/src/git4idea/GitUtil.java
@@ -608,6 +608,9 @@ public class GitUtil {
}
public static boolean justOneGitRepository(Project project) {
+ if (project.isDisposed()) {
+ return true;
+ }
GitRepositoryManager manager = getRepositoryManager(project);
if (manager == null) {
return true;
diff --git a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java
index 139ac72b22aa..47169747ef0f 100644
--- a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java
+++ b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java
@@ -236,7 +236,9 @@ class GitCheckoutOperation extends GitBranchOperation {
// See http://youtrack.jetbrains.com/issue/IDEA-80573
sleepABit();
refreshRoot(repository);
- // repository state will be auto-updated with this VFS refresh => no need to call GitRepository#update().
+ // repository state will be auto-updated with this VFS refresh => in general there is no need to call GitRepository#update()
+ // but to avoid problems of the asynchronous refresh, let's force update the repository info.
+ repository.update(GitRepository.TrackedTopic.CURRENT_BRANCH, GitRepository.TrackedTopic.CURRENT_REVISION);
}
}
diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
index a2e21ae6f5ec..19c3319527da 100644
--- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
+++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
@@ -476,9 +476,11 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
handler.addParameters(paths);
handler.run();
}
- GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
- if (manager != null) {
- manager.updateRepository(root, GitRepository.TrackedTopic.CURRENT_REVISION, GitRepository.TrackedTopic.STATE);
+ if (!project.isDisposed()) {
+ GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
+ if (manager != null) {
+ manager.updateRepository(root, GitRepository.TrackedTopic.CURRENT_REVISION, GitRepository.TrackedTopic.STATE);
+ }
}
}
diff --git a/plugins/git4idea/src/git4idea/commands/GitCompoundResult.java b/plugins/git4idea/src/git4idea/commands/GitCompoundResult.java
index a0ea8be656f2..cfc906f03bd6 100644
--- a/plugins/git4idea/src/git4idea/commands/GitCompoundResult.java
+++ b/plugins/git4idea/src/git4idea/commands/GitCompoundResult.java
@@ -79,7 +79,7 @@ public final class GitCompoundResult {
GitCommandResult result = entry.getValue();
if (!result.success()) {
sb.append("
");
- if (!onlyOneRepositoryInTheProject()) {
+ if (!GitUtil.justOneGitRepository(myProject)) {
sb.append("" + repository.getPresentableUrl() + ":
");
}
sb.append(result.getErrorOutputAsHtmlString());
@@ -88,8 +88,4 @@ public final class GitCompoundResult {
}
return sb.toString();
}
-
- private boolean onlyOneRepositoryInTheProject() {
- return !GitUtil.getRepositoryManager(myProject).moreThanOneRoot();
- }
}
diff --git a/plugins/git4idea/src/git4idea/convert/GitFileSeparatorConverter.java b/plugins/git4idea/src/git4idea/convert/GitFileSeparatorConverter.java
index 66118a1f85e2..7ed54d9a1cfe 100644
--- a/plugins/git4idea/src/git4idea/convert/GitFileSeparatorConverter.java
+++ b/plugins/git4idea/src/git4idea/convert/GitFileSeparatorConverter.java
@@ -50,6 +50,9 @@ public class GitFileSeparatorConverter {
final GitVcsSettings settings,
Map> sortedChanges,
final List exceptions) {
+ if (project.isDisposed()) {
+ return true;
+ }
final GitVcsSettings.ConversionPolicy conversionPolicy = settings.getLineSeparatorsConversion();
if (conversionPolicy != GitVcsSettings.ConversionPolicy.NONE) {
LocalFileSystem lfs = LocalFileSystem.getInstance();
@@ -77,10 +80,10 @@ public class GitFileSeparatorConverter {
}
}
// check crlf for real
- for (Iterator>> i = files.entrySet().iterator(); i.hasNext();) {
+ for (Iterator>> i = files.entrySet().iterator(); i.hasNext(); ) {
Map.Entry> e = i.next();
Set fs = e.getValue();
- for (Iterator j = fs.iterator(); j.hasNext();) {
+ for (Iterator j = fs.iterator(); j.hasNext(); ) {
VirtualFile f = j.next();
String detectedLineSeparator = LoadTextUtil.detectLineSeparator(f, true);
if (detectedLineSeparator == null || nl.equals(detectedLineSeparator)) {
@@ -105,15 +108,18 @@ public class GitFileSeparatorConverter {
settings.setLineSeparatorsConversion(GitVcsSettings.ConversionPolicy.CONVERT);
}
selectedFiles = d.getSelectedFiles();
- } else if (d.getExitCode() == GitConvertFilesDialog.DO_NOT_CONVERT) {
+ }
+ else if (d.getExitCode() == GitConvertFilesDialog.DO_NOT_CONVERT) {
if (d.isDontShowAgainChosen()) {
settings.setLineSeparatorsConversion(GitVcsSettings.ConversionPolicy.NONE);
}
- } else {
+ }
+ else {
//noinspection ThrowableInstanceNeverThrown
exceptions.add(new VcsException("Commit was cancelled in file conversion dialog"));
}
- } else {
+ }
+ else {
ArrayList fileList = new ArrayList();
for (Set fileSet : files.values()) {
fileList.addAll(fileSet);
@@ -127,7 +133,8 @@ public class GitFileSeparatorConverter {
}
try {
LoadTextUtil.changeLineSeparator(project, GitConvertFilesDialog.class.getName(), f, nl);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
//noinspection ThrowableInstanceNeverThrown
exceptions.add(new VcsException("Failed to change line separators for the file: " + f.getPresentableUrl(), e));
}
diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java
index 4a31f78873cf..5bf34489e979 100644
--- a/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java
+++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java
@@ -16,6 +16,7 @@
package git4idea.repo;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -54,9 +55,15 @@ final class GitRepositoryUpdater implements Disposable, BulkFileListener {
myHeadsDir = VcsUtil.getVirtualFile(myRepositoryFiles.getRefsHeadsPath());
myRemotesDir = VcsUtil.getVirtualFile(myRepositoryFiles.getRefsRemotesPath());
- myUpdateQueue = new QueueProcessor(new Updater(repository), repository.getProject().getDisposed());
- myMessageBusConnection = repository.getProject().getMessageBus().connect();
- myMessageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, this);
+ Project project = repository.getProject();
+ myUpdateQueue = new QueueProcessor(new Updater(repository), project.getDisposed());
+ if (!project.isDisposed()) {
+ myMessageBusConnection = project.getMessageBus().connect();
+ myMessageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, this);
+ }
+ else {
+ myMessageBusConnection = null;
+ }
}
private static void visitGitDirVfs(@NotNull VirtualFile gitDir) {
@@ -85,7 +92,9 @@ final class GitRepositoryUpdater implements Disposable, BulkFileListener {
if (myWatchRequest != null) {
LocalFileSystem.getInstance().removeWatchedRoot(myWatchRequest);
}
- myMessageBusConnection.disconnect();
+ if (myMessageBusConnection != null) {
+ myMessageBusConnection.disconnect();
+ }
}
@Override
diff --git a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
index 356ba991486b..feabdb62c367 100644
--- a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
+++ b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java
@@ -104,8 +104,10 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener {
}
void setupVfsListener(@NotNull Project project) {
- MessageBusConnection connection = project.getMessageBus().connect(this);
- connection.subscribe(VirtualFileManager.VFS_CHANGES, this);
+ if (!project.isDisposed()) {
+ MessageBusConnection connection = project.getMessageBus().connect(this);
+ connection.subscribe(VirtualFileManager.VFS_CHANGES, this);
+ }
}
@Override
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java
index 1bdd028d9d93..44a186947467 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java
@@ -189,22 +189,31 @@ public final class HgCommandExecutor {
final String cmdString = String.format("%s %s %s", executable, operation, arguments == null ? "" : StringUtils.join(arguments, " "));
// log command
- LOG.info(cmdString);
if (!myIsSilent) {
+ LOG.info(cmdString);
myVcs.showMessageInConsole(cmdString, ConsoleViewContentType.NORMAL_OUTPUT.getAttributes());
}
+ else {
+ LOG.debug(cmdString);
+ }
// log output if needed
if (!myIsSilent && myShowOutput) {
LOG.info(result.getRawOutput());
myVcs.showMessageInConsole(result.getRawOutput(), ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes());
}
+ else {
+ LOG.debug(result.getRawOutput());
+ }
// log error
if (!myIsSilent) {
LOG.info(result.getRawError());
myVcs.showMessageInConsole(result.getRawError(), ConsoleViewContentType.ERROR_OUTPUT.getAttributes());
}
+ else {
+ LOG.debug(result.getRawError());
+ }
}
private void showError(Exception e) {