Browse Source

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>
stable-4.2
David Pursehouse 9 years ago
parent
commit
d4ddb6fc2b
  1. 33
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java

33
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

Loading…
Cancel
Save