Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2016-02-05 04:17:02 -0500
committerDavid Pursehouse2016-02-05 04:17:02 -0500
commitef471b086171075caadcef5f9fd16ee67aeea525 (patch)
tree9267fa657c8f42d0bf50ae5a6f9f5acf75f7e2a6
parent143ba06cd6259b8c64733a08f3d66cbe51e76b7f (diff)
downloadjgit-ef471b086171075caadcef5f9fd16ee67aeea525.tar.gz
jgit-ef471b086171075caadcef5f9fd16ee67aeea525.tar.xz
jgit-ef471b086171075caadcef5f9fd16ee67aeea525.zip
RepoTest: Open Git in try-with-resources
Allocate a new Git for each part of the test, rather than reassigning to the same variable. Change-Id: Ic83778bbff0b2f57d37b95aef70324859d42cd58 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RepoTest.java36
1 files changed, 20 insertions, 16 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RepoTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RepoTest.java
index 0eee771d2c..ba62383b3d 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RepoTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RepoTest.java
@@ -74,28 +74,32 @@ public class RepoTest extends CLIRepositoryTestCase {
super.setUp();
defaultDb = createWorkRepository();
- Git git = new Git(defaultDb);
- JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "world");
- git.add().addFilepattern("hello.txt").call();
- git.commit().setMessage("Initial commit").call();
+ try (Git git = new Git(defaultDb)) {
+ JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "world");
+ git.add().addFilepattern("hello.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ }
notDefaultDb = createWorkRepository();
- git = new Git(notDefaultDb);
- JGitTestUtil.writeTrashFile(notDefaultDb, "world.txt", "hello");
- git.add().addFilepattern("world.txt").call();
- git.commit().setMessage("Initial commit").call();
+ try (Git git = new Git(notDefaultDb)) {
+ JGitTestUtil.writeTrashFile(notDefaultDb, "world.txt", "hello");
+ git.add().addFilepattern("world.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ }
groupADb = createWorkRepository();
- git = new Git(groupADb);
- JGitTestUtil.writeTrashFile(groupADb, "a.txt", "world");
- git.add().addFilepattern("a.txt").call();
- git.commit().setMessage("Initial commit").call();
+ try (Git git = new Git(groupADb)) {
+ JGitTestUtil.writeTrashFile(groupADb, "a.txt", "world");
+ git.add().addFilepattern("a.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ }
groupBDb = createWorkRepository();
- git = new Git(groupBDb);
- JGitTestUtil.writeTrashFile(groupBDb, "b.txt", "world");
- git.add().addFilepattern("b.txt").call();
- git.commit().setMessage("Initial commit").call();
+ try (Git git = new Git(groupBDb)) {
+ JGitTestUtil.writeTrashFile(groupBDb, "b.txt", "world");
+ git.add().addFilepattern("b.txt").call();
+ git.commit().setMessage("Initial commit").call();
+ }
resolveRelativeUris();
}

Back to the top