aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2009-10-04 17:51:16 (EDT)
committerShawn O. Pearce2009-10-16 13:00:48 (EDT)
commitdcd861db6f364c9c41a2409fd90ad2f91bcd7f54 (patch)
tree3d6cc41f527a2cb325bfebeb6dedaa4e11e9aa4c
parent07081c040d92b9129b718bd7ccd97baa71c460cb (diff)
downloadegit-dcd861db6f364c9c41a2409fd90ad2f91bcd7f54.zip
egit-dcd861db6f364c9c41a2409fd90ad2f91bcd7f54.tar.gz
egit-dcd861db6f364c9c41a2409fd90ad2f91bcd7f54.tar.bz2
Fix dialog to select Git repository locationrefs/changes/62/62/3
Previously the dialog had several bugs, this change: - Prevents infinite loop if multiple repository mappings were found - Removed break statement which prevents from inspecting upper levels - Fixed logic to find any existing git repositories. It never searched parent directories for a linked resource or project itself due to an extra 'else' statement. - Enabled repository creation if there is no '.git/' directory in the project's root. Bug: 291303 Change-Id: I47e8fd4a77083010cec880cd976d9e99a9e1ba5b Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryFinder.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/sharing/ExistingOrNewPage.java37
2 files changed, 25 insertions, 16 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 fbd9add..c2fb20a 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
@@ -94,13 +94,13 @@ public class RepositoryFinder {
if (ownCfg.isFile()) {
register(c, ownCfg.getParentFile());
- } else if (c.isLinked() || c instanceof IProject) {
+ }
+ if (c.isLinked() || c instanceof IProject) {
File p = fsLoc.getParentFile();
while (p != null) {
final File pCfg = configFor(p);
if (pCfg.isFile()) {
register(c, pCfg.getParentFile());
- break;
}
p = p.getParentFile();
}
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 7a32cb6..c546e3c 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
@@ -87,22 +87,24 @@ class ExistingOrNewPage extends WizardPage {
Collection<RepositoryMapping> find;
try {
find = repositoryFinder.find(new NullProgressMonitor());
- if (find.size() == 0)
+ Iterator<RepositoryMapping> mi = find.iterator();
+
+ // special case for a git repository in the project's root
+ final File gitDirInProjectRoot = project.getLocation().append(
+ ".git").toFile(); //$NON-NLS-1$
+ if (!gitDirInProjectRoot.isDirectory()) {
+ // '.git/' isn't there, enable repository creation
treeItem.setText(2, ""); //$NON-NLS-1$
- else {
- Iterator<RepositoryMapping> mi = find.iterator();
+ } else {
+ // '.git/' is there
+ fillTreeItemWithGitDirectory(mi.next(), treeItem);
+ }
+
+ while (mi.hasNext()) {
RepositoryMapping m = mi.next();
- if (m.getGitDir() == null)
- treeItem.setText(2,UIText.ExistingOrNewPage_SymbolicValueEmptyMapping);
- else
- treeItem.setText(2, m.getGitDir());
- while (mi.hasNext()) {
- TreeItem treeItem2 = new TreeItem(treeItem, SWT.NONE);
- if (m.getGitDir() == null)
- treeItem2.setText(2,UIText.ExistingOrNewPage_SymbolicValueEmptyMapping);
- else
- treeItem2.setText(2,m.getGitDir());
- }
+ TreeItem treeItem2 = new TreeItem(treeItem, SWT.NONE);
+ treeItem2.setData(m.getContainer().getProject());
+ fillTreeItemWithGitDirectory(m, treeItem2);
}
} catch (CoreException e) {
TreeItem treeItem2 = new TreeItem(treeItem, SWT.BOLD|SWT.ITALIC);
@@ -177,6 +179,13 @@ class ExistingOrNewPage extends WizardPage {
setControl(g);
}
+ private void fillTreeItemWithGitDirectory(RepositoryMapping m, TreeItem treeItem2) {
+ if (m.getGitDir() == null)
+ treeItem2.setText(2, UIText.ExistingOrNewPage_SymbolicValueEmptyMapping);
+ else
+ treeItem2.setText(2, m.getGitDir());
+ }
+
private void updateCreateOptions() {
minumumPath = null;
IPath p = null;