summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2016-01-25 15:23:06 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2016-01-25 15:23:06 +0900
commit7ccda5f63ecb7d416f0647a88bb944c3fae6ee0a (patch)
treecabb855ed590959b3d5b34b5670dcf19aa6e2daa /org.eclipse.jgit.test/tst
parente5cf4a89fd25fc7f857f8dd84ce87cb6bd98c3c0 (diff)
downloadjgit-7ccda5f63ecb7d416f0647a88bb944c3fae6ee0a.tar.gz
jgit-7ccda5f63ecb7d416f0647a88bb944c3fae6ee0a.zip
PullCommandTest: Open RevWalk in try-with-resource
Change-Id: I676cd7ef4bb29f980a313acd77506dd070e6c98f Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java33
1 files changed, 18 insertions, 15 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
index 57888e70a8..ff7066e8bf 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
@@ -140,11 +140,12 @@ public class PullCommandTest extends RepositoryTestCase {
ObjectId[] mergedCommits = mergeResult.getMergedCommits();
assertEquals(targetCommit.getId(), mergedCommits[0]);
assertEquals(sourceCommit.getId(), mergedCommits[1]);
- RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult
- .getNewHead());
- String message = "Merge branch 'master' of "
- + db.getWorkTree().getAbsolutePath();
- assertEquals(message, mergeCommit.getShortMessage());
+ try (RevWalk rw = new RevWalk(dbTarget)) {
+ RevCommit mergeCommit = rw.parseCommit(mergeResult.getNewHead());
+ String message = "Merge branch 'master' of "
+ + db.getWorkTree().getAbsolutePath();
+ assertEquals(message, mergeCommit.getShortMessage());
+ }
}
@Test
@@ -259,11 +260,12 @@ public class PullCommandTest extends RepositoryTestCase {
ObjectId[] mergedCommits = mergeResult.getMergedCommits();
assertEquals(targetCommit.getId(), mergedCommits[0]);
assertEquals(sourceCommit.getId(), mergedCommits[1]);
- RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult
- .getNewHead());
- String message = "Merge branch 'other' of "
- + db.getWorkTree().getAbsolutePath();
- assertEquals(message, mergeCommit.getShortMessage());
+ try (RevWalk rw = new RevWalk(dbTarget)) {
+ RevCommit mergeCommit = rw.parseCommit(mergeResult.getNewHead());
+ String message = "Merge branch 'other' of "
+ + db.getWorkTree().getAbsolutePath();
+ assertEquals(message, mergeCommit.getShortMessage());
+ }
}
@Test
@@ -293,11 +295,12 @@ public class PullCommandTest extends RepositoryTestCase {
ObjectId[] mergedCommits = mergeResult.getMergedCommits();
assertEquals(targetCommit.getId(), mergedCommits[0]);
assertEquals(sourceCommit.getId(), mergedCommits[1]);
- RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult
- .getNewHead());
- String message = "Merge branch 'other' of "
- + db.getWorkTree().getAbsolutePath() + " into other";
- assertEquals(message, mergeCommit.getShortMessage());
+ try (RevWalk rw = new RevWalk(dbTarget)) {
+ RevCommit mergeCommit = rw.parseCommit(mergeResult.getNewHead());
+ String message = "Merge branch 'other' of "
+ + db.getWorkTree().getAbsolutePath() + " into other";
+ assertEquals(message, mergeCommit.getShortMessage());
+ }
}
private enum TestPullMode {