Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2016-02-11 23:57:34 -0500
committerDavid Pursehouse2016-02-11 23:57:34 -0500
commitad9b326e3f42d49470c2ad687e4ebc9617a85089 (patch)
treeeeb89138a7d34b36a4457e6efa87f318feafa885
parentf3c250bd083871a11ea692ddd8a930a34e8db92c (diff)
downloadjgit-ad9b326e3f42d49470c2ad687e4ebc9617a85089.tar.gz
jgit-ad9b326e3f42d49470c2ad687e4ebc9617a85089.tar.xz
jgit-ad9b326e3f42d49470c2ad687e4ebc9617a85089.zip
PullCommandWithRebaseTest: Open RevWalk in try-with-resource
Change-Id: I16f4d219e8b103d30149b2a94d3484424f3de84b Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java41
1 files changed, 21 insertions, 20 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
index 9ad845b2a9..b405f6ad74 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
@@ -273,26 +273,27 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
// Get the HEAD and HEAD~1 commits
Repository targetRepo = target.getRepository();
- RevWalk revWalk = new RevWalk(targetRepo);
- ObjectId headId = targetRepo.resolve(Constants.HEAD);
- RevCommit root = revWalk.parseCommit(headId);
- revWalk.markStart(root);
- // HEAD
- RevCommit head = revWalk.next();
- // HEAD~1
- RevCommit beforeHead = revWalk.next();
-
- // verify the commit message on the HEAD commit
- assertEquals(TARGET_COMMIT_MESSAGE, head.getFullMessage());
- // verify the commit just before HEAD
- assertEquals(SOURCE_COMMIT_MESSAGE, beforeHead.getFullMessage());
-
- // verify file states
- assertFileContentsEqual(sourceFile, SOURCE_FILE_CONTENTS);
- assertFileContentsEqual(newFile, NEW_FILE_CONTENTS);
- // verify repository state
- assertEquals(RepositoryState.SAFE, target
- .getRepository().getRepositoryState());
+ try (RevWalk revWalk = new RevWalk(targetRepo)) {
+ ObjectId headId = targetRepo.resolve(Constants.HEAD);
+ RevCommit root = revWalk.parseCommit(headId);
+ revWalk.markStart(root);
+ // HEAD
+ RevCommit head = revWalk.next();
+ // HEAD~1
+ RevCommit beforeHead = revWalk.next();
+
+ // verify the commit message on the HEAD commit
+ assertEquals(TARGET_COMMIT_MESSAGE, head.getFullMessage());
+ // verify the commit just before HEAD
+ assertEquals(SOURCE_COMMIT_MESSAGE, beforeHead.getFullMessage());
+
+ // verify file states
+ assertFileContentsEqual(sourceFile, SOURCE_FILE_CONTENTS);
+ assertFileContentsEqual(newFile, NEW_FILE_CONTENTS);
+ // verify repository state
+ assertEquals(RepositoryState.SAFE, target
+ .getRepository().getRepositoryState());
+ }
}
@Override

Back to the top