Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2016-02-12 03:26:58 +0000
committerDavid Pursehouse2016-02-12 03:26:58 +0000
commit77887b49f93707248c996473db1d8672e33235b0 (patch)
treefa2c09d0d819d50e72b26bcd7d760bce9d08b26e
parent5ca9aaa17277c2d7f33508afcdc8f748fada8881 (diff)
downloadjgit-77887b49f93707248c996473db1d8672e33235b0.tar.gz
jgit-77887b49f93707248c996473db1d8672e33235b0.tar.xz
jgit-77887b49f93707248c996473db1d8672e33235b0.zip
ReflogTest: Open Git instances in try-with-resource
Change-Id: I950b6f16148cfe11de729b04904f88d6e4c28b9a Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ReflogTest.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ReflogTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ReflogTest.java
index ce808326b4..7330ee97be 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ReflogTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ReflogTest.java
@@ -57,24 +57,27 @@ public class ReflogTest extends CLIRepositoryTestCase {
@Test
public void testSingleCommit() throws Exception {
- new Git(db).commit().setMessage("initial commit").call();
+ try (Git git = new Git(db)) {
+ git.commit().setMessage("initial commit").call();
- assertEquals("6fd41be HEAD@{0}: commit (initial): initial commit",
- execute("git reflog")[0]);
+ assertEquals("6fd41be HEAD@{0}: commit (initial): initial commit",
+ execute("git reflog")[0]);
+ }
}
@Test
public void testBranch() throws Exception {
- Git git = new Git(db);
- git.commit().setMessage("first commit").call();
- git.checkout().setCreateBranch(true).setName("side").call();
- writeTrashFile("file", "side content");
- git.add().addFilepattern("file").call();
- git.commit().setMessage("side commit").call();
+ try (Git git = new Git(db)) {
+ git.commit().setMessage("first commit").call();
+ git.checkout().setCreateBranch(true).setName("side").call();
+ writeTrashFile("file", "side content");
+ git.add().addFilepattern("file").call();
+ git.commit().setMessage("side commit").call();
- assertArrayEquals(new String[] {
- "38890c7 side@{0}: commit: side commit",
- "d216986 side@{1}: branch: Created from commit first commit",
- "" }, execute("git reflog refs/heads/side"));
+ assertArrayEquals(new String[] {
+ "38890c7 side@{0}: commit: side commit",
+ "d216986 side@{1}: branch: Created from commit first commit",
+ "" }, execute("git reflog refs/heads/side"));
+ }
}
} \ No newline at end of file

Back to the top