From 667f571b266f7c0dab952733c22bb5f029754f44 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 24 Dec 2009 15:48:32 +0100 Subject: [PATCH] Fix enabling team operations on project import The old code only worked if .git directory was one level above the Eclipse projects being imported. Bug: 298027 Change-Id: I5eb0a867b2d6fa8e1f63abfa2291950507fdf3f3 Signed-off-by: Matthias Sohn --- .../org/eclipse/egit/core/op/CloneOperation.java | 12 ++++++- .../egit/core/op/ConnectProviderOperation.java | 6 ++-- .../egit/core/project/RepositoryMapping.java | 7 ++++ .../egit/ui/internal/clone/GitCloneWizard.java | 1 + .../ui/internal/clone/GitProjectsImportPage.java | 37 ++++++++++------------ 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CloneOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CloneOperation.java index 91b32656..bc3f9fb0 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CloneOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CloneOperation.java @@ -54,6 +54,8 @@ public class CloneOperation implements IRunnableWithProgress { private final File workdir; + private final File gitdir; + private final String branch; private final String remoteName; @@ -91,6 +93,7 @@ public class CloneOperation implements IRunnableWithProgress { this.allSelected = allSelected; this.selectedBranches = selectedBranches; this.workdir = workdir; + this.gitdir = new File(workdir, Constants.DOT_GIT); this.branch = branch; this.remoteName = remoteName; } @@ -124,6 +127,14 @@ public class CloneOperation implements IRunnableWithProgress { } } + + /** + * @return The git directory which will contain the repository + */ + public File getGitDir() { + return gitdir; + } + private void closeLocal() { if (local != null) { local.close(); @@ -135,7 +146,6 @@ public class CloneOperation implements IRunnableWithProgress { throws URISyntaxException, IOException { monitor.setTaskName("Initializing local repository"); - final File gitdir = new File(workdir, Constants.DOT_GIT); local = new Repository(gitdir); local.create(); 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 9b5a316d..5913f30d 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 @@ -127,16 +127,16 @@ public class ConnectProviderOperation implements IWorkspaceRunnable { /** * @param repos - * available repositories + * available repositories * @param suggestedRepo - * relative path to git repository + * relative path to git repository * @return a repository mapping which corresponds to a suggested repository * location, null otherwise */ private RepositoryMapping findActualRepository( Collection repos, File suggestedRepo) { for (RepositoryMapping rm : repos) { - if (Path.fromOSString(rm.getGitDir()).equals(Path.fromOSString(suggestedRepo.getPath()))) + if (rm.getGitDirAbsolutePath().equals(Path.fromOSString(suggestedRepo.getPath()))) return rm; } return null; 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 6c399836..68da5580 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 @@ -253,4 +253,11 @@ public class RepositoryMapping { public String getGitDir() { return gitdirPath; } + + /** + * @return The GIT DIR absolute path + */ + public IPath getGitDirAbsolutePath() { + return container.getLocation().append(getGitDirPath()); + } } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java index e840e8d8..3d9103e7 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitCloneWizard.java @@ -140,6 +140,7 @@ public class GitCloneWizard extends Wizard implements IImportWizard { final CloneOperation op = new CloneOperation(uri, allSelected, selectedBranches, workdir, branch, remoteName); + importProject.setGitDir(op.getGitDir()); if (background) { final Job job = new Job(NLS.bind(UIText.GitCloneWizard_jobName, uri .toString())) { diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java index f988aa24..6ff3c579 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java @@ -83,6 +83,11 @@ public class GitProjectsImportPage extends WizardPage { */ private IImportStructureProvider structureProvider; + /** + * The git directory which will contain the repository + */ + private File gitDir; + class ProjectRecord { File projectSystemFile; @@ -95,12 +100,6 @@ public class GitProjectsImportPage extends WizardPage { IProjectDescription description; /** - * Relative path to repository, '../.git' is by default. If you'll set - * it null you're on your own, no checks for null performed. - */ - File repository = new File("../.git"); //$NON-NLS-1$ - - /** * Create a record for a project based on the info in the file. * * @param file @@ -111,19 +110,6 @@ public class GitProjectsImportPage extends WizardPage { } /** - * Create a record for a project based on the info in the file. - * - * @param file - * @param aRepository - * relative path to repository - */ - ProjectRecord(File file, File aRepository) { - projectSystemFile = file; - setProjectName(); - repository = aRepository; - } - - /** * @param parent * The parent folder of the .project file * @param level @@ -216,7 +202,7 @@ public class GitProjectsImportPage extends WizardPage { private String lastPath; // The last time that the file or folder at the selected path was modified - // to mimize searches + // to minimize searches private long lastModified; private Button shareCheckBox; @@ -486,6 +472,15 @@ public class GitProjectsImportPage extends WizardPage { } /** + * Set the git directory which will contain the repository + * + * @param gitDir + */ + public void setGitDir(File gitDir) { + this.gitDir = gitDir; + } + + /** * Update the list of projects based on path. * * @param path @@ -732,7 +727,7 @@ public class GitProjectsImportPage extends WizardPage { monitor, openTicks)); if (share) { ConnectProviderOperation connectProviderOperation = new ConnectProviderOperation( - project, record.repository); + project, gitDir); connectProviderOperation .run(new SubProgressMonitor(monitor, 20)); } -- 2.11.4.GIT