Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-03-16 16:51:29 -0400
committerMatthias Sohn2016-03-20 18:56:59 -0400
commitc1024b6856f8fe396c58974ef8d4bc68a97ad82e (patch)
tree1ac02182300567aa701e44a99a52f3c95c8f515f
parentab8cd06d5d50ecc7c1c97478121ddd219fd40e9a (diff)
downloadegit-c1024b6856f8fe396c58974ef8d4bc68a97ad82e.tar.gz
egit-c1024b6856f8fe396c58974ef8d4bc68a97ad82e.tar.xz
egit-c1024b6856f8fe396c58974ef8d4bc68a97ad82e.zip
Fix refresh after re-connecting a project with submodules inside
Follow-up to commit a8bcee9. When a previously connected, then disconnected project is re-connected, there is no resource change event. Thus the GitProjectData doesn't pick up inner repositories, and doesn't re-set the RepositoryMappings for folders inside the project that contain submodule or nested repository working trees. Because of another bug that I plan to fix soon (disconnecting a project does not remove the RepositoryMapping session properties), this problem is currently only visible if one quits and restarts Eclipse after having disconnected. (Otherwise, the previous session properties are still set, and everything appears fine.) Thus we need to make sure when a project is shared that we get at least a resource delta including all .git files and folders in the hierarchy. Ensure that by touching all such inner resources. Also, the SharingWizard must not suppress the refresh. Bug: 489696 Change-Id: I1bce767f54bffced241d2a0ad3c7ae8230152199 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java37
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java1
3 files changed, 41 insertions, 7 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java
index fd8495f22..91a47400e 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConnectProviderOperation.java
@@ -25,6 +25,8 @@ import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -152,7 +154,8 @@ public class ConnectProviderOperation implements IEGitOperation {
RepositoryProvider.map(project, GitProvider.ID);
if (refreshResources) {
- project.refreshLocal(IResource.DEPTH_INFINITE, subMon.newChild(40));
+ touchGitResources(project, subMon.newChild(10));
+ project.refreshLocal(IResource.DEPTH_INFINITE, subMon.newChild(30));
} else {
subMon.worked(40);
}
@@ -160,6 +163,38 @@ public class ConnectProviderOperation implements IEGitOperation {
autoIgnoreDerivedResources(project, subMon.newChild(10));
}
+ /**
+ * Touches all descendants named ".git" so that they'll be included in a
+ * subsequent resource delta.
+ *
+ * @param project
+ * to process
+ * @param monitor
+ * for progress reporting and cancellation, may be {@code null}
+ * if neither is desired
+ */
+ private void touchGitResources(IProject project, IProgressMonitor monitor) {
+ final SubMonitor progress = SubMonitor.convert(monitor, 1);
+ try {
+ project.accept(new IResourceProxyVisitor() {
+ @Override
+ public boolean visit(IResourceProxy resource)
+ throws CoreException {
+ int type = resource.getType();
+ if ((type == IResource.FILE || type == IResource.FOLDER)
+ && Constants.DOT_GIT.equals(resource.getName())) {
+ progress.setWorkRemaining(2);
+ resource.requestResource().touch(progress.newChild(1));
+ return false;
+ }
+ return true;
+ }
+ }, IResource.NONE);
+ } catch (CoreException e) {
+ Activator.error(e.getMessage(), e);
+ }
+ }
+
private void deleteGitProvider(MultiStatus ms, IProject project) {
try {
GitProjectData.delete(project);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
index a7daa3ef1..5b05a3337 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
@@ -41,8 +41,6 @@ import org.eclipse.egit.ui.test.Eclipse;
import org.eclipse.egit.ui.test.TestUtil;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
@@ -89,7 +87,8 @@ public class SharingWizardTest extends LocalRepositoryTestCase {
SystemReader.setInstance(null);
}
- private static String createProject(String projectName) {
+ private static String createProject(String projectName)
+ throws CoreException {
bot.menu("File").menu("New").menu("Project...").click();
SWTBotShell createProjectDialogShell = bot.shell("New Project");
bot.tree().getTreeItem("General").expand().getNode("Project").select();
@@ -100,6 +99,8 @@ public class SharingWizardTest extends LocalRepositoryTestCase {
String path = bot.textWithLabel("Location:").getText();
bot.button("Finish").click();
bot.waitUntil(Conditions.shellCloses(createProjectDialogShell), 10000);
+ ResourcesPlugin.getWorkspace().getRoot()
+ .refreshLocal(IResource.DEPTH_INFINITE, null);
return path;
}
@@ -193,8 +194,7 @@ public class SharingWizardTest extends LocalRepositoryTestCase {
}
@Test
- public void shareProjectWithAlreadyCreatedRepos() throws IOException,
- InterruptedException, JGitInternalException, GitAPIException {
+ public void shareProjectWithAlreadyCreatedRepos() throws Exception {
Repository repo1 = FileRepositoryBuilder.create(new File(
new File(createProject(projectName1)).getParent(), ".git"));
repo1.create();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java
index b9e6667f7..df04dbf05 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/SharingWizard.java
@@ -128,7 +128,6 @@ public class SharingWizard extends Wizard implements IConfigurationWizard,
} else {
final ConnectProviderOperation op = new ConnectProviderOperation(
existingPage.getProjects(true));
- op.setRefreshResources(false);
try {
getContainer().run(true, false, new IRunnableWithProgress() {
@Override

Back to the top