Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-03-17 09:40:53 -0400
committerGerrit Code Review @ Eclipse.org2016-03-17 09:40:55 -0400
commitab8cd06d5d50ecc7c1c97478121ddd219fd40e9a (patch)
tree0ddf7e068a889cc1df7c77714d6dc6fac467b61a
parenta8bcee9ea7a58e6db797b86c735f0bdb9e774c18 (diff)
parent241d23eb7313644e8b4a428f88724336e48374f4 (diff)
downloadegit-ab8cd06d5d50ecc7c1c97478121ddd219fd40e9a.tar.gz
egit-ab8cd06d5d50ecc7c1c97478121ddd219fd40e9a.tar.xz
egit-ab8cd06d5d50ecc7c1c97478121ddd219fd40e9a.zip
Merge "Handle submodules in auto-sharing"
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java23
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java15
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java13
3 files changed, 36 insertions, 15 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
index 47fedba55..8eb51d264 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
@@ -17,6 +17,7 @@ import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -499,12 +500,12 @@ public class Activator extends Plugin implements DebugOptionsListener {
}
RepositoryFinder f = new RepositoryFinder(project);
f.setFindInChildren(false);
- Collection<RepositoryMapping> mappings = f.find(new NullProgressMonitor());
- if (mappings.size() != 1) {
+ List<RepositoryMapping> mappings = f
+ .find(new NullProgressMonitor());
+ if (mappings.isEmpty()) {
return;
}
-
- RepositoryMapping m = mappings.iterator().next();
+ RepositoryMapping m = mappings.get(0);
IPath gitDirPath = m.getGitDirAbsolutePath();
if (gitDirPath == null || gitDirPath.segmentCount() == 0) {
return;
@@ -526,9 +527,21 @@ public class Activator extends Plugin implements DebugOptionsListener {
}
// connect
- final File repositoryDir = gitDirPath.toFile();
+ File repositoryDir = gitDirPath.toFile();
projects.put(project, repositoryDir);
+ // If we had more than one mapping: add the last one as
+ // 'configured' repository. We don't want to add submodules,
+ // that would only lead to problems when a configured repository
+ // is deleted.
+ int nofMappings = mappings.size();
+ if (nofMappings > 1) {
+ IPath lastPath = mappings.get(nofMappings - 1)
+ .getGitDirAbsolutePath();
+ if (lastPath != null) {
+ repositoryDir = lastPath.toFile();
+ }
+ }
try {
Activator.getDefault().getRepositoryUtil()
.addConfiguredRepository(repositoryDir);
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java
index 6b6406fea..87b698143 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java
@@ -16,8 +16,8 @@ package org.eclipse.egit.core.project;
import java.io.File;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
@@ -55,7 +55,7 @@ import org.eclipse.jgit.util.SystemReader;
public class RepositoryFinder {
private final IProject proj;
- private final Collection<RepositoryMapping> results = new ArrayList<RepositoryMapping>();
+ private final List<RepositoryMapping> results = new ArrayList<RepositoryMapping>();
private final Set<File> gitdirs = new HashSet<File>();
private final Set<File> ceilingDirectories = new HashSet<File>();
@@ -95,12 +95,13 @@ public class RepositoryFinder {
* @param m
* a progress monitor to report feedback to; may be null.
* @return all found {@link RepositoryMapping} instances associated with the
- * project supplied to this instance's constructor.
+ * project supplied to this instance's constructor, in the order
+ * they were found.
* @throws CoreException
* Eclipse was unable to access its workspace, and threw up on
* us. We're throwing it back at the caller.
*/
- public Collection<RepositoryMapping> find(IProgressMonitor m)
+ public List<RepositoryMapping> find(IProgressMonitor m)
throws CoreException {
return find(m, false);
}
@@ -113,13 +114,15 @@ public class RepositoryFinder {
* @param searchLinkedFolders
* specify if linked folders should be included in the search
* @return all found {@link RepositoryMapping} instances associated with the
- * project supplied to this instance's constructor.
+ * project supplied to this instance's constructor, in the order
+ * they were found.
* @throws CoreException
* Eclipse was unable to access its workspace, and threw up on
* us. We're throwing it back at the caller.
* @since 2.3
*/
- public Collection<RepositoryMapping> find(IProgressMonitor m, boolean searchLinkedFolders)
+ public List<RepositoryMapping> find(IProgressMonitor m,
+ boolean searchLinkedFolders)
throws CoreException {
find(m, proj, searchLinkedFolders);
return results;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java
index c0aed4086..4eb3f75f6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/AddCommand.java
@@ -12,8 +12,8 @@
package org.eclipse.egit.ui.internal.repository.tree.command;
import java.io.File;
-import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.ExecutionEvent;
@@ -91,10 +91,15 @@ public class AddCommand extends
RepositoryFinder f = new RepositoryFinder(project);
f.setFindInChildren(false);
try {
- Collection<RepositoryMapping> mappings = f
+ List<RepositoryMapping> mappings = f
.find(new NullProgressMonitor());
- if (mappings.size() == 1)
- connections.put(project, repositoryDir);
+ if (!mappings.isEmpty()) {
+ // Connect to the first one; it's the innermost.
+ IPath gitDir = mappings.get(0).getGitDirAbsolutePath();
+ if (gitDir != null) {
+ connections.put(project, gitDir.toFile());
+ }
+ }
} catch (CoreException e) {
// Ignore this project in that case
continue;

Back to the top