Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2013-08-08 13:53:50 +0000
committerMatthias Sohn2013-08-23 08:49:05 +0000
commitcf80bc9ce92d3338dbd8327ab43c88ed323ac985 (patch)
treed658517a9baa34a1a394512855106266df142f24
parent50feacdf2c6c86013f032b27b8f12def34db4d41 (diff)
downloadegit-cf80bc9ce92d3338dbd8327ab43c88ed323ac985.tar.gz
egit-cf80bc9ce92d3338dbd8327ab43c88ed323ac985.tar.xz
egit-cf80bc9ce92d3338dbd8327ab43c88ed323ac985.zip
Don't automatically connect projects in /, /home or /home/username
See bug 393332 and 414629. If that's really what the user wants, it's always possible to connect it manually via Team > Share Projects... Bug: 393332 Bug: 414629 Change-Id: I0267a35950724512f7193eebf9316c737cb36a53 Signed-off-by: Robin Stocker <robin@nibor.org>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java38
1 files changed, 27 insertions, 11 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 9d70e6bd18..fc8839ddd4 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
@@ -33,6 +33,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.DefaultScope;
@@ -307,19 +308,34 @@ public class Activator extends Plugin implements DebugOptionsListener {
return false;
RepositoryFinder f = new RepositoryFinder(project);
Collection<RepositoryMapping> mappings = f.find(new NullProgressMonitor());
- try {
- if (mappings.size() == 1) {
- // connect
- RepositoryMapping m = mappings.iterator()
- .next();
- final File repositoryDir = m
- .getGitDirAbsolutePath().toFile();
+ if (mappings.size() != 1)
+ return false;
- projects.put(project, repositoryDir);
+ RepositoryMapping m = mappings.iterator().next();
+ IPath gitDirPath = m.getGitDirAbsolutePath();
+ if (gitDirPath.segmentCount() == 0)
+ return false;
- Activator.getDefault().getRepositoryUtil()
- .addConfiguredRepository(repositoryDir);
- }
+ IPath workingDir = gitDirPath.removeLastSegments(1);
+ // Don't connect "/" or "C:\"
+ if (workingDir.isRoot())
+ return false;
+
+ File userHome = FS.DETECTED.userHome();
+ if (userHome != null) {
+ Path userHomePath = new Path(userHome.getAbsolutePath());
+ // Don't connect "/home" or "/home/username"
+ if (workingDir.isPrefixOf(userHomePath))
+ return false;
+ }
+
+ // connect
+ final File repositoryDir = gitDirPath.toFile();
+ projects.put(project, repositoryDir);
+
+ try {
+ Activator.getDefault().getRepositoryUtil()
+ .addConfiguredRepository(repositoryDir);
} catch (IllegalArgumentException e) {
logError(CoreText.Activator_AutoSharingFailed, e);
}

Back to the top