]> source.dussan.org Git - jgit.git/commitdiff
DirCache: Fix getEntriesWithin("") to not include null entries 13/61513/1
authorShawn Pearce <spearce@spearce.org>
Sat, 28 Nov 2015 05:34:16 +0000 (21:34 -0800)
committerShawn Pearce <spearce@spearce.org>
Sat, 28 Nov 2015 07:25:22 +0000 (23:25 -0800)
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

org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java

index a3980d2126020bb78389ceb2818fc9624c59f566..6dcb9488b969c017398ef35014f965dbae53d5a3 100644 (file)
@@ -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$