summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2015-11-27 21:34:16 -0800
committerShawn Pearce <spearce@spearce.org>2015-11-27 23:25:22 -0800
commit885879ffe907a5df1c6fcc40ef6972e27dfecdd6 (patch)
tree5c56b34a996d8753a1e9b0f67ad317086d208bc1
parent46e4992e9267211a55aae03b744b50edb87740fd (diff)
downloadjgit-885879ffe907a5df1c6fcc40ef6972e27dfecdd6.tar.gz
jgit-885879ffe907a5df1c6fcc40ef6972e27dfecdd6.zip
DirCache: Fix getEntriesWithin("") to not include null entries
The internal array may be longer than entryCnt, in this case the tail of the array is padded with null entries. Do not return those to the caller of getEntriesWithin(). Change-Id: I19efb05e103fab6b739ced407f6e28155a48dba6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
index a3980d2126..6dcb9488b9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
@@ -877,8 +877,8 @@ public class DirCache {
*/
public DirCacheEntry[] getEntriesWithin(String path) {
if (path.length() == 0) {
- final DirCacheEntry[] r = new DirCacheEntry[sortedEntries.length];
- System.arraycopy(sortedEntries, 0, r, 0, sortedEntries.length);
+ DirCacheEntry[] r = new DirCacheEntry[entryCnt];
+ System.arraycopy(sortedEntries, 0, r, 0, entryCnt);
return r;
}
if (!path.endsWith("/")) //$NON-NLS-1$