Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-07-20 08:39:01 -0400
committerMatthias Sohn2019-07-21 09:11:21 -0400
commit374c142de4634d0888425368b138957c38498482 (patch)
treee170b6355f72b09ac9f939c8186d1de4f78d63f6 /org.eclipse.egit.ui
parent4869cd977ac253f65f61d360548b49dfec01b5db (diff)
downloadegit-374c142de4634d0888425368b138957c38498482.tar.gz
egit-374c142de4634d0888425368b138957c38498482.tar.xz
egit-374c142de4634d0888425368b138957c38498482.zip
Fix a few instances where repositories are not closed
In the staging view, ensure the fake RepositoryNode is cleared when no longer needed. In ExistingOrNewPage, ensure the newly created repo is closed. In LinkHelper, look up the repository from the repository cache instead of creating a new Repository instance that then cannot be closed because it my be referenced by the RepositoryTreeNode returned and that may be needed later. Change-Id: I7d255df59038167b17796735cc36b542d0771d36 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/LinkHelper.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java4
3 files changed, 15 insertions, 13 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/LinkHelper.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/LinkHelper.java
index 986199a8c..51f8f7110 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/LinkHelper.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/LinkHelper.java
@@ -15,18 +15,17 @@ package org.eclipse.egit.ui.internal.repository.tree;
import java.io.File;
import java.io.IOException;
import java.net.URI;
-import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.egit.core.RepositoryCache;
import org.eclipse.egit.core.RepositoryUtil;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
@@ -94,12 +93,12 @@ public class LinkHelper implements ILinkHelper {
return null;
RepositoryUtil config = Activator.getDefault().getRepositoryUtil();
-
- List<String> repos = config.getConfiguredRepositories();
- for (String repo : repos) {
+ RepositoryCache cache = org.eclipse.egit.core.Activator.getDefault()
+ .getRepositoryCache();
+ for (String repo : config.getConfiguredRepositories()) {
Repository repository;
try {
- repository = FileRepositoryBuilder.create(new File(repo));
+ repository = cache.lookupRepository(new File(repo));
} catch (IOException e) {
continue;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
index 122f87932..546ef3894 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java
@@ -398,9 +398,10 @@ class ExistingOrNewPage extends WizardPage {
File gitDir = new File(repositoryToCreate.getText(),
Constants.DOT_GIT);
try {
- Repository repository = FileRepositoryBuilder
- .create(gitDir);
- repository.create();
+ try (Repository repository = FileRepositoryBuilder
+ .create(gitDir)) {
+ repository.create();
+ }
for (IProject project : getProjects(false).keySet()) {
// If we don't refresh the project directories right
// now we won't later know that a .git directory
@@ -535,10 +536,9 @@ class ExistingOrNewPage extends WizardPage {
treeItem.setText(0, path.toString());
}
treeItem.setText(2, relativePath.toOSString());
- try {
+ try (Repository repo = new RepositoryBuilder()
+ .setGitDir(gitDir.toFile()).build();) {
IProject project = m.getContainer().getProject();
- Repository repo = new RepositoryBuilder()
- .setGitDir(gitDir.toFile()).build();
File workTree = repo.getWorkTree();
IPath workTreePath = Path.fromOSString(workTree
.getAbsolutePath());
@@ -563,7 +563,6 @@ class ExistingOrNewPage extends WizardPage {
}
}
}
- repo.close();
} catch (IOException e1) {
Activator
.logError(
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 2645c32de..07d60b409 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -3656,7 +3656,11 @@ public class StagingView extends ViewPart
enableCommitWidgets(false);
refreshAction.setEnabled(false);
updateSectionText();
+ RepositoryNode tmp = titleNode;
titleNode = null;
+ if (tmp != null) {
+ tmp.clear();
+ }
if (repository != null && repository.isBare()) {
form.setText(UIText.StagingView_BareRepoSelection);
} else {

Back to the top