summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorSkirmantas Kligys2009-10-14 21:35:03 (EDT)
committer Shawn O. Pearce2009-11-30 21:03:46 (EST)
commitefbfafde119eaa2ddd5156e19b1b73485c0f4fa6 (patch)
treeb04bc0c154ccdc2236dd5cd9f4600bc108fda940
parentcb9adcf59464fc49a555516039435c45eb6ccb60 (diff)
downloadegit-efbfafde119eaa2ddd5156e19b1b73485c0f4fa6.zip
egit-efbfafde119eaa2ddd5156e19b1b73485c0f4fa6.tar.gz
egit-efbfafde119eaa2ddd5156e19b1b73485c0f4fa6.tar.bz2
Fix RepositoryFinder to work with linked foldersrefs/changes/09/109/2
When displaying the path to a repository contained within a linked folder, use the path of the linked folder within the project as the prefix of the repository location as the repository location string is relative to that folder. When a tree node is selected without a project, use the parent tree node to acquire the project. Change-Id: If7214ca8bf10439e7e27b424864742a10dd8b766 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java6
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java14
3 files changed, 21 insertions, 4 deletions
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 4b4956e..4230543 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
@@ -14,6 +14,8 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
@@ -49,6 +51,7 @@ public class RepositoryFinder {
private final IProject proj;
private final Collection<RepositoryMapping> results = new ArrayList<RepositoryMapping>();
+ private final Set<File> gitdirs = new HashSet<File>();
/**
* Create a new finder to locate Git repositories for a project.
@@ -138,6 +141,9 @@ public class RepositoryFinder {
} catch (IOException ioe) {
f = gitdir.getAbsoluteFile();
}
+ if (gitdirs.contains(f))
+ return;
+ gitdirs.add(f);
results.add(new RepositoryMapping(c, f));
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
index a9808a2..c09a595 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
@@ -98,7 +98,10 @@ public class RepositoryMapping {
}
}
- IPath getContainerPath() {
+ /**
+ * @return the container path corresponding to git repository
+ */
+ public IPath getContainerPath() {
return Path.fromPortableString(containerPath);
}
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 8789327..d880b81 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
@@ -186,8 +186,12 @@ class ExistingOrNewPage extends WizardPage {
private void fillTreeItemWithGitDirectory(RepositoryMapping m, TreeItem treeItem2) {
if (m.getGitDir() == null)
treeItem2.setText(2, UIText.ExistingOrNewPage_SymbolicValueEmptyMapping);
- else
- treeItem2.setText(2, m.getGitDir());
+ else {
+ String container = m.getContainerPath().toString();
+ if (container.length() > 0)
+ container += File.separator;
+ treeItem2.setText(2, container + m.getGitDir());
+ }
}
private void updateCreateOptions() {
@@ -241,7 +245,11 @@ class ExistingOrNewPage extends WizardPage {
final TreeItem[] selection = tree.getSelection();
Map<IProject, File> ret = new HashMap<IProject, File>(selection.length);
for (int i = 0; i < selection.length; ++i) {
- final TreeItem treeItem = selection[i];
+ TreeItem treeItem = selection[i];
+ while (treeItem.getData() == null && treeItem.getParentItem() != null) {
+ treeItem = treeItem.getParentItem();
+ }
+
final IProject project = (IProject) treeItem.getData();
final File selectedRepo = new File(treeItem.getText(2));
File localPathToRepo = selectedRepo;