Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-10-20 06:52:28 -0400
committerThomas Wolf2019-10-27 05:28:07 -0400
commitcca58bb545e144e9cc521f3786785feacb8f1953 (patch)
tree7270c892814a65c3d358183e315ed4fb4c8bf75e
parentd844df59a85500dd989523f04ebdfecdfc4c2414 (diff)
downloadegit-cca58bb545e144e9cc521f3786785feacb8f1953.tar.gz
egit-cca58bb545e144e9cc521f3786785feacb8f1953.tar.xz
egit-cca58bb545e144e9cc521f3786785feacb8f1953.zip
Simplify decoration for submodules node
Instead of doing a SubmoduleWalk rely on the IndexDiff of the parent repository: this already reports modified submodules. As a side-effect this will also honor the ignore settings in .gitmodules. Bug: 550878 Change-Id: Ia098fc559d87f27b1371fc6834b84a0435593317 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeDecorator.java36
1 files changed, 18 insertions, 18 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeDecorator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeDecorator.java
index d462fe03dd..4420db0b24 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeDecorator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryTreeNodeDecorator.java
@@ -12,11 +12,15 @@ package org.eclipse.egit.ui.internal.repository;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.Set;
import org.eclipse.core.commands.IStateListener;
import org.eclipse.core.commands.State;
import org.eclipse.egit.core.RepositoryUtil;
import org.eclipse.egit.core.internal.Utils;
+import org.eclipse.egit.core.internal.indexdiff.IndexDiffCache;
+import org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry;
+import org.eclipse.egit.core.internal.indexdiff.IndexDiffData;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.CommonUtils;
import org.eclipse.egit.ui.internal.GitLabels;
@@ -39,7 +43,6 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
-import org.eclipse.jgit.submodule.SubmoduleWalk;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.RegistryToggleState;
@@ -248,7 +251,7 @@ public class RepositoryTreeNodeDecorator extends GitDecorator
}
private boolean decorateSubmodules(@NonNull Repository repository,
- IDecoration decoration) throws IOException {
+ IDecoration decoration) {
if (haveSubmoduleChanges(repository)) {
decoration.addPrefix("> "); //$NON-NLS-1$
return true;
@@ -293,23 +296,20 @@ public class RepositoryTreeNodeDecorator extends GitDecorator
}
}
- private boolean haveSubmoduleChanges(@NonNull Repository repository)
- throws IOException {
- boolean hasChanges = false;
- try (SubmoduleWalk walk = SubmoduleWalk.forIndex(repository)) {
- while (!hasChanges && walk.next()) {
- Repository submodule = walk.getRepository();
- if (submodule != null) {
- Repository cached = org.eclipse.egit.core.Activator
- .getDefault().getRepositoryCache().lookupRepository(
- submodule.getDirectory().getAbsoluteFile());
- hasChanges = cached != null
- && RepositoryUtil.hasChanges(cached);
- submodule.close();
- }
- }
+ private boolean haveSubmoduleChanges(@NonNull Repository repository) {
+ IndexDiffCache cache = org.eclipse.egit.core.Activator.getDefault()
+ .getIndexDiffCache();
+ if (cache == null) {
+ return false;
+ }
+ IndexDiffCacheEntry entry = cache.getIndexDiffCacheEntry(repository);
+ IndexDiffData data = entry != null ? entry.getIndexDiff() : null;
+ if (data == null) {
+ return false;
}
- return hasChanges;
+ Set<String> modified = data.getModified();
+ return data.getSubmodules().stream()
+ .anyMatch(s -> modified.contains(s));
}
@Override

Back to the top