summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard <axel.richard@obeo.fr>2014-11-05 09:30:47 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2014-11-06 09:40:29 +0100
commit5328c8c9164414a63ce7f1323d8194b84b6f1e49 (patch)
treec60023031813d3a88f9e29b89136aceb88a3d8d9
parent2532c28cb93ccb8e674ef374f08fb3bf246c353b (diff)
downloadjgit-5328c8c9164414a63ce7f1323d8194b84b6f1e49.tar.gz
jgit-5328c8c9164414a63ce7f1323d8194b84b6f1e49.zip
Add new method IndexDiff#getPathsWithIndexMode
Get the list of paths that have the given file mode. This helps EGit to efficiently determine which modified files are symlinks and should be shown with a symlink icon in the staging view. Bug: 429302 Change-Id: Id15f0c6f265667f5b8b57cc2d9f97de568371919 Signed-off-by: Axel Richard <axel.richard@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
index 1e0a764682..1acfa3d681 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
@@ -3,6 +3,7 @@
* Copyright (C) 2007-2008, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
* Copyright (C) 2013, Robin Stocker <robin@nibor.org>
+ * Copyright (C) 2014, Axel Richard <axel.richard@obeo.fr>
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -276,6 +277,8 @@ public class IndexDiff {
private IgnoreSubmoduleMode ignoreSubmoduleMode = null;
+ private Map<FileMode, Set<String>> fileModes = new HashMap<FileMode, Set<String>>();
+
/**
* Construct an IndexDiff
*
@@ -425,6 +428,7 @@ public class IndexDiff {
indexDiffFilter = new IndexDiffFilter(INDEX, WORKDIR);
filters.add(indexDiffFilter);
treeWalk.setFilter(AndTreeFilter.create(filters));
+ fileModes.clear();
while (treeWalk.next()) {
AbstractTreeIterator treeIterator = treeWalk.getTree(TREE,
AbstractTreeIterator.class);
@@ -497,6 +501,17 @@ public class IndexDiff {
}
}
}
+
+ for (int i = 0; i < treeWalk.getTreeCount(); i++) {
+ Set<String> values = fileModes.get(treeWalk.getFileMode(i));
+ String path = treeWalk.getPathString();
+ if (path != null) {
+ if (values == null)
+ values = new HashSet<String>();
+ values.add(path);
+ fileModes.put(treeWalk.getFileMode(i), values);
+ }
+ }
}
if (ignoreSubmoduleMode != IgnoreSubmoduleMode.ALL) {
@@ -539,6 +554,7 @@ public class IndexDiff {
}
}
}
+
}
// consume the remaining work
@@ -675,4 +691,20 @@ public class IndexDiff {
final DirCacheEntry entry = dirCache.getEntry(path);
return entry != null ? entry.getFileMode() : FileMode.MISSING;
}
+
+ /**
+ * Get the list of paths that IndexDiff has detected to differ and have the
+ * given file mode
+ *
+ * @param mode
+ * @return the list of paths that IndexDiff has detected to differ and have
+ * the given file mode
+ * @since 3.6
+ */
+ public Set<String> getPathsWithIndexMode(final FileMode mode) {
+ Set<String> paths = fileModes.get(mode);
+ if (paths == null)
+ paths = new HashSet<String>();
+ return paths;
+ }
}