summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2016-02-02 18:22:32 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2016-02-02 18:22:32 +0900
commitd4ddb6fc2b2402aa78520bcffce6dc784c5c27bd (patch)
tree7f8f97394b18235aeff4f31e845d13d3498bd3f0
parent5c84145fd041f403528a6d9e877f0d7bc7cdfb6a (diff)
downloadjgit-d4ddb6fc2b2402aa78520bcffce6dc784c5c27bd.tar.gz
jgit-d4ddb6fc2b2402aa78520bcffce6dc784c5c27bd.zip
ApplyCommandTest: Open Git in try-with-resource
Also, add missing braces around if-block. Change-Id: I9390b2c7d5c4507923b6f06271a070dc868534e5 Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java33
1 files changed, 17 insertions, 16 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
index ad3ff60a00..d842046bb7 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
@@ -69,23 +69,24 @@ public class ApplyCommandTest extends RepositoryTestCase {
private ApplyResult init(final String name, final boolean preExists,
final boolean postExists) throws Exception {
- Git git = new Git(db);
-
- if (preExists) {
- a = new RawText(readFile(name + "_PreImage"));
- write(new File(db.getDirectory().getParent(), name),
- a.getString(0, a.size(), false));
-
- git.add().addFilepattern(name).call();
- git.commit().setMessage("PreImage").call();
+ try (Git git = new Git(db)) {
+ if (preExists) {
+ a = new RawText(readFile(name + "_PreImage"));
+ write(new File(db.getDirectory().getParent(), name),
+ a.getString(0, a.size(), false));
+
+ git.add().addFilepattern(name).call();
+ git.commit().setMessage("PreImage").call();
+ }
+
+ if (postExists) {
+ b = new RawText(readFile(name + "_PostImage"));
+ }
+
+ return git
+ .apply()
+ .setPatch(getTestResource(name + ".patch")).call();
}
-
- if (postExists)
- b = new RawText(readFile(name + "_PostImage"));
-
- return git
- .apply()
- .setPatch(getTestResource(name + ".patch")).call();
}
@Test