]> source.dussan.org Git - jgit.git/commitdiff
SubmoduleDeinitTest fails on Windows 67/127667/1
authorAndrey Loskutov <loskutov@gmx.de>
Sun, 19 Aug 2018 18:53:31 +0000 (20:53 +0200)
committerAndrey Loskutov <loskutov@gmx.de>
Sun, 19 Aug 2018 18:53:31 +0000 (20:53 +0200)
Bug: 538068
Change-Id: I982e8b12936582e8e119f45d7a3bf4888d3e0e1a
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleDeinitTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleDeinitCommand.java

index df4b96398f8e0d918e2df6d046172ee91bdb42a2..815ce9b3504b552e8372b368e5284c5b3a2480ee 100644 (file)
@@ -136,10 +136,12 @@ public class SubmoduleDeinitTest extends RepositoryTestCase {
                generator.next();
 
                //want to create a commit inside the repo...
-               Repository submoduleLocalRepo = generator.getRepository();
-               JGitTestUtil.writeTrashFile(submoduleLocalRepo, "file.txt", "new data");
-               Git.wrap(submoduleLocalRepo).commit().setAll(true).setMessage("local commit").call();
-
+               try (Repository submoduleLocalRepo = generator.getRepository()) {
+                       JGitTestUtil.writeTrashFile(submoduleLocalRepo, "file.txt",
+                                       "new data");
+                       Git.wrap(submoduleLocalRepo).commit().setAll(true)
+                                       .setMessage("local commit").call();
+               }
                SubmoduleDeinitResult result = runDeinit(new SubmoduleDeinitCommand(db).addPath("sub"));
                assertEquals(path, result.getPath());
                assertEquals(SubmoduleDeinitCommand.SubmoduleDeinitStatus.DIRTY, result.getStatus());
index 569a8e359639c995058a7f41ad94b72a04f82e5f..5a0528b0f5b4a21928c0fee7ce779dff62b5ef1e 100644 (file)
@@ -227,11 +227,11 @@ public class SubmoduleDeinitCommand
                                return SubmoduleDeinitStatus.DIRTY;
                        }
 
-                       Repository submoduleRepo = w.getRepository();
-
-                       Status status = Git.wrap(submoduleRepo).status().call();
-                       return status.isClean() ? SubmoduleDeinitStatus.SUCCESS
-                                       : SubmoduleDeinitStatus.DIRTY;
+                       try (Repository submoduleRepo = w.getRepository()) {
+                               Status status = Git.wrap(submoduleRepo).status().call();
+                               return status.isClean() ? SubmoduleDeinitStatus.SUCCESS
+                                               : SubmoduleDeinitStatus.DIRTY;
+                       }
                }
        }