Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java59
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());
+ }
}
/**

Back to the top