diff --git a/plugins/git4idea/src/git4idea/GitVcs.java b/plugins/git4idea/src/git4idea/GitVcs.java index 320d9bc71709..b78c401436de 100644 --- a/plugins/git4idea/src/git4idea/GitVcs.java +++ b/plugins/git4idea/src/git4idea/GitVcs.java @@ -419,9 +419,11 @@ public class GitVcs extends AbstractVcs { final String executable = myAppSettings.getPathToGit(); try { myVersion = GitVersion.identifyVersion(executable); - if (!myVersion.isSupported() && !myProject.isDefault()) { + if (! myVersion.isSupported()) { String message = GitBundle.message("vcs.unsupported.version", myVersion, GitVersion.MIN); - showMessage(message, ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes()); + if (! myProject.isDefault()) { + showMessage(message, ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes()); + } VcsBalloonProblemNotifier.showOverVersionControlView(myProject, message, MessageType.ERROR); } } catch (Exception e) { diff --git a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java index 45e11a63095a..f774ff6a8bd0 100644 --- a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java +++ b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java @@ -104,13 +104,14 @@ public class LowLevelAccessImpl implements LowLevelAccess { // uses cached version public CachedRefs getRefs() throws VcsException { final CachedRefs refs = new CachedRefs(); - GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(myRoot); + GitRepository repository = myProject == null || myProject.isDefault() ? null : GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(myRoot); if (repository == null) { final File child = new File(myRoot.getPath(), GitUtil.DOT_GIT); if (! child.exists()) { throw new VcsException("No git repository in " + myRoot.getPath()); } repository = GitRepositoryImpl.getLightInstance(myRoot, myProject, myProject); + repository.update(GitRepository.TrackedTopic.BRANCHES); repository.getBranches(); } GitBranchesCollection branches = repository.getBranches(); diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/BigTableTableModel.java b/plugins/git4idea/src/git4idea/history/wholeTree/BigTableTableModel.java index 49d53fda73ae..77725162a697 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/BigTableTableModel.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/BigTableTableModel.java @@ -444,7 +444,9 @@ public class BigTableTableModel extends AbstractTableModel { } public int getLastForRoot(final VirtualFile root) { - return myRepoIdxMap.get(root).last(); + final TreeSet integers = myRepoIdxMap.get(root); + if (integers.isEmpty()) return -1; + return integers.last(); } @Override diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/SelectRepositoryAndShowLogAction.java b/plugins/git4idea/src/git4idea/history/wholeTree/SelectRepositoryAndShowLogAction.java index f597644cf9cc..d2f7d96a22b2 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/SelectRepositoryAndShowLogAction.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/SelectRepositoryAndShowLogAction.java @@ -71,7 +71,10 @@ public class SelectRepositoryAndShowLogAction extends AnAction { @Override public void actionPerformed(AnActionEvent e) { - final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); + Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); + project = project == null ? ProjectManager.getInstance().getDefaultProject() : project; + final Project finalProject = project; + final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, true, false, true); final VirtualFile[] virtualFiles = FileChooser.chooseFiles(descriptor, project, null); if (virtualFiles.length == 0) return; @@ -106,13 +109,12 @@ public class SelectRepositoryAndShowLogAction extends AnAction { } final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID); - final Project finalProject = project; final Runnable showContent = new Runnable() { @Override public void run() { ContentManager cm = window.getContentManager(); - if (checkForProjectScope(cm, project, correctRoots)) return; + if (checkForProjectScope(cm, finalProject, correctRoots)) return; int cnt = 0; Content[] contents = cm.getContents(); @@ -123,7 +125,7 @@ public class SelectRepositoryAndShowLogAction extends AnAction { List roots = ((MyContentComponent)component).getRoots(); if (Comparing.equal(roots, correctRoots)) { cm.setSelectedContent(content); - alreadyOpened(project); + alreadyOpened(finalProject); return; } } @@ -252,6 +254,10 @@ public class SelectRepositoryAndShowLogAction extends AnAction { GitVcs vcs = GitVcs.getInstance(myProject); if (vcs == null) { return; } myVersion = vcs.getVersion(); + if (myVersion.isNull()) { + vcs.checkVersion(); + myVersion = vcs.getVersion(); + } } } diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java index 6c3d521b9fa1..7dc2e815286e 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java @@ -61,7 +61,8 @@ public class GitRepositoryImpl implements GitRepository, Disposable { * If you need to have an instance of GitRepository for a repository outside the project, use * {@link #getLightInstance(com.intellij.openapi.vfs.VirtualFile, com.intellij.openapi.project.Project, com.intellij.openapi.Disposable)}. */ - private GitRepositoryImpl(@NotNull VirtualFile rootDir, @NotNull Project project, @NotNull Disposable parentDisposable) { + private GitRepositoryImpl(@NotNull VirtualFile rootDir, @NotNull Project project, @NotNull Disposable parentDisposable, + final boolean light) { myRootDir = rootDir; myProject = project; Disposer.register(parentDisposable, this); @@ -71,12 +72,16 @@ public class GitRepositoryImpl implements GitRepository, Disposable { myReader = new GitRepositoryReader(VfsUtil.virtualToIoFile(myGitDir)); - myUntrackedFilesHolder = new GitUntrackedFilesHolder(this); - Disposer.register(this, myUntrackedFilesHolder); - myMessageBus = project.getMessageBus(); myNotifier = new QueueProcessor(new NotificationConsumer(myProject, myMessageBus), myProject.getDisposed()); - update(TrackedTopic.ALL); + if (! light) { + myUntrackedFilesHolder = new GitUntrackedFilesHolder(this); + Disposer.register(this, myUntrackedFilesHolder); + + update(TrackedTopic.ALL); + } else { + myUntrackedFilesHolder = null; + } } /** @@ -86,7 +91,7 @@ public class GitRepositoryImpl implements GitRepository, Disposable { */ @NotNull public static GitRepository getLightInstance(@NotNull VirtualFile root, @NotNull Project project, @NotNull Disposable parentDisposable) { - return new GitRepositoryImpl(root, project, parentDisposable); + return new GitRepositoryImpl(root, project, parentDisposable, true); } /** @@ -94,7 +99,7 @@ public class GitRepositoryImpl implements GitRepository, Disposable { * This is used for repositories registered in project, and should be optained via {@link GitRepositoryManager}. */ public static GitRepository getFullInstance(@NotNull VirtualFile root, @NotNull Project project, @NotNull Disposable parentDisposable) { - GitRepositoryImpl repository = new GitRepositoryImpl(root, project, parentDisposable); + GitRepositoryImpl repository = new GitRepositoryImpl(root, project, parentDisposable, false); repository.myUntrackedFilesHolder.setupVfsListener(project); repository.setupUpdater(); return repository;