Browse Source

Merge changes I6e022e4a,If1b9d808

* changes:
  Close TreeWalks in tests
  Close SubmoduleWalks in tests
next
David Pursehouse 5 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
51b24ea17c
  1. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
  2. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
  3. 36
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java
  4. 15
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java
  5. 527
      org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java
  6. 109
      org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeDirCacheIteratorTest.java
  7. 99
      org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeWorkingTreeIteratorTest.java
  8. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java
  9. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java
  10. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java
  11. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
  12. 11
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java
  13. 19
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleDeinitTest.java
  14. 42
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleInitTest.java
  15. 14
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleSyncTest.java
  16. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleUpdateTest.java
  17. 35
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
  18. 7
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java
  19. 15
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java
  20. 114
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/IndexDiffFilterTest.java

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java

@ -646,7 +646,8 @@ public class CloneCommandTest extends RepositoryTestCase {
assertEquals(sub1Head, pathStatus.getHeadId());
assertEquals(sub1Head, pathStatus.getIndexId());
SubmoduleWalk walk = SubmoduleWalk.forIndex(git2.getRepository());
try (SubmoduleWalk walk = SubmoduleWalk
.forIndex(git2.getRepository())) {
assertTrue(walk.next());
try (Repository clonedSub1 = walk.getRepository()) {
assertNotNull(clonedSub1);
@ -659,12 +660,13 @@ public class CloneCommandTest extends RepositoryTestCase {
status = new SubmoduleStatusCommand(clonedSub1);
statuses = status.call();
}
assertFalse(walk.next());
}
pathStatus = statuses.get(path);
assertNotNull(pathStatus);
assertEquals(SubmoduleStatusType.INITIALIZED, pathStatus.getType());
assertEquals(sub2Head, pathStatus.getHeadId());
assertEquals(sub2Head, pathStatus.getIndexId());
assertFalse(walk.next());
}
@Test

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java

@ -148,9 +148,10 @@ public class CommitCommandTest extends RepositoryTestCase {
writeTrashFile(path, "content");
git.add().addFilepattern(path).call();
RevCommit commit1 = git.commit().setMessage("commit").call();
TreeWalk walk = TreeWalk.forPath(db, path, commit1.getTree());
try (TreeWalk walk = TreeWalk.forPath(db, path, commit1.getTree())) {
assertNotNull(walk);
assertEquals(FileMode.EXECUTABLE_FILE, walk.getFileMode(0));
}
FS nonExecutableFs = new FS() {
@ -204,10 +205,11 @@ public class CommitCommandTest extends RepositoryTestCase {
writeTrashFile(path, "content2");
RevCommit commit2 = git2.commit().setOnly(path).setMessage("commit2")
.call();
walk = TreeWalk.forPath(db, path, commit2.getTree());
try (TreeWalk walk = TreeWalk.forPath(db, path, commit2.getTree())) {
assertNotNull(walk);
assertEquals(FileMode.EXECUTABLE_FILE, walk.getFileMode(0));
}
}
@Test
public void commitNewSubmodule() throws Exception {
@ -225,7 +227,7 @@ public class CommitCommandTest extends RepositoryTestCase {
assertNotNull(repo);
addRepoToClose(repo);
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals(path, generator.getPath());
assertEquals(commit, generator.getObjectId());
@ -235,6 +237,7 @@ public class CommitCommandTest extends RepositoryTestCase {
try (Repository subModRepo = generator.getRepository()) {
assertNotNull(subModRepo);
}
}
assertEquals(commit, repo.resolve(Constants.HEAD));
RevCommit submoduleCommit = git.commit().setMessage("submodule add")
@ -275,7 +278,7 @@ public class CommitCommandTest extends RepositoryTestCase {
assertNotNull(repo);
addRepoToClose(repo);
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals(path, generator.getPath());
assertEquals(commit2, generator.getObjectId());
@ -285,6 +288,7 @@ public class CommitCommandTest extends RepositoryTestCase {
try (Repository subModRepo = generator.getRepository()) {
assertNotNull(subModRepo);
}
}
assertEquals(commit2, repo.resolve(Constants.HEAD));
RevCommit submoduleAddCommit = git.commit().setMessage("submodule add")

36
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java

@ -142,8 +142,6 @@ public class EolRepositoryTest extends RepositoryTestCase {
protected String CONTENT_MIXED;
private TreeWalk walk;
/** work tree root .gitattributes */
private File dotGitattributes;
@ -689,27 +687,25 @@ public class EolRepositoryTest extends RepositoryTestCase {
private void collectRepositoryState() throws Exception {
dirCache = db.readDirCache();
walk = beginWalk();
if (dotGitattributes != null)
collectEntryContentAndAttributes(F, ".gitattributes", null);
collectEntryContentAndAttributes(F, fileCRLF.getName(), entryCRLF);
collectEntryContentAndAttributes(F, fileLF.getName(), entryLF);
collectEntryContentAndAttributes(F, fileMixed.getName(), entryMixed);
endWalk();
}
private TreeWalk beginWalk() throws Exception {
TreeWalk newWalk = new TreeWalk(db);
newWalk.addTree(new FileTreeIterator(db));
newWalk.addTree(new DirCacheIterator(db.readDirCache()));
return newWalk;
}
private void endWalk() throws IOException {
try (TreeWalk walk = new TreeWalk(db)) {
walk.addTree(new FileTreeIterator(db));
walk.addTree(new DirCacheIterator(db.readDirCache()));
if (dotGitattributes != null) {
collectEntryContentAndAttributes(walk, F, ".gitattributes",
null);
}
collectEntryContentAndAttributes(walk, F, fileCRLF.getName(),
entryCRLF);
collectEntryContentAndAttributes(walk, F, fileLF.getName(),
entryLF);
collectEntryContentAndAttributes(walk, F, fileMixed.getName(),
entryMixed);
assertFalse("Not all files tested", walk.next());
}
}
private void collectEntryContentAndAttributes(FileMode type, String pathName,
private void collectEntryContentAndAttributes(TreeWalk walk, FileMode type,
String pathName,
ActualEntry e) throws IOException {
assertTrue("walk has entry", walk.next());

15
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchAndPullCommandsRecurseSubmodulesTest.java

@ -343,19 +343,22 @@ public class FetchAndPullCommandsRecurseSubmodulesTest extends RepositoryTestCas
private void assertSubmoduleFetchHeads(ObjectId expectedHead1,
ObjectId expectedHead2) throws Exception {
Object newHead1 = null;
ObjectId newHead2 = null;
try (SubmoduleWalk walk = SubmoduleWalk
.forIndex(git2.getRepository())) {
assertTrue(walk.next());
Repository r = walk.getRepository();
ObjectId newHead1 = r.resolve(Constants.FETCH_HEAD);
ObjectId newHead2;
try (Repository r = walk.getRepository()) {
newHead1 = r.resolve(Constants.FETCH_HEAD);
try (SubmoduleWalk walk2 = SubmoduleWalk.forIndex(r)) {
assertTrue(walk2.next());
newHead2 = walk2.getRepository().resolve(Constants.FETCH_HEAD);
try (Repository r2 = walk2.getRepository()) {
newHead2 = r2.resolve(Constants.FETCH_HEAD);
}
}
}
}
assertEquals(expectedHead1, newHead1);
assertEquals(expectedHead2, newHead2);
}
}
}

527
org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java

@ -69,83 +69,90 @@ public class AttributesHandlerTest extends RepositoryTestCase {
private static final FileMode F = FileMode.REGULAR_FILE;
private TreeWalk walk;
@Test
public void testExpandNonMacro1() throws Exception {
setupRepo(null, null, null, "*.txt text");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("text"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("text"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testExpandNonMacro2() throws Exception {
setupRepo(null, null, null, "*.txt -text");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("-text"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("-text"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testExpandNonMacro3() throws Exception {
setupRepo(null, null, null, "*.txt !text");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs(""));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs(""));
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testExpandNonMacro4() throws Exception {
setupRepo(null, null, null, "*.txt text=auto");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("text=auto"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("text=auto"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testExpandBuiltInMacro1() throws Exception {
setupRepo(null, null, null, "*.txt binary");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("binary -diff -merge -text"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt",
attrs("binary -diff -merge -text"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testExpandBuiltInMacro2() throws Exception {
setupRepo(null, null, null, "*.txt -binary");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("-binary diff merge text"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt",
attrs("-binary diff merge text"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testExpandBuiltInMacro3() throws Exception {
setupRepo(null, null, null, "*.txt !binary");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs(""));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs(""));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -153,44 +160,48 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(
"[attr]foo a -b !c d=e", null, null, "*.txt foo");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("foo a -b d=e"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("foo a -b d=e"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testCustomGlobalMacro2() throws Exception {
setupRepo("[attr]foo a -b !c d=e", null, null, "*.txt -foo");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("-foo -a b d=e"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("-foo -a b d=e"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testCustomGlobalMacro3() throws Exception {
setupRepo("[attr]foo a -b !c d=e", null, null, "*.txt !foo");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs(""));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs(""));
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testCustomGlobalMacro4() throws Exception {
setupRepo("[attr]foo a -b !c d=e", null, null, "*.txt foo=bar");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("foo=bar a -b d=bar"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("foo=bar a -b d=bar"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -198,11 +209,12 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo("[attr]foo bar1",
"[attr]foo bar2", null, "*.txt foo");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("foo bar2"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("foo bar2"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -211,12 +223,13 @@ public class AttributesHandlerTest extends RepositoryTestCase {
null,
"[attr]foo bar3", "*.txt foo");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("foo bar3"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("foo bar3"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -224,12 +237,13 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo("[attr]foo bar1",
"[attr]foo bar2", "[attr]foo bar3", "*.txt foo");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("foo bar2"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("foo bar2"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -238,11 +252,12 @@ public class AttributesHandlerTest extends RepositoryTestCase {
"[attr]foo x bar -foo",
null, null, "*.txt foo");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("foo x bar"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("foo x bar"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -250,11 +265,12 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(
"[attr]foo x -bar\n[attr]bar y -foo", null, null, "*.txt foo");
walk = beginWalk();
assertIteration(D, "sub");
assertIteration(F, "sub/.gitattributes");
assertIteration(F, "sub/a.txt", attrs("foo x -bar -y"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/.gitattributes");
assertIteration(walk, F, "sub/a.txt", attrs("foo x -bar -y"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -266,23 +282,30 @@ public class AttributesHandlerTest extends RepositoryTestCase {
// apply to any of the files here. It would match for a
// further subdirectory sub/sub. The sub/ rules must match
// only for directories.
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "sub", attrs("global"));
assertIteration(F, "sub/.gitattributes", attrs("init top_sub"));
assertIteration(F, "sub/a.txt", attrs("init foo top top_sub"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "sub", attrs("global"));
assertIteration(walk, F, "sub/.gitattributes",
attrs("init top_sub"));
assertIteration(walk, F, "sub/a.txt",
attrs("init foo top top_sub"));
assertFalse("Not all files tested", walk.next());
}
// All right, let's see that they *do* apply in sub/sub:
writeTrashFile("sub/sub/b.txt", "b");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "sub", attrs("global"));
assertIteration(F, "sub/.gitattributes", attrs("init top_sub"));
assertIteration(F, "sub/a.txt", attrs("init foo top top_sub"));
assertIteration(D, "sub/sub", attrs("init subsub2 top_sub global"));
assertIteration(F, "sub/sub/b.txt",
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "sub", attrs("global"));
assertIteration(walk, F, "sub/.gitattributes",
attrs("init top_sub"));
assertIteration(walk, F, "sub/a.txt",
attrs("init foo top top_sub"));
assertIteration(walk, D, "sub/sub",
attrs("init subsub2 top_sub global"));
assertIteration(walk, F, "sub/sub/b.txt",
attrs("init foo subsub top top_sub"));
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -293,16 +316,17 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/b.jar", "bj");
writeTrashFile("sub/b.xml", "bx");
// On foo.xml/bar.jar we must not have 'xml'
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo.xml", attrs("xml"));
assertIteration(F, "foo.xml/bar.jar", attrs("jar"));
assertIteration(F, "foo.xml/bar.xml", attrs("xml"));
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(F, "sub/b.jar", attrs("jar"));
assertIteration(F, "sub/b.xml", attrs("xml"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo.xml", attrs("xml"));
assertIteration(walk, F, "foo.xml/bar.jar", attrs("jar"));
assertIteration(walk, F, "foo.xml/bar.xml", attrs("xml"));
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, F, "sub/b.jar", attrs("jar"));
assertIteration(walk, F, "sub/b.xml", attrs("xml"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -314,18 +338,19 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/b.jar", "bj");
writeTrashFile("sub/b.xml", "bx");
writeTrashFile("sub/foo/b.jar", "bf");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo", attrs("xml"));
assertIteration(F, "foo/bar.jar", attrs("jar"));
assertIteration(F, "foo/bar.xml");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(F, "sub/b.jar", attrs("jar"));
assertIteration(F, "sub/b.xml");
assertIteration(D, "sub/foo", attrs("sub xml"));
assertIteration(F, "sub/foo/b.jar", attrs("jar"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo", attrs("xml"));
assertIteration(walk, F, "foo/bar.jar", attrs("jar"));
assertIteration(walk, F, "foo/bar.xml");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, F, "sub/b.jar", attrs("jar"));
assertIteration(walk, F, "sub/b.xml");
assertIteration(walk, D, "sub/foo", attrs("sub xml"));
assertIteration(walk, F, "sub/foo/b.jar", attrs("jar"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -337,18 +362,19 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/b.xml", "bx");
writeTrashFile("sub/foo/b.jar", "bf");
// On foo.xml/bar.jar we must not have 'xml'
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo");
assertIteration(F, "foo/bar.jar", attrs("jar xml"));
assertIteration(F, "foo/bar.xml", attrs("xml"));
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(F, "sub/b.jar", attrs("jar"));
assertIteration(F, "sub/b.xml");
assertIteration(D, "sub/foo");
assertIteration(F, "sub/foo/b.jar", attrs("jar"));
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo");
assertIteration(walk, F, "foo/bar.jar", attrs("jar xml"));
assertIteration(walk, F, "foo/bar.xml", attrs("xml"));
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, F, "sub/b.jar", attrs("jar"));
assertIteration(walk, F, "sub/b.xml");
assertIteration(walk, D, "sub/foo");
assertIteration(walk, F, "sub/foo/b.jar", attrs("jar"));
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -357,27 +383,29 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/a.txt", "1");
writeTrashFile("foo/sext", "2");
writeTrashFile("foo/s.txt", "3");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo");
assertIteration(F, "foo/s.txt", attrs("bar"));
assertIteration(F, "foo/sext", attrs("bar"));
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo");
assertIteration(walk, F, "foo/s.txt", attrs("bar"));
assertIteration(walk, F, "foo/sext", attrs("bar"));
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertFalse("Not all files tested", walk.next());
}
}
@Test
public void testPrefixMatchNot() throws Exception {
setupRepo(null, null, "sub/new bar", null);
writeTrashFile("sub/new/foo.txt", "1");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(D, "sub/new", attrs("bar"));
assertIteration(F, "sub/new/foo.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, D, "sub/new", attrs("bar"));
assertIteration(walk, F, "sub/new/foo.txt");
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -385,14 +413,15 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(null, null, "s[t-v]b/n[de]w bar", null);
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("sub/ndw", "2");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(F, "sub/ndw", attrs("bar"));
assertIteration(D, "sub/new", attrs("bar"));
assertIteration(F, "sub/new/foo.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, F, "sub/ndw", attrs("bar"));
assertIteration(walk, D, "sub/new", attrs("bar"));
assertIteration(walk, F, "sub/new/foo.txt");
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -400,15 +429,16 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(null, null, "sub/new/* bar", null);
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("sub/new/lower/foo.txt", "2");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(D, "sub/new");
assertIteration(F, "sub/new/foo.txt", attrs("bar"));
assertIteration(D, "sub/new/lower", attrs("bar"));
assertIteration(F, "sub/new/lower/foo.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, D, "sub/new");
assertIteration(walk, F, "sub/new/foo.txt", attrs("bar"));
assertIteration(walk, D, "sub/new/lower", attrs("bar"));
assertIteration(walk, F, "sub/new/lower/foo.txt");
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -417,20 +447,21 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
writeTrashFile("sub/sub/new/foo.txt", "3");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo");
assertIteration(D, "foo/sub");
assertIteration(D, "foo/sub/new");
assertIteration(F, "foo/sub/new/foo.txt");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(D, "sub/new", attrs("bar"));
assertIteration(F, "sub/new/foo.txt");
assertIteration(D, "sub/sub");
assertIteration(D, "sub/sub/new");
assertIteration(F, "sub/sub/new/foo.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo");
assertIteration(walk, D, "foo/sub");
assertIteration(walk, D, "foo/sub/new");
assertIteration(walk, F, "foo/sub/new/foo.txt");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, D, "sub/new", attrs("bar"));
assertIteration(walk, F, "sub/new/foo.txt");
assertIteration(walk, D, "sub/sub");
assertIteration(walk, D, "sub/sub/new");
assertIteration(walk, F, "sub/sub/new/foo.txt");
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -438,17 +469,18 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(null, null, "**/sub/new/ bar", null);
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo");
assertIteration(D, "foo/sub");
assertIteration(D, "foo/sub/new", attrs("bar"));
assertIteration(F, "foo/sub/new/foo.txt");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(D, "sub/new", attrs("bar"));
assertIteration(F, "sub/new/foo.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo");
assertIteration(walk, D, "foo/sub");
assertIteration(walk, D, "foo/sub/new", attrs("bar"));
assertIteration(walk, F, "foo/sub/new/foo.txt");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, D, "sub/new", attrs("bar"));
assertIteration(walk, F, "sub/new/foo.txt");
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -457,20 +489,21 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
writeTrashFile("sub/sub/new/foo.txt", "3");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo");
assertIteration(D, "foo/sub");
assertIteration(D, "foo/sub/new", attrs("bar"));
assertIteration(F, "foo/sub/new/foo.txt");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(D, "sub/new", attrs("bar"));
assertIteration(F, "sub/new/foo.txt");
assertIteration(D, "sub/sub");
assertIteration(D, "sub/sub/new", attrs("bar"));
assertIteration(F, "sub/sub/new/foo.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo");
assertIteration(walk, D, "foo/sub");
assertIteration(walk, D, "foo/sub/new", attrs("bar"));
assertIteration(walk, F, "foo/sub/new/foo.txt");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, D, "sub/new", attrs("bar"));
assertIteration(walk, F, "sub/new/foo.txt");
assertIteration(walk, D, "sub/sub");
assertIteration(walk, D, "sub/sub/new", attrs("bar"));
assertIteration(walk, F, "sub/sub/new/foo.txt");
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -479,20 +512,21 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
writeTrashFile("sub/sub/new/foo.txt", "3");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo");
assertIteration(D, "foo/sub");
assertIteration(D, "foo/sub/new", attrs("bar"));
assertIteration(F, "foo/sub/new/foo.txt");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(D, "sub/new", attrs("bar"));
assertIteration(F, "sub/new/foo.txt");
assertIteration(D, "sub/sub");
assertIteration(D, "sub/sub/new", attrs("bar"));
assertIteration(F, "sub/sub/new/foo.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo");
assertIteration(walk, D, "foo/sub");
assertIteration(walk, D, "foo/sub/new", attrs("bar"));
assertIteration(walk, F, "foo/sub/new/foo.txt");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, D, "sub/new", attrs("bar"));
assertIteration(walk, F, "sub/new/foo.txt");
assertIteration(walk, D, "sub/sub");
assertIteration(walk, D, "sub/sub/new", attrs("bar"));
assertIteration(walk, F, "sub/sub/new/foo.txt");
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -500,17 +534,18 @@ public class AttributesHandlerTest extends RepositoryTestCase {
setupRepo(null, null, "s[uv]b/n*/ bar", null);
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo");
assertIteration(D, "foo/sub");
assertIteration(D, "foo/sub/new");
assertIteration(F, "foo/sub/new/foo.txt");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(D, "sub/new", attrs("bar"));
assertIteration(F, "sub/new/foo.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo");
assertIteration(walk, D, "foo/sub");
assertIteration(walk, D, "foo/sub/new");
assertIteration(walk, F, "foo/sub/new/foo.txt");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, D, "sub/new", attrs("bar"));
assertIteration(walk, F, "sub/new/foo.txt");
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -519,30 +554,32 @@ public class AttributesHandlerTest extends RepositoryTestCase {
writeTrashFile("sub/new/foo.txt", "1");
writeTrashFile("foo/sub/new/foo.txt", "2");
writeTrashFile("foo/new", "3");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(D, "foo");
assertIteration(F, "foo/new");
assertIteration(D, "foo/sub");
assertIteration(D, "foo/sub/new", attrs("bar"));
assertIteration(F, "foo/sub/new/foo.txt");
assertIteration(D, "sub");
assertIteration(F, "sub/a.txt");
assertIteration(D, "sub/new", attrs("bar"));
assertIteration(F, "sub/new/foo.txt");
endWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, D, "foo");
assertIteration(walk, F, "foo/new");
assertIteration(walk, D, "foo/sub");
assertIteration(walk, D, "foo/sub/new", attrs("bar"));
assertIteration(walk, F, "foo/sub/new/foo.txt");
assertIteration(walk, D, "sub");
assertIteration(walk, F, "sub/a.txt");
assertIteration(walk, D, "sub/new", attrs("bar"));
assertIteration(walk, F, "sub/new/foo.txt");
assertFalse("Not all files tested", walk.next());
}
}
private static Collection<Attribute> attrs(String s) {
return new AttributesRule("*", s).getAttributes();
}
private void assertIteration(FileMode type, String pathName)
private void assertIteration(TreeWalk walk, FileMode type, String pathName)
throws IOException {
assertIteration(type, pathName, Collections.<Attribute> emptyList());
assertIteration(walk, type, pathName,
Collections.<Attribute> emptyList());
}
private void assertIteration(FileMode type, String pathName,
private void assertIteration(TreeWalk walk, FileMode type, String pathName,
Collection<Attribute> expectedAttrs) throws IOException {
assertTrue("walk has entry", walk.next());
assertEquals(pathName, walk.getPathString());
@ -611,8 +648,4 @@ public class AttributesHandlerTest extends RepositoryTestCase {
newWalk.addTree(new FileTreeIterator(db));
return newWalk;
}
private void endWalk() throws IOException {
assertFalse("Not all files tested", walk.next());
}
}

109
org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeDirCacheIteratorTest.java

@ -78,8 +78,6 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
private Git git;
private TreeWalk walk;
@Override
@Before
public void setUp() throws Exception {
@ -105,23 +103,25 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(F, "readme.txt", asList(EOL_LF));
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, F, "readme.txt", asList(EOL_LF));
assertIteration(D, "src");
assertIteration(walk, D, "src");
assertIteration(D, "src/config");
assertIteration(F, "src/config/.gitattributes");
assertIteration(F, "src/config/readme.txt", asList(DELTA_UNSET));
assertIteration(F, "src/config/windows.file", null);
assertIteration(F, "src/config/windows.txt", asList(DELTA_UNSET));
assertIteration(walk, D, "src/config");
assertIteration(walk, F, "src/config/.gitattributes");
assertIteration(walk, F, "src/config/readme.txt",
asList(DELTA_UNSET));
assertIteration(walk, F, "src/config/windows.file", null);
assertIteration(walk, F, "src/config/windows.txt",
asList(DELTA_UNSET));
assertIteration(F, "windows.file", null);
assertIteration(F, "windows.txt", asList(EOL_LF));
assertIteration(walk, F, "windows.file", null);
assertIteration(walk, F, "windows.txt", asList(EOL_LF));
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
/**
@ -138,17 +138,18 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
walk = beginWalk();
assertIteration(F, "l0.txt");
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, "l0.txt");
assertIteration(D, "level1");
assertIteration(F, "level1/l1.txt");
assertIteration(walk, D, "level1");
assertIteration(walk, F, "level1/l1.txt");
assertIteration(D, "level1/level2");
assertIteration(F, "level1/level2/l2.txt");
assertIteration(walk, D, "level1/level2");
assertIteration(walk, F, "level1/level2/l2.txt");
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
/**
@ -166,18 +167,19 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(F, "l0.txt");
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, F, "l0.txt");
assertIteration(D, "level1");
assertIteration(F, "level1/l1.txt");
assertIteration(walk, D, "level1");
assertIteration(walk, F, "level1/l1.txt");
assertIteration(D, "level1/level2");
assertIteration(F, "level1/level2/l2.txt");
assertIteration(walk, D, "level1/level2");
assertIteration(walk, F, "level1/level2/l2.txt");
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -191,18 +193,19 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
walk = beginWalk();
assertIteration(F, ".gitattributes");
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(D, "levelA");
assertIteration(F, "levelA/.gitattributes");
assertIteration(F, "levelA/lA.txt");
assertIteration(walk, D, "levelA");
assertIteration(walk, F, "levelA/.gitattributes");
assertIteration(walk, F, "levelA/lA.txt");
assertIteration(D, "levelB");
assertIteration(F, "levelB/.gitattributes");
assertIteration(walk, D, "levelB");
assertIteration(walk, F, "levelB/.gitattributes");
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -215,25 +218,27 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
// Adds file to index
git.add().addFilepattern(".").call();
walk = beginWalk();
assertIteration(F, "gitattributes");
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, "gitattributes");
assertIteration(F, "l0.txt");
assertIteration(walk, F, "l0.txt");
assertIteration(D, "levelA");
assertIteration(F, "levelA/file.gitattributes");
assertIteration(F, "levelA/lA.txt");
assertIteration(walk, D, "levelA");
assertIteration(walk, F, "levelA/file.gitattributes");
assertIteration(walk, F, "levelA/lA.txt");
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
private void assertIteration(FileMode type, String pathName)
private void assertIteration(TreeWalk walk, FileMode type, String pathName)
throws IOException {
assertIteration(type, pathName, Collections.<Attribute> emptyList());
assertIteration(walk, type, pathName,
Collections.<Attribute> emptyList());
}
private void assertIteration(FileMode type, String pathName,
private void assertIteration(TreeWalk walk, FileMode type, String pathName,
List<Attribute> nodeAttrs) throws IOException {
assertTrue("walk has entry", walk.next());
assertEquals(pathName, walk.getPathString());
@ -243,14 +248,14 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
AttributesNode attributesNode = itr.getEntryAttributesNode(db
.newObjectReader());
assertAttributesNode(pathName, attributesNode, nodeAttrs);
assertAttributesNode(walk, pathName, attributesNode, nodeAttrs);
if (D.equals(type))
walk.enterSubtree();
}
private void assertAttributesNode(String pathName,
private void assertAttributesNode(TreeWalk walk, String pathName,
AttributesNode attributesNode, List<Attribute> nodeAttrs)
throws IOException {
if (attributesNode == null)
@ -292,8 +297,4 @@ public class AttributesNodeDirCacheIteratorTest extends RepositoryTestCase {
newWalk.addTree(new DirCacheIterator(db.readDirCache()));
return newWalk;
}
private void endWalk() throws IOException {
assertFalse("Not all files tested", walk.next());
}
}

99
org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeWorkingTreeIteratorTest.java

@ -77,8 +77,6 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
private static Attribute DELTA_UNSET = new Attribute("delta", State.UNSET);
private TreeWalk walk;
@Test
public void testRules() throws Exception {
@ -102,24 +100,26 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
writeTrashFile("src/config/windows.file", "");
writeTrashFile("src/config/windows.txt", "");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(F, "global.txt", asList(EOL_LF));
assertIteration(F, "readme.txt", asList(EOL_LF));
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, F, "global.txt", asList(EOL_LF));
assertIteration(walk, F, "readme.txt", asList(EOL_LF));
assertIteration(D, "src");
assertIteration(walk, D, "src");
assertIteration(D, "src/config");
assertIteration(F, "src/config/.gitattributes");
assertIteration(F, "src/config/readme.txt", asList(DELTA_UNSET));
assertIteration(F, "src/config/windows.file", null);
assertIteration(F, "src/config/windows.txt", asList(DELTA_UNSET));
assertIteration(walk, D, "src/config");
assertIteration(walk, F, "src/config/.gitattributes");
assertIteration(walk, F, "src/config/readme.txt",
asList(DELTA_UNSET));
assertIteration(walk, F, "src/config/windows.file", null);
assertIteration(walk, F, "src/config/windows.txt",
asList(DELTA_UNSET));
assertIteration(F, "windows.file", null);
assertIteration(F, "windows.txt", asList(EOL_LF));
assertIteration(walk, F, "windows.file", null);
assertIteration(walk, F, "windows.txt", asList(EOL_LF));
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
/**
@ -134,17 +134,17 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
writeTrashFile("level1/l1.txt", "");
writeTrashFile("level1/level2/l2.txt", "");
walk = beginWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, "l0.txt");
assertIteration(F, "l0.txt");
assertIteration(walk, D, "level1");
assertIteration(walk, F, "level1/l1.txt");
assertIteration(D, "level1");
assertIteration(F, "level1/l1.txt");
assertIteration(walk, D, "level1/level2");
assertIteration(walk, F, "level1/level2/l2.txt");
assertIteration(D, "level1/level2");
assertIteration(F, "level1/level2/l2.txt");
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
/**
@ -160,18 +160,18 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
writeTrashFile("level1/l1.txt", "");
writeTrashFile("level1/level2/l2.txt", "");
walk = beginWalk();
assertIteration(F, ".gitattributes");
assertIteration(F, "l0.txt");
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(walk, F, "l0.txt");
assertIteration(D, "level1");
assertIteration(F, "level1/l1.txt");
assertIteration(walk, D, "level1");
assertIteration(walk, F, "level1/l1.txt");
assertIteration(D, "level1/level2");
assertIteration(F, "level1/level2/l2.txt");
assertIteration(walk, D, "level1/level2");
assertIteration(walk, F, "level1/level2/l2.txt");
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
@Test
@ -183,26 +183,27 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
writeTrashFile("levelA/lA.txt", "");
walk = beginWalk();
try (TreeWalk walk = beginWalk()) {
assertIteration(walk, F, ".gitattributes");
assertIteration(F, ".gitattributes");
assertIteration(walk, D, "levelA");
assertIteration(walk, F, "levelA/.gitattributes");
assertIteration(walk, F, "levelA/lA.txt");
assertIteration(D, "levelA");
assertIteration(F, "levelA/.gitattributes");
assertIteration(F, "levelA/lA.txt");
assertIteration(walk, D, "levelB");
assertIteration(walk, F, "levelB/.gitattributes");
assertIteration(D, "levelB");
assertIteration(F, "levelB/.gitattributes");
endWalk();
assertFalse("Not all files tested", walk.next());
}
}
private void assertIteration(FileMode type, String pathName)
private void assertIteration(TreeWalk walk, FileMode type, String pathName)
throws IOException {
assertIteration(type, pathName, Collections.<Attribute> emptyList());
assertIteration(walk, type, pathName,
Collections.<Attribute> emptyList());
}
private void assertIteration(FileMode type, String pathName,
private void assertIteration(TreeWalk walk, FileMode type, String pathName,
List<Attribute> nodeAttrs)
throws IOException {
assertTrue("walk has entry", walk.next());
@ -212,13 +213,13 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
assertNotNull("has tree", itr);
AttributesNode attributesNode = itr.getEntryAttributesNode();
assertAttributesNode(pathName, attributesNode, nodeAttrs);
assertAttributesNode(walk, pathName, attributesNode, nodeAttrs);
if (D.equals(type))
walk.enterSubtree();
}
private void assertAttributesNode(String pathName,
private void assertAttributesNode(TreeWalk walk, String pathName,
AttributesNode attributesNode, List<Attribute> nodeAttrs)
throws IOException {
if (attributesNode == null)
@ -259,8 +260,4 @@ public class AttributesNodeWorkingTreeIteratorTest extends RepositoryTestCase {
newWalk.addTree(new FileTreeIterator(db));
return newWalk;
}
private void endWalk() throws IOException {
assertFalse("Not all files tested", walk.next());
}
}

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/TreeWalkAttributeTest.java

@ -131,6 +131,12 @@ public class TreeWalkAttributeTest extends RepositoryTestCase {
@Override
@After
public void tearDown() throws Exception {
if (walk != null) {
walk.close();
}
if (ci_walk != null) {
ci_walk.close();
}
super.tearDown();
if (customAttributeFile != null)
customAttributeFile.delete();

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java

@ -63,6 +63,7 @@ import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.WorkingTreeIterator;
import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.SystemReader;
import org.junit.After;
import org.junit.Test;
/**
@ -79,6 +80,13 @@ public class IgnoreNodeTest extends RepositoryTestCase {
private TreeWalk walk;
@After
public void closeWalk() {
if (walk != null) {
walk.close();
}
}
@Test
public void testSimpleRootGitIgnoreGlobalIgnore() throws IOException {
writeIgnoreFile(".gitignore", "x");

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/CherryPickTest.java

@ -106,7 +106,7 @@ public class CherryPickTest extends RepositoryTestCase {
boolean merge = twm.merge(new ObjectId[] { O, T });
assertTrue(merge);
final TreeWalk tw = new TreeWalk(db);
try (TreeWalk tw = new TreeWalk(db)) {
tw.setRecursive(true);
tw.reset(twm.getResultTreeId());
@ -124,6 +124,7 @@ public class CherryPickTest extends RepositoryTestCase {
assertFalse(tw.next());
}
}
@Test
public void testRevert() throws Exception {
@ -168,7 +169,7 @@ public class CherryPickTest extends RepositoryTestCase {
boolean merge = twm.merge(new ObjectId[] { B, T });
assertTrue(merge);
final TreeWalk tw = new TreeWalk(db);
try (TreeWalk tw = new TreeWalk(db)) {
tw.setRecursive(true);
tw.reset(twm.getResultTreeId());
@ -182,6 +183,7 @@ public class CherryPickTest extends RepositoryTestCase {
assertFalse(tw.next());
}
}
private static void assertCorrectId(DirCache treeT, TreeWalk tw) {
assertEquals(treeT.getEntry(tw.getPathString()).getObjectId(), tw

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java

@ -174,7 +174,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
assertTrue(merge);
final TreeWalk tw = new TreeWalk(db);
try (TreeWalk tw = new TreeWalk(db)) {
tw.setRecursive(true);
tw.reset(ourMerger.getResultTreeId());
@ -192,6 +192,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
assertFalse(tw.next());
}
}
@Test
public void testTrivialTwoWay_concurrentSubtreeChange() throws Exception {
@ -226,7 +227,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
assertTrue(merge);
final TreeWalk tw = new TreeWalk(db);
try (TreeWalk tw = new TreeWalk(db)) {
tw.setRecursive(true);
tw.reset(ourMerger.getResultTreeId());
@ -240,6 +241,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
assertFalse(tw.next());
}
}
@Test
public void testTrivialTwoWay_conflictSubtreeChange() throws Exception {

11
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java

@ -135,7 +135,7 @@ public class SubmoduleAddTest extends RepositoryTestCase {
subCommit = repo.resolve(Constants.HEAD);
}
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
generator.loadModulesConfig();
assertTrue(generator.next());
assertEquals(path, generator.getModuleName());
@ -148,7 +148,7 @@ public class SubmoduleAddTest extends RepositoryTestCase {
assertNotNull(subModRepo);
assertEquals(subCommit, commit);
}
}
Status status = Git.wrap(db).status().call();
assertTrue(status.getAdded().contains(Constants.DOT_GIT_MODULES));
assertTrue(status.getAdded().contains(path));
@ -175,7 +175,7 @@ public class SubmoduleAddTest extends RepositoryTestCase {
subCommit = repo.resolve(Constants.HEAD);
}
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
generator.loadModulesConfig();
assertTrue(generator.next());
assertEquals(name, generator.getModuleName());
@ -188,7 +188,7 @@ public class SubmoduleAddTest extends RepositoryTestCase {
assertNotNull(subModRepo);
assertEquals(subCommit, commit);
}
}
Status status = Git.wrap(db).status().call();
assertTrue(status.getAdded().contains(Constants.DOT_GIT_MODULES));
assertTrue(status.getAdded().contains(path));
@ -269,7 +269,7 @@ public class SubmoduleAddTest extends RepositoryTestCase {
assertNotNull(repo);
addRepoToClose(repo);
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals(path, generator.getPath());
assertEquals(commit, generator.getObjectId());
@ -288,6 +288,7 @@ public class SubmoduleAddTest extends RepositoryTestCase {
Constants.DEFAULT_REMOTE_NAME,
ConfigConstants.CONFIG_KEY_URL));
}
}
assertEquals(commit, repo.resolve(Constants.HEAD));
Status status = Git.wrap(db).status().call();

19
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleDeinitTest.java

@ -107,7 +107,6 @@ public class SubmoduleDeinitTest extends RepositoryTestCase {
assertEquals(1, updated.size());
File submoduleDir = assertSubmoduleIsInitialized();
SubmoduleWalk generator;
write(new File(submoduleDir, "untracked"), "untracked");
@ -115,8 +114,9 @@ public class SubmoduleDeinitTest extends RepositoryTestCase {
assertEquals(path, result.getPath());
assertEquals(SubmoduleDeinitCommand.SubmoduleDeinitStatus.DIRTY, result.getStatus());
generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
}
assertTrue(submoduleDir.isDirectory());
assertNotEquals(0, submoduleDir.list().length);
}
@ -132,7 +132,7 @@ public class SubmoduleDeinitTest extends RepositoryTestCase {
assertEquals(1, updated.size());
File submoduleDir = assertSubmoduleIsInitialized();
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
generator.next();
// want to create a commit inside the repo...
@ -142,24 +142,27 @@ public class SubmoduleDeinitTest extends RepositoryTestCase {
Git.wrap(submoduleLocalRepo).commit().setAll(true)
.setMessage("local commit").call();
}
}
SubmoduleDeinitResult result = runDeinit(new SubmoduleDeinitCommand(db).addPath("sub"));
assertEquals(path, result.getPath());
assertEquals(SubmoduleDeinitCommand.SubmoduleDeinitStatus.DIRTY, result.getStatus());
generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
}
assertTrue(submoduleDir.isDirectory());
assertNotEquals(0, submoduleDir.list().length);
}
private File assertSubmoduleIsInitialized() throws IOException {
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
File submoduleDir = new File(db.getWorkTree(), generator.getPath());
assertTrue(submoduleDir.isDirectory());
assertNotEquals(0, submoduleDir.list().length);
return submoduleDir;
}
}
@Test
public void dirtySubmoduleWithForce() throws Exception {
@ -180,8 +183,9 @@ public class SubmoduleDeinitTest extends RepositoryTestCase {
assertEquals(path, result.getPath());
assertEquals(SubmoduleDeinitCommand.SubmoduleDeinitStatus.FORCED, result.getStatus());
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
}
assertTrue(submoduleDir.isDirectory());
assertEquals(0, submoduleDir.list().length);
}
@ -202,8 +206,9 @@ public class SubmoduleDeinitTest extends RepositoryTestCase {
assertEquals(path, result.getPath());
assertEquals(SubmoduleDeinitCommand.SubmoduleDeinitStatus.SUCCESS, result.getStatus());
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
}
assertTrue(submoduleDir.isDirectory());
assertEquals(0, submoduleDir.list().length);
}

42
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleInitTest.java

@ -86,11 +86,11 @@ public class SubmoduleInitTest extends RepositoryTestCase {
ConfigInvalidException, GitAPIException {
final String path = addSubmoduleToIndex();
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertNull(generator.getConfigUrl());
assertNull(generator.getConfigUpdate());
}
FileBasedConfig modulesConfig = new FileBasedConfig(new File(
db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
@ -109,11 +109,12 @@ public class SubmoduleInitTest extends RepositoryTestCase {
assertEquals(1, modules.size());
assertEquals(path, modules.iterator().next());
generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals(url, generator.getConfigUrl());
assertEquals(update, generator.getConfigUpdate());
}
}
@Test
public void resolveSameLevelRelativeUrl() throws Exception {
@ -126,11 +127,11 @@ public class SubmoduleInitTest extends RepositoryTestCase {
base);
config.save();
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertNull(generator.getConfigUrl());
assertNull(generator.getConfigUpdate());
}
FileBasedConfig modulesConfig = new FileBasedConfig(new File(
db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
@ -149,11 +150,13 @@ public class SubmoduleInitTest extends RepositoryTestCase {
assertEquals(1, modules.size());
assertEquals(path, modules.iterator().next());
generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals("git://server/repo.git/sub.git", generator.getConfigUrl());
assertEquals("git://server/repo.git/sub.git",
generator.getConfigUrl());
assertEquals(update, generator.getConfigUpdate());
}
}
@Test
public void resolveOneLevelHigherRelativeUrl() throws IOException,
@ -167,11 +170,11 @@ public class SubmoduleInitTest extends RepositoryTestCase {
base);
config.save();
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertNull(generator.getConfigUrl());
assertNull(generator.getConfigUpdate());
}
FileBasedConfig modulesConfig = new FileBasedConfig(new File(
db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
@ -190,11 +193,12 @@ public class SubmoduleInitTest extends RepositoryTestCase {
assertEquals(1, modules.size());
assertEquals(path, modules.iterator().next());
generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals("git://server/sub.git", generator.getConfigUrl());
assertEquals(update, generator.getConfigUpdate());
}
}
@Test
public void resolveTwoLevelHigherRelativeUrl() throws IOException,
@ -208,11 +212,11 @@ public class SubmoduleInitTest extends RepositoryTestCase {
base);
config.save();
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertNull(generator.getConfigUrl());
assertNull(generator.getConfigUpdate());
}
FileBasedConfig modulesConfig = new FileBasedConfig(new File(
db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
@ -231,11 +235,12 @@ public class SubmoduleInitTest extends RepositoryTestCase {
assertEquals(1, modules.size());
assertEquals(path, modules.iterator().next());
generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals("git://server2/sub.git", generator.getConfigUrl());
assertEquals(update, generator.getConfigUpdate());
}
}
@Test
public void resolveWorkingDirectoryRelativeUrl() throws IOException,
@ -250,11 +255,11 @@ public class SubmoduleInitTest extends RepositoryTestCase {
Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL);
config.save();
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertNull(generator.getConfigUrl());
assertNull(generator.getConfigUpdate());
}
FileBasedConfig modulesConfig = new FileBasedConfig(new File(
db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
@ -273,11 +278,12 @@ public class SubmoduleInitTest extends RepositoryTestCase {
assertEquals(1, modules.size());
assertEquals(path, modules.iterator().next());
generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals(base + "/sub.git", generator.getConfigUrl());
assertEquals(update, generator.getConfigUpdate());
}
}
@Test
public void resolveInvalidParentUrl() throws IOException,
@ -291,11 +297,11 @@ public class SubmoduleInitTest extends RepositoryTestCase {
base);
config.save();
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertNull(generator.getConfigUrl());
assertNull(generator.getConfigUpdate());
}
FileBasedConfig modulesConfig = new FileBasedConfig(new File(
db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,

14
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleSyncTest.java

@ -119,11 +119,11 @@ public class SubmoduleSyncTest extends RepositoryTestCase {
addRepoToClose(subRepo);
assertNotNull(subRepo);
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertNull(generator.getConfigUrl());
assertEquals(url, generator.getModulesUrl());
}
SubmoduleSyncCommand command = new SubmoduleSyncCommand(db);
Map<String, String> synced = command.call();
assertNotNull(synced);
@ -132,7 +132,7 @@ public class SubmoduleSyncTest extends RepositoryTestCase {
assertEquals(path, module.getKey());
assertEquals(url, module.getValue());
generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals(url, generator.getConfigUrl());
try (Repository subModRepository = generator.getRepository()) {
@ -144,6 +144,7 @@ public class SubmoduleSyncTest extends RepositoryTestCase {
ConfigConstants.CONFIG_KEY_URL));
}
}
}
@Test
public void repositoryWithRelativeUriSubmodule() throws Exception {
@ -190,11 +191,11 @@ public class SubmoduleSyncTest extends RepositoryTestCase {
assertNotNull(subRepo);
addRepoToClose(subRepo);
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertNull(generator.getConfigUrl());
assertEquals(current, generator.getModulesUrl());
}
modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
ConfigConstants.CONFIG_KEY_URL, "../sub.git");
modulesConfig.save();
@ -207,7 +208,7 @@ public class SubmoduleSyncTest extends RepositoryTestCase {
assertEquals(path, module.getKey());
assertEquals("git://server/sub.git", module.getValue());
generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
assertEquals("git://server/sub.git", generator.getConfigUrl());
try (Repository subModRepository1 = generator.getRepository()) {
@ -220,3 +221,4 @@ public class SubmoduleSyncTest extends RepositoryTestCase {
}
}
}
}

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleUpdateTest.java

@ -119,13 +119,14 @@ public class SubmoduleUpdateTest extends RepositoryTestCase {
assertEquals(1, updated.size());
assertEquals(path, updated.iterator().next());
SubmoduleWalk generator = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk generator = SubmoduleWalk.forIndex(db)) {
assertTrue(generator.next());
try (Repository subRepo = generator.getRepository()) {
assertNotNull(subRepo);
assertEquals(commit, subRepo.resolve(Constants.HEAD));
}
}
}
@Test
public void repositoryWithUnconfiguredSubmodule() throws IOException,
@ -181,10 +182,11 @@ public class SubmoduleUpdateTest extends RepositoryTestCase {
});
editor.commit();
Repository subRepo = Git.init().setBare(false)
try (Repository subRepo = Git.init().setBare(false)
.setDirectory(new File(db.getWorkTree(), path)).call()
.getRepository();
.getRepository()) {
assertNotNull(subRepo);
}
SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
Collection<String> updated = command.call();

35
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java

@ -98,11 +98,12 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
@Test
public void repositoryWithNoSubmodules() throws IOException {
SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk gen = SubmoduleWalk.forIndex(db)) {
assertFalse(gen.next());
assertNull(gen.getPath());
assertEquals(ObjectId.zeroId(), gen.getObjectId());
}
}
@Test
public void bareRepositoryWithNoSubmodules() throws IOException {
@ -129,7 +130,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
});
editor.commit();
SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk gen = SubmoduleWalk.forIndex(db)) {
assertTrue(gen.next());
assertEquals(path, gen.getPath());
assertEquals(id, gen.getObjectId());
@ -140,10 +141,11 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertNull(gen.getModulesUpdate());
assertNull(gen.getModulesUrl());
assertNull(gen.getRepository());
Status status = Git.wrap(db).status().call();
assertTrue(!status.isClean());
assertFalse(gen.next());
}
Status status = Git.wrap(db).status().call();
assertFalse(status.isClean());
}
@Test
public void repositoryWithRootLevelSubmoduleAbsoluteRef()
@ -178,7 +180,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
});
editor.commit();
SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk gen = SubmoduleWalk.forIndex(db)) {
assertTrue(gen.next());
assertEquals(path, gen.getPath());
assertEquals(id, gen.getObjectId());
@ -197,6 +199,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
}
assertFalse(gen.next());
}
}
@Test
public void repositoryWithRootLevelSubmoduleRelativeRef()
@ -232,7 +235,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
});
editor.commit();
SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk gen = SubmoduleWalk.forIndex(db)) {
assertTrue(gen.next());
assertEquals(path, gen.getPath());
assertEquals(id, gen.getObjectId());
@ -251,6 +254,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertFalse(gen.next());
}
}
}
@Test
public void repositoryWithNestedSubmodule() throws IOException,
@ -270,7 +274,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
});
editor.commit();
SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk gen = SubmoduleWalk.forIndex(db)) {
assertTrue(gen.next());
assertEquals(path, gen.getPath());
assertEquals(id, gen.getObjectId());
@ -283,6 +287,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertNull(gen.getRepository());
assertFalse(gen.next());
}
}
@Test
public void generatorFilteredToOneOfTwoSubmodules() throws IOException {
@ -312,13 +317,14 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
});
editor.commit();
SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk gen = SubmoduleWalk.forIndex(db)) {
gen.setFilter(PathFilter.create(path1));
assertTrue(gen.next());
assertEquals(path1, gen.getPath());
assertEquals(id1, gen.getObjectId());
assertFalse(gen.next());
}
}
@Test
public void indexWithGitmodules() throws Exception {
@ -358,7 +364,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
});
editor.commit();
SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
try (SubmoduleWalk gen = SubmoduleWalk.forIndex(db)) {
assertTrue(gen.next());
assertEquals(path, gen.getPath());
assertEquals(subId, gen.getObjectId());
@ -371,6 +377,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertNull(gen.getRepository());
assertFalse(gen.next());
}
}
@Test
public void treeIdWithGitmodules() throws Exception {
@ -397,7 +404,8 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
})
.create());
SubmoduleWalk gen = SubmoduleWalk.forPath(db, commit.getTree(), "sub");
try (SubmoduleWalk gen = SubmoduleWalk.forPath(db, commit.getTree(),
"sub")) {
assertEquals(path, gen.getPath());
assertEquals(subId, gen.getObjectId());
assertEquals(new File(db.getWorkTree(), path), gen.getDirectory());
@ -409,6 +417,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertNull(gen.getRepository());
assertFalse(gen.next());
}
}
@Test
public void testTreeIteratorWithGitmodules() throws Exception {
@ -437,7 +446,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
final CanonicalTreeParser p = new CanonicalTreeParser();
p.reset(testDb.getRevWalk().getObjectReader(), commit.getTree());
SubmoduleWalk gen = SubmoduleWalk.forPath(db, p, "sub");
try (SubmoduleWalk gen = SubmoduleWalk.forPath(db, p, "sub")) {
assertEquals(path, gen.getPath());
assertEquals(subId, gen.getObjectId());
assertEquals(new File(db.getWorkTree(), path), gen.getDirectory());
@ -449,6 +458,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertNull(gen.getRepository());
assertFalse(gen.next());
}
}
@Test
public void testTreeIteratorWithGitmodulesNameNotPath() throws Exception {
@ -477,7 +487,7 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
final CanonicalTreeParser p = new CanonicalTreeParser();
p.reset(testDb.getRevWalk().getObjectReader(), commit.getTree());
SubmoduleWalk gen = SubmoduleWalk.forPath(db, p, "sub");
try (SubmoduleWalk gen = SubmoduleWalk.forPath(db, p, "sub")) {
assertEquals(path, gen.getPath());
assertEquals(subId, gen.getObjectId());
assertEquals(new File(db.getWorkTree(), path), gen.getDirectory());
@ -490,3 +500,4 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
assertFalse(gen.next());
}
}
}

7
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java

@ -272,9 +272,9 @@ public class FileTreeIteratorTest extends RepositoryTestCase {
git.add().addFilepattern("file").call();
}
DirCacheEntry dce = db.readDirCache().getEntry("file");
TreeWalk tw = new TreeWalk(db);
FileTreeIterator fti = new FileTreeIterator(trash, db.getFS(), db
.getConfig().get(WorkingTreeOptions.KEY));
try (TreeWalk tw = new TreeWalk(db)) {
FileTreeIterator fti = new FileTreeIterator(trash, db.getFS(),
db.getConfig().get(WorkingTreeOptions.KEY));
tw.addTree(fti);
DirCacheIterator dci = new DirCacheIterator(db.readDirCache());
tw.addTree(dci);
@ -290,6 +290,7 @@ public class FileTreeIteratorTest extends RepositoryTestCase {
assertFalse(fti.isModified(dce, false, objectReader));
}
}
}
@Test
public void testTreewalkEnterSubtree() throws Exception {

15
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java

@ -84,7 +84,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertEquals(1, tree1.getEntryCount());
}
final TreeWalk tw = new TreeWalk(db);
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new DirCacheIterator(tree0));
tw.addTree(new DirCacheIterator(tree1));
@ -95,6 +95,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertModes("a/b", MISSING, REGULAR_FILE, tw);
assertModes("a0b", SYMLINK, MISSING, tw);
}
}
@Test
public void testDF_NoGap() throws Exception {
@ -115,7 +116,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertEquals(1, tree1.getEntryCount());
}
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
try (NameConflictTreeWalk tw = new NameConflictTreeWalk(db)) {
tw.addTree(new DirCacheIterator(tree0));
tw.addTree(new DirCacheIterator(tree1));
@ -130,6 +131,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertModes("a0b", SYMLINK, MISSING, tw);
assertFalse(tw.isDirectoryFileConflict());
}
}
@Test
public void testDF_GapByOne() throws Exception {
@ -151,7 +153,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertEquals(2, tree1.getEntryCount());
}
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
try (NameConflictTreeWalk tw = new NameConflictTreeWalk(db)) {
tw.addTree(new DirCacheIterator(tree0));
tw.addTree(new DirCacheIterator(tree1));
@ -166,6 +168,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertModes("a0b", SYMLINK, MISSING, tw);
assertFalse(tw.isDirectoryFileConflict());
}
}
@Test
public void testDF_SkipsSeenSubtree() throws Exception {
@ -187,7 +190,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertEquals(3, tree1.getEntryCount());
}
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
try (NameConflictTreeWalk tw = new NameConflictTreeWalk(db)) {
tw.addTree(new DirCacheIterator(tree0));
tw.addTree(new DirCacheIterator(tree1));
@ -202,6 +205,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertModes("a0b", SYMLINK, SYMLINK, tw);
assertFalse(tw.isDirectoryFileConflict());
}
}
@Test
public void testDF_DetectConflict() throws Exception {
@ -224,7 +228,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertEquals(4, tree1.getEntryCount());
}
final NameConflictTreeWalk tw = new NameConflictTreeWalk(db);
try (NameConflictTreeWalk tw = new NameConflictTreeWalk(db)) {
tw.addTree(new DirCacheIterator(tree0));
tw.addTree(new DirCacheIterator(tree1));
@ -245,6 +249,7 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase {
assertModes("a.b", MISSING, REGULAR_FILE, tw);
assertFalse(tw.isDirectoryFileConflict());
}
}
private static void assertModes(final String path, final FileMode mode0,
final FileMode mode1, final TreeWalk tw) throws Exception {

114
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/IndexDiffFilterTest.java

@ -101,22 +101,23 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
RevCommit commit = writeFileInFolderAndCommit();
deleteAll();
writeFileWithFolderName();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertTrue(treeWalk.next());
assertEquals("folder", treeWalk.getPathString());
assertTrue(treeWalk.next());
assertEquals("folder/file", treeWalk.getPathString());
assertFalse(treeWalk.next());
}
}
@Test
public void testNonRecursiveTreeWalk() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
deleteAll();
writeFileWithFolderName();
TreeWalk treeWalk = createNonRecursiveTreeWalk(commit);
try (TreeWalk treeWalk = createNonRecursiveTreeWalk(commit)) {
assertTrue(treeWalk.next());
assertEquals("folder", treeWalk.getPathString());
assertTrue(treeWalk.next());
@ -127,13 +128,15 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
assertEquals("folder/file", treeWalk.getPathString());
assertFalse(treeWalk.next());
}
}
@Test
public void testFileCommitted() throws Exception {
RevCommit commit = writeFileAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testConflicts() throws Exception {
@ -153,232 +156,260 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
"<<<<<<< HEAD\nside\n=======\nmaster\n>>>>>>> master\n");
writeTrashFile(FILE, "master");
TreeWalk treeWalk = createTreeWalk(side);
try (TreeWalk treeWalk = createTreeWalk(side)) {
int count = 0;
while (treeWalk.next())
count++;
assertEquals(2, count);
}
}
@Test
public void testFileInFolderCommitted() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testEmptyFolderCommitted() throws Exception {
RevCommit commit = createEmptyFolderAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileCommittedChangedNotModified() throws Exception {
RevCommit commit = writeFileAndCommit();
writeFile();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileInFolderCommittedChangedNotModified() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
writeFileInFolder();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileCommittedModified() throws Exception {
RevCommit commit = writeFileAndCommit();
writeFileModified();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE);
}
}
@Test
public void testFileInFolderCommittedModified() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
writeFileInFolderModified();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testFileCommittedDeleted() throws Exception {
RevCommit commit = writeFileAndCommit();
deleteFile();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE);
}
}
@Test
public void testFileInFolderCommittedDeleted() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
deleteFileInFolder();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testFileInFolderCommittedAllDeleted() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
deleteAll();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testEmptyFolderCommittedDeleted() throws Exception {
RevCommit commit = createEmptyFolderAndCommit();
deleteFolder();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileCommittedModifiedCommittedComparedWithInitialCommit()
throws Exception {
RevCommit commit = writeFileAndCommit();
writeFileModifiedAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE);
}
}
@Test
public void testFileInFolderCommittedModifiedCommittedComparedWithInitialCommit()
throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
writeFileInFolderModifiedAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testFileCommittedDeletedCommittedComparedWithInitialCommit()
throws Exception {
RevCommit commit = writeFileAndCommit();
deleteFileAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE);
}
}
@Test
public void testFileInFolderCommittedDeletedCommittedComparedWithInitialCommit()
throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
deleteFileInFolderAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testFileInFolderCommittedAllDeletedCommittedComparedWithInitialCommit()
throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
deleteAllAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testEmptyFolderCommittedDeletedCommittedComparedWithInitialCommit()
throws Exception {
RevCommit commit = createEmptyFolderAndCommit();
deleteFolderAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileUntracked() throws Exception {
RevCommit commit = writeFileAndCommit();
writeFileUntracked();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, UNTRACKED_FILE);
}
}
@Test
public void testFileInFolderUntracked() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
writeFileInFolderUntracked();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, UNTRACKED_FILE_IN_FOLDER);
}
}
@Test
public void testEmptyFolderUntracked() throws Exception {
RevCommit commit = createEmptyFolderAndCommit();
createEmptyFolderUntracked();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileIgnored() throws Exception {
RevCommit commit = writeFileAndCommit();
writeFileIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileInFolderIgnored() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
writeFileInFolderIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileInFolderAllIgnored() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
writeFileInFolderAllIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testEmptyFolderIgnored() throws Exception {
RevCommit commit = createEmptyFolderAndCommit();
createEmptyFolderIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileIgnoredNotHonored() throws Exception {
RevCommit commit = writeFileAndCommit();
writeFileIgnored();
TreeWalk treeWalk = createTreeWalkDishonorIgnores(commit);
try (TreeWalk treeWalk = createTreeWalkDishonorIgnores(commit)) {
assertPaths(treeWalk, IGNORED_FILE, GITIGNORE);
}
}
@Test
public void testFileCommittedModifiedIgnored() throws Exception {
RevCommit commit = writeFileAndCommit();
writeFileModifiedIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE);
}
}
@Test
public void testFileInFolderCommittedModifiedIgnored() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
writeFileInFolderModifiedIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testFileInFolderCommittedModifiedAllIgnored() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
writeFileInFolderModifiedAllIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testFileCommittedDeletedCommittedIgnoredComparedWithInitialCommit()
@ -386,9 +417,10 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
RevCommit commit = writeFileAndCommit();
deleteFileAndCommit();
rewriteFileIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE);
}
}
@Test
public void testFileInFolderCommittedDeletedCommittedIgnoredComparedWithInitialCommit()
@ -396,9 +428,10 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
RevCommit commit = writeFileInFolderAndCommit();
deleteFileInFolderAndCommit();
rewriteFileInFolderIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testFileInFolderCommittedAllDeletedCommittedAllIgnoredComparedWithInitialCommit()
@ -406,9 +439,10 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
RevCommit commit = writeFileInFolderAndCommit();
deleteAllAndCommit();
rewriteFileInFolderAllIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FILE_IN_FOLDER);
}
}
@Test
public void testEmptyFolderCommittedDeletedCommittedIgnoredComparedWithInitialCommit()
@ -416,25 +450,28 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
RevCommit commit = createEmptyFolderAndCommit();
deleteFolderAndCommit();
recreateEmptyFolderIgnored();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertFalse(treeWalk.next());
}
}
@Test
public void testFileInFolderCommittedNonRecursive() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
TreeWalk treeWalk = createNonRecursiveTreeWalk(commit);
try (TreeWalk treeWalk = createNonRecursiveTreeWalk(commit)) {
assertPaths(treeWalk, FOLDER);
}
}
@Test
public void testFolderChangedToFile() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();
deleteAll();
writeFileWithFolderName();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FOLDER, FILE_IN_FOLDER);
}
}
@Test
public void testFolderChangedToFileCommittedComparedWithInitialCommit()
@ -442,9 +479,10 @@ public class IndexDiffFilterTest extends RepositoryTestCase {
RevCommit commit = writeFileInFolderAndCommit();
deleteAll();
writeFileWithFolderNameAndCommit();
TreeWalk treeWalk = createTreeWalk(commit);
try (TreeWalk treeWalk = createTreeWalk(commit)) {
assertPaths(treeWalk, FOLDER, FILE_IN_FOLDER);
}
}
private void writeFile() throws Exception {
writeTrashFile(FILE, FILE_CONTENT);

Loading…
Cancel
Save