Browse Source

FileTreeIteratorJava7Test: Create Git instances in try-with-resource

Change-Id: I493e90e8a0d96db5acc49759c8e138b0a8c7b099
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
stable-4.2
David Pursehouse 9 years ago
parent
commit
7c21aeb508
  1. 18
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorJava7Test.java

18
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/FileTreeIteratorJava7Test.java

@ -103,8 +103,9 @@ public class FileTreeIteratorJava7Test extends RepositoryTestCase {
});
assertTrue(dce.commit());
}
new Git(db).commit().setMessage("Adding link").call();
new Git(db).reset().setMode(ResetType.HARD).call();
try (Git git = new Git(db)) {
git.commit().setMessage("Adding link").call();
git.reset().setMode(ResetType.HARD).call();
DirCacheIterator dci = new DirCacheIterator(db.readDirCache());
FileTreeIterator fti = new FileTreeIterator(db);
@ -116,6 +117,7 @@ public class FileTreeIteratorJava7Test extends RepositoryTestCase {
assertFalse(fti.isModified(dci.getDirCacheEntry(), true,
db.newObjectReader()));
}
}
/**
* Like #testSymlinkNotModifiedThoughNormalized but there is no
@ -142,8 +144,9 @@ public class FileTreeIteratorJava7Test extends RepositoryTestCase {
});
assertTrue(dce.commit());
}
new Git(db).commit().setMessage("Adding link").call();
new Git(db).reset().setMode(ResetType.HARD).call();
try (Git git = new Git(db)) {
git.commit().setMessage("Adding link").call();
git.reset().setMode(ResetType.HARD).call();
DirCacheIterator dci = new DirCacheIterator(db.readDirCache());
FileTreeIterator fti = new FileTreeIterator(db);
@ -155,6 +158,7 @@ public class FileTreeIteratorJava7Test extends RepositoryTestCase {
assertFalse(fti.isModified(dci.getDirCacheEntry(), true,
db.newObjectReader()));
}
}
/**
* Like #testSymlinkNotModifiedThoughNormalized but here the link is
@ -182,8 +186,9 @@ public class FileTreeIteratorJava7Test extends RepositoryTestCase {
});
assertTrue(dce.commit());
}
new Git(db).commit().setMessage("Adding link").call();
new Git(db).reset().setMode(ResetType.HARD).call();
try (Git git = new Git(db)) {
git.commit().setMessage("Adding link").call();
git.reset().setMode(ResetType.HARD).call();
FileUtils.delete(new File(trash, "link"), FileUtils.NONE);
FS.DETECTED.createSymLink(new File(trash, "link"), "newtarget");
@ -198,4 +203,5 @@ public class FileTreeIteratorJava7Test extends RepositoryTestCase {
assertTrue(fti.isModified(dci.getDirCacheEntry(), true,
db.newObjectReader()));
}
}
}

Loading…
Cancel
Save