diff options
Diffstat (limited to 'org.eclipse.jgit.junit/src')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java index 18275ec710..5b0e74cace 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java @@ -600,33 +600,38 @@ public class TestRepository<R extends Repository> { public void packAndPrune() throws Exception { if (db.getObjectDatabase() instanceof ObjectDirectory) { ObjectDirectory odb = (ObjectDirectory) db.getObjectDatabase(); - PackWriter pw = new PackWriter(db, NullProgressMonitor.INSTANCE); - Set<ObjectId> all = new HashSet<ObjectId>(); - for (Ref r : db.getAllRefs().values()) - all.add(r.getObjectId()); - pw.preparePack(all, Collections.<ObjectId> emptySet()); + final File pack, idx; + PackWriter pw = new PackWriter(db, NullProgressMonitor.INSTANCE); + try { + Set<ObjectId> all = new HashSet<ObjectId>(); + for (Ref r : db.getAllRefs().values()) + all.add(r.getObjectId()); + pw.preparePack(all, Collections.<ObjectId> emptySet()); - final ObjectId name = pw.computeName(); - OutputStream out; + final ObjectId name = pw.computeName(); + OutputStream out; - final File pack = nameFor(odb, name, ".pack"); - out = new BufferedOutputStream(new FileOutputStream(pack)); - try { - pw.writePack(out); - } finally { - out.close(); - } - pack.setReadOnly(); + pack = nameFor(odb, name, ".pack"); + out = new BufferedOutputStream(new FileOutputStream(pack)); + try { + pw.writePack(out); + } finally { + out.close(); + } + pack.setReadOnly(); - final File idx = nameFor(odb, name, ".idx"); - out = new BufferedOutputStream(new FileOutputStream(idx)); - try { - pw.writeIndex(out); + idx = nameFor(odb, name, ".idx"); + out = new BufferedOutputStream(new FileOutputStream(idx)); + try { + pw.writeIndex(out); + } finally { + out.close(); + } + idx.setReadOnly(); } finally { - out.close(); + pw.release(); } - idx.setReadOnly(); odb.openPack(pack, idx); updateServerInfo(); |