diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-02-05 17:31:11 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-02-05 17:31:11 +0900 |
commit | 8074f50b581cdb6cd9e3c189991caa0b8a56b7eb (patch) | |
tree | deaa9aab3e300c92678433e0f987a611fd04283c /org.eclipse.jgit.test/tst/org/eclipse/jgit/merge | |
parent | 3c4e7c08a70ce72cf67bec5af689feadba3c3c61 (diff) | |
download | jgit-8074f50b581cdb6cd9e3c189991caa0b8a56b7eb.tar.gz jgit-8074f50b581cdb6cd9e3c189991caa0b8a56b7eb.zip |
ResolveMergerTest: Open Git in try-with-resource
Change-Id: Ic378ec25c4a3ea4354ee643029f87e46b6449ed4
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/merge')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java index 674619f0de..55bb93acf8 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java @@ -88,35 +88,36 @@ public class ResolveMergerTest extends RepositoryTestCase { file = new File(folder1, "file2.txt"); write(file, "folder1--file2.txt"); - Git git = new Git(db); - git.add().addFilepattern(folder1.getName()).call(); - RevCommit base = git.commit().setMessage("adding folder").call(); - - recursiveDelete(folder1); - git.rm().addFilepattern("folder1/file1.txt") - .addFilepattern("folder1/file2.txt").call(); - RevCommit other = git.commit() - .setMessage("removing folders on 'other'").call(); - - git.checkout().setName(base.name()).call(); - - file = new File(db.getWorkTree(), "unrelated.txt"); - write(file, "unrelated"); - - git.add().addFilepattern("unrelated.txt").call(); - RevCommit head = git.commit().setMessage("Adding another file").call(); - - // Untracked file to cause failing path for delete() of folder1 - // but that's ok. - file = new File(folder1, "file3.txt"); - write(file, "folder1--file3.txt"); - - ResolveMerger merger = (ResolveMerger) strategy.newMerger(db, false); - merger.setCommitNames(new String[] { "BASE", "HEAD", "other" }); - merger.setWorkingTreeIterator(new FileTreeIterator(db)); - boolean ok = merger.merge(head.getId(), other.getId()); - assertTrue(ok); - assertTrue(file.exists()); + try (Git git = new Git(db)) { + git.add().addFilepattern(folder1.getName()).call(); + RevCommit base = git.commit().setMessage("adding folder").call(); + + recursiveDelete(folder1); + git.rm().addFilepattern("folder1/file1.txt") + .addFilepattern("folder1/file2.txt").call(); + RevCommit other = git.commit() + .setMessage("removing folders on 'other'").call(); + + git.checkout().setName(base.name()).call(); + + file = new File(db.getWorkTree(), "unrelated.txt"); + write(file, "unrelated"); + + git.add().addFilepattern("unrelated.txt").call(); + RevCommit head = git.commit().setMessage("Adding another file").call(); + + // Untracked file to cause failing path for delete() of folder1 + // but that's ok. + file = new File(folder1, "file3.txt"); + write(file, "folder1--file3.txt"); + + ResolveMerger merger = (ResolveMerger) strategy.newMerger(db, false); + merger.setCommitNames(new String[] { "BASE", "HEAD", "other" }); + merger.setWorkingTreeIterator(new FileTreeIterator(db)); + boolean ok = merger.merge(head.getId(), other.getId()); + assertTrue(ok); + assertTrue(file.exists()); + } } /** |