Browse Source

Merge "Fix DirCache,getEntriesWithin for empty string arguemnt"

stable-1.2
Christian Halstrick 13 years ago committed by Code Review
parent
commit
d306c35cea
  1. 7
      org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheFindTest.java
  2. 5
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java

7
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheFindTest.java vendored

@ -88,6 +88,13 @@ public class DirCacheFindTest extends RepositoryTestCase {
for (int i = aFirst, j = 0; i <= aLast; i++, j++)
assertSame(ents[i], aContents[j]);
}
{
final DirCacheEntry[] aContents = dc.getEntriesWithin("");
assertNotNull(aContents);
assertEquals(ents.length, aContents.length);
for (int i = 0; i < ents.length; i++)
assertSame(ents[i], aContents[i]);
}
assertNotNull(dc.getEntriesWithin("a."));
assertEquals(0, dc.getEntriesWithin("a.").length);

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

@ -712,6 +712,11 @@ public class DirCache {
* @return all entries recursively contained within the subtree.
*/
public DirCacheEntry[] getEntriesWithin(String path) {
if (path.length() == 0) {
final DirCacheEntry[] r = new DirCacheEntry[sortedEntries.length];
System.arraycopy(sortedEntries, 0, r, 0, sortedEntries.length);
return r;
}
if (!path.endsWith("/"))
path += "/";
final byte[] p = Constants.encode(path);

Loading…
Cancel
Save