Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/RecursiveMergerTest.java')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/RecursiveMergerTest.java61
1 files changed, 28 insertions, 33 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/RecursiveMergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/RecursiveMergerTest.java
index 039a6e8cfc..190224a855 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/RecursiveMergerTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/RecursiveMergerTest.java
@@ -817,40 +817,35 @@ public class RecursiveMergerTest extends RepositoryTestCase {
void modifyWorktree(WorktreeState worktreeState, String path, String other)
throws Exception {
- FileOutputStream fos = null;
- ObjectId bloblId;
-
- try {
- switch (worktreeState) {
- case Missing:
- new File(db.getWorkTree(), path).delete();
- break;
- case DifferentFromHeadAndOther:
- write(new File(db.getWorkTree(), path),
- Integer.toString(counter++));
- break;
- case SameAsHead:
- bloblId = contentId(Constants.HEAD, path);
- fos = new FileOutputStream(new File(db.getWorkTree(), path));
- db.newObjectReader().open(bloblId).copyTo(fos);
- break;
- case SameAsOther:
- bloblId = contentId(other, path);
- fos = new FileOutputStream(new File(db.getWorkTree(), path));
- db.newObjectReader().open(bloblId).copyTo(fos);
- break;
- case Bare:
- if (db.isBare())
- return;
- File workTreeFile = db.getWorkTree();
- db.getConfig().setBoolean("core", null, "bare", true);
- db.getDirectory().renameTo(new File(workTreeFile, "test.git"));
- db = new FileRepository(new File(workTreeFile, "test.git"));
- db_t = new TestRepository<>(db);
+ switch (worktreeState) {
+ case Missing:
+ new File(db.getWorkTree(), path).delete();
+ break;
+ case DifferentFromHeadAndOther:
+ write(new File(db.getWorkTree(), path),
+ Integer.toString(counter++));
+ break;
+ case SameAsHead:
+ try (FileOutputStream fos = new FileOutputStream(
+ new File(db.getWorkTree(), path))) {
+ db.newObjectReader().open(contentId(Constants.HEAD, path))
+ .copyTo(fos);
}
- } finally {
- if (fos != null)
- fos.close();
+ break;
+ case SameAsOther:
+ try (FileOutputStream fos = new FileOutputStream(
+ new File(db.getWorkTree(), path))) {
+ db.newObjectReader().open(contentId(other, path)).copyTo(fos);
+ }
+ break;
+ case Bare:
+ if (db.isBare())
+ return;
+ File workTreeFile = db.getWorkTree();
+ db.getConfig().setBoolean("core", null, "bare", true);
+ db.getDirectory().renameTo(new File(workTreeFile, "test.git"));
+ db = new FileRepository(new File(workTreeFile, "test.git"));
+ db_t = new TestRepository<>(db);
}
}

Back to the top