|
|
@ -286,7 +286,7 @@ public class FileTreeIteratorTest extends RepositoryTestCase { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testTreewalkEnterSubtree() throws Exception { |
|
|
|
public void testTreewalkEnterSubtree() throws Exception { |
|
|
|
try (Git git = new Git(db)) { |
|
|
|
try (Git git = new Git(db); TreeWalk tw = new TreeWalk(db)) { |
|
|
|
writeTrashFile("b/c", "b/c"); |
|
|
|
writeTrashFile("b/c", "b/c"); |
|
|
|
writeTrashFile("z/.git", "gitdir: /tmp/somewhere"); |
|
|
|
writeTrashFile("z/.git", "gitdir: /tmp/somewhere"); |
|
|
|
git.add().addFilepattern(".").call(); |
|
|
|
git.add().addFilepattern(".").call(); |
|
|
@ -297,7 +297,6 @@ public class FileTreeIteratorTest extends RepositoryTestCase { |
|
|
|
FileUtils.delete(new File(db.getWorkTree(), "b"), |
|
|
|
FileUtils.delete(new File(db.getWorkTree(), "b"), |
|
|
|
FileUtils.RECURSIVE); |
|
|
|
FileUtils.RECURSIVE); |
|
|
|
|
|
|
|
|
|
|
|
TreeWalk tw = new TreeWalk(db); |
|
|
|
|
|
|
|
tw.addTree(new DirCacheIterator(db.readDirCache())); |
|
|
|
tw.addTree(new DirCacheIterator(db.readDirCache())); |
|
|
|
tw.addTree(new FileTreeIterator(db)); |
|
|
|
tw.addTree(new FileTreeIterator(db)); |
|
|
|
assertTrue(tw.next()); |
|
|
|
assertTrue(tw.next()); |
|
|
@ -617,40 +616,42 @@ public class FileTreeIteratorTest extends RepositoryTestCase { |
|
|
|
public void testCustomFileModeStrategy() throws Exception { |
|
|
|
public void testCustomFileModeStrategy() throws Exception { |
|
|
|
Repository nestedRepo = createNestedRepo(); |
|
|
|
Repository nestedRepo = createNestedRepo(); |
|
|
|
|
|
|
|
|
|
|
|
Git git = new Git(nestedRepo); |
|
|
|
try (Git git = new Git(nestedRepo)) { |
|
|
|
// validate that our custom strategy is honored
|
|
|
|
// validate that our custom strategy is honored
|
|
|
|
WorkingTreeIterator customIterator = |
|
|
|
WorkingTreeIterator customIterator = new FileTreeIterator( |
|
|
|
new FileTreeIterator(nestedRepo, NO_GITLINKS_STRATEGY); |
|
|
|
nestedRepo, NO_GITLINKS_STRATEGY); |
|
|
|
git.add().setWorkingTreeIterator(customIterator) |
|
|
|
git.add().setWorkingTreeIterator(customIterator).addFilepattern(".") |
|
|
|
.addFilepattern(".").call(); |
|
|
|
.call(); |
|
|
|
assertEquals( |
|
|
|
assertEquals( |
|
|
|
"[sub/a.txt, mode:100644, content:content]" + |
|
|
|
"[sub/a.txt, mode:100644, content:content]" |
|
|
|
"[sub/nested/b.txt, mode:100644, content:content b]", |
|
|
|
+ "[sub/nested/b.txt, mode:100644, content:content b]", |
|
|
|
indexState(nestedRepo, CONTENT)); |
|
|
|
indexState(nestedRepo, CONTENT)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testCustomFileModeStrategyFromParentIterator() throws Exception { |
|
|
|
public void testCustomFileModeStrategyFromParentIterator() throws Exception { |
|
|
|
Repository nestedRepo = createNestedRepo(); |
|
|
|
Repository nestedRepo = createNestedRepo(); |
|
|
|
|
|
|
|
|
|
|
|
Git git = new Git(nestedRepo); |
|
|
|
try (Git git = new Git(nestedRepo)) { |
|
|
|
|
|
|
|
FileTreeIterator customIterator = new FileTreeIterator(nestedRepo, |
|
|
|
FileTreeIterator customIterator = |
|
|
|
NO_GITLINKS_STRATEGY); |
|
|
|
new FileTreeIterator(nestedRepo, NO_GITLINKS_STRATEGY); |
|
|
|
|
|
|
|
File r = new File(nestedRepo.getWorkTree(), "sub"); |
|
|
|
File r = new File(nestedRepo.getWorkTree(), "sub"); |
|
|
|
|
|
|
|
|
|
|
|
// here we want to validate that if we create a new iterator using the
|
|
|
|
// here we want to validate that if we create a new iterator using
|
|
|
|
// constructor that accepts a parent iterator, that the child iterator
|
|
|
|
// the constructor that accepts a parent iterator, that the child
|
|
|
|
// correctly inherits the FileModeStrategy from the parent iterator.
|
|
|
|
// iterator correctly inherits the FileModeStrategy from the parent
|
|
|
|
FileTreeIterator childIterator = |
|
|
|
// iterator.
|
|
|
|
new FileTreeIterator(customIterator, r, nestedRepo.getFS()); |
|
|
|
FileTreeIterator childIterator = new FileTreeIterator( |
|
|
|
git.add().setWorkingTreeIterator(childIterator).addFilepattern(".").call(); |
|
|
|
customIterator, r, nestedRepo.getFS()); |
|
|
|
|
|
|
|
git.add().setWorkingTreeIterator(childIterator).addFilepattern(".") |
|
|
|
|
|
|
|
.call(); |
|
|
|
assertEquals( |
|
|
|
assertEquals( |
|
|
|
"[sub/a.txt, mode:100644, content:content]" + |
|
|
|
"[sub/a.txt, mode:100644, content:content]" |
|
|
|
"[sub/nested/b.txt, mode:100644, content:content b]", |
|
|
|
+ "[sub/nested/b.txt, mode:100644, content:content b]", |
|
|
|
indexState(nestedRepo, CONTENT)); |
|
|
|
indexState(nestedRepo, CONTENT)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void assertEntry(String sha1string, String path, TreeWalk tw) |
|
|
|
private static void assertEntry(String sha1string, String path, TreeWalk tw) |
|
|
|