From 5a95e7e74bd18e0719306ac7363b7b60964ff915 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Sun, 19 Aug 2018 20:53:31 +0200 Subject: [PATCH] SubmoduleDeinitTest fails on Windows Bug: 538068 Change-Id: I982e8b12936582e8e119f45d7a3bf4888d3e0e1a Signed-off-by: Andrey Loskutov --- .../eclipse/jgit/submodule/SubmoduleDeinitTest.java | 10 ++++++---- .../org/eclipse/jgit/api/SubmoduleDeinitCommand.java | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleDeinitTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleDeinitTest.java index df4b96398f..815ce9b350 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleDeinitTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleDeinitTest.java @@ -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()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleDeinitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleDeinitCommand.java index 569a8e3596..5a0528b0f5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleDeinitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleDeinitCommand.java @@ -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; + } } } -- 2.39.5