From 7dc6c553c02875991c6124ab02f0c0f72dae04b9 Mon Sep 17 00:00:00 2001 From: Colby Ranger Date: Mon, 16 Sep 2013 11:56:02 -0700 Subject: [PATCH] Remove unneeded packs when compacting with no new objects Previously, the DfsPackCompactor exited without pruning the existing packs, when no new packs were created. Change-Id: I5e3b6f8c789706c7a982e6ae93cf7c3d4346797c --- .../jgit/internal/storage/dfs/DfsPackCompactor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java index ea563926b..83728842b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java @@ -220,8 +220,14 @@ public void compact(ProgressMonitor pm) throws IOException { pw.setReuseDeltaCommits(false); addObjectsToPack(pw, ctx, pm); - if (pw.getObjectCount() == 0) + if (pw.getObjectCount() == 0) { + List remove = toPrune(); + if (remove.size() > 0) + objdb.commitPack( + Collections.emptyList(), + remove); return; + } boolean rollback = true; DfsPackDescription pack = objdb.newPack(COMPACT);