DirCacheCheckoutMaliciousPathTest: Open Git and RevWalk in t-w-r

Change-Id: Iacb4e25f0ada74b1a01e448216cb02c7ec18b2d7
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
This commit is contained in:
David Pursehouse 2016-02-15 17:14:09 +09:00
parent 30c9ec88d1
commit 259dca06ec
1 changed files with 62 additions and 61 deletions

View File

@ -338,7 +338,8 @@ private void testMaliciousPathGoodSecondCheckout(String... paths) throws Excepti
*/
private void testMaliciousPath(boolean good, boolean secondCheckout,
String... path) throws GitAPIException, IOException {
Git git = new Git(db);
try (Git git = new Git(db);
RevWalk revWalk = new RevWalk(git.getRepository())) {
ObjectInserter newObjectInserter;
newObjectInserter = git.getRepository().newObjectInserter();
ObjectId blobId = newObjectInserter.insert(Constants.OBJ_BLOB,
@ -379,7 +380,6 @@ private void testMaliciousPath(boolean good, boolean secondCheckout,
commitBuilder.setParentId(firstCommitId);
ObjectId commitId = newObjectInserter.insert(commitBuilder);
RevWalk revWalk = new RevWalk(git.getRepository());
if (!secondCheckout)
git.checkout().setStartPoint(revWalk.parseCommit(firstCommitId))
.setName("refs/heads/master").setCreateBranch(true).call();
@ -402,5 +402,6 @@ private void testMaliciousPath(boolean good, boolean secondCheckout,
assertTrue(e.getMessage().startsWith("Invalid path"));
}
}
}
}