]> source.dussan.org Git - jgit.git/commitdiff
BranchTest: Create Git instances in try-with-resource 22/64322/2
authorDavid Pursehouse <david.pursehouse@sonymobile.com>
Thu, 14 Jan 2016 08:38:18 +0000 (17:38 +0900)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 19 Jan 2016 16:27:46 +0000 (17:27 +0100)
Change-Id: I8becee479fab91a18e6daffd6f4fd57338c9d120
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/BranchTest.java

index 4200cd05cf0b2d166e48779768bcb3f3babf9560..d1bd5bacebe49a238454947a5ca768658aad4cae 100644 (file)
@@ -57,7 +57,9 @@ public class BranchTest extends CLIRepositoryTestCase {
        @Before
        public void setUp() throws Exception {
                super.setUp();
-               new Git(db).commit().setMessage("initial commit").call();
+               try (Git git = new Git(db)) {
+                       git.commit().setMessage("initial commit").call();
+               }
        }
 
        @Test
@@ -77,13 +79,15 @@ public class BranchTest extends CLIRepositoryTestCase {
 
        @Test
        public void testListContains() throws Exception {
-               new Git(db).branchCreate().setName("initial").call();
-               RevCommit second = new Git(db).commit().setMessage("second commit")
-                               .call();
-               assertArrayOfLinesEquals(new String[] { "  initial", "* master", "" },
-                               execute("git branch --contains 6fd41be"));
-               assertArrayOfLinesEquals(new String[] { "* master", "" },
-                               execute("git branch --contains " + second.name()));
+               try (Git git = new Git(db)) {
+                               git.branchCreate().setName("initial").call();
+                       RevCommit second = git.commit().setMessage("second commit")
+                                       .call();
+                       assertArrayOfLinesEquals(new String[] { "  initial", "* master", "" },
+                                       execute("git branch --contains 6fd41be"));
+                       assertArrayOfLinesEquals(new String[] { "* master", "" },
+                                       execute("git branch --contains " + second.name()));
+               }
        }
 
        @Test