Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Bossert2016-02-16 10:05:56 -0500
committerMatthias Sohn2016-03-14 19:33:13 -0400
commit1272016c626438a9a5a7824147d241168dceb303 (patch)
tree9fb5e76ba12eed967ac5a754d3cb6b6c10f0af58
parente47bced605873c5e82705f9a8184f540d1dbb586 (diff)
downloadegit-1272016c626438a9a5a7824147d241168dceb303.tar.gz
egit-1272016c626438a9a5a7824147d241168dceb303.tar.xz
egit-1272016c626438a9a5a7824147d241168dceb303.zip
Delegate detection of git repositories to JGit
This prepares EGit to still properly detect git repositories when JGit change "https://git.eclipse.org/r/#/c/67873/" adds the evaluation of ".git" file with "gitdir" link to worktree and evaluates commondir. Bug: 477475 Change-Id: Id1a54e0efb6fb7334ea4cb4a5507ed3e0bff0f7e Signed-off-by: Andre Bossert <anb0s@anbos.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java22
2 files changed, 12 insertions, 15 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
index efc753ba1..e7b2852d9 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
@@ -53,8 +53,10 @@ import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.RepositoryCache;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.storage.file.WindowCacheConfig;
+import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.RepositoryProvider;
@@ -612,7 +614,8 @@ public class GitProjectData {
return;
}
git = absolutePath.toFile();
- if (!git.isDirectory() || !new File(git, "config").isFile()) { //$NON-NLS-1$
+
+ if (!RepositoryCache.FileKey.isGitRepository(git, FS.DETECTED)) {
logAndUnmapGoneMappedResource(m);
return;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java
index 35c14653b..ddc510715 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositorySearchDialog.java
@@ -42,7 +42,6 @@ import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.RepositoryCache.FileKey;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
@@ -419,19 +418,14 @@ public class RepositorySearchDialog extends WizardPage {
if (!child.isDirectory())
continue;
- if (FileKey.isGitRepository(child, FS.DETECTED)) {
- strings.add(child.getAbsoluteFile());
- monitor.setTaskName(NLS
- .bind(UIText.RepositorySearchDialog_RepositoriesFound_message,
- Integer.valueOf(strings.size())));
- } else if (FileKey.isGitRepository(new File(child,
- Constants.DOT_GIT), FS.DETECTED)) {
- strings.add(
- new File(child, Constants.DOT_GIT).getAbsoluteFile());
- monitor.setTaskName(NLS
- .bind(UIText.RepositorySearchDialog_RepositoriesFound_message,
- Integer.valueOf(strings.size())));
- } else if (lookForNestedRepositories) {
+ File resolved = FileKey.resolve(child, FS.DETECTED);
+ if (resolved != null) {
+ strings.add(resolved.getAbsoluteFile());
+ monitor.setTaskName(NLS.bind(
+ UIText.RepositorySearchDialog_RepositoriesFound_message,
+ Integer.valueOf(strings.size())));
+ }
+ else if (lookForNestedRepositories) {
monitor.subTask(child.getPath());
findGitDirsRecursive(child, strings, monitor,
lookForNestedRepositories);

Back to the top