Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2019-03-20 12:54:10 +0000
committerMatthias Sohn2019-03-20 13:10:30 +0000
commit534ede2d8143093110ff9f20ff9b510c690db8d1 (patch)
treebf5008eccf7eeb8c681ddbe12366d8141042f7f9 /org.eclipse.jgit.test/tst
parent2b64345f53d48badb8523c1d3536522af4851315 (diff)
downloadjgit-534ede2d8143093110ff9f20ff9b510c690db8d1.tar.gz
jgit-534ede2d8143093110ff9f20ff9b510c690db8d1.tar.xz
jgit-534ede2d8143093110ff9f20ff9b510c690db8d1.zip
Fix GC to delete empty fanout directories after repacking
The prune method did not delete empty fanout directories when loose objects moved to a new pack file but only when loose unreferenced objects were pruned. Change-Id: Ia068f4914c54d9cf9f40b75e8ea50759402b5000 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPruneNonReferencedTest.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPruneNonReferencedTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPruneNonReferencedTest.java
index 5b1a4178a6..345207089f 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPruneNonReferencedTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPruneNonReferencedTest.java
@@ -47,6 +47,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.io.File;
import java.util.Collections;
import java.util.Date;
@@ -113,8 +114,24 @@ public class GcPruneNonReferencedTest extends GcTestCase {
fsTick();
gc.gc();
stats = gc.getStatistics();
+ assertNoEmptyFanoutDirectories();
assertEquals(0, stats.numberOfLooseObjects);
assertEquals(8, stats.numberOfPackedObjects);
assertEquals(2, stats.numberOfPackFiles);
}
+
+ private void assertNoEmptyFanoutDirectories() {
+ File[] fanout = repo.getObjectsDirectory().listFiles();
+ for (File f : fanout) {
+ if (f.isDirectory()) {
+ String[] entries = f.list();
+ if (entries == null || entries.length == 0) {
+ assertFalse(
+ "Found empty fanout directory "
+ + f.getAbsolutePath() + " after pruning",
+ f.getName().length() == 2);
+ }
+ }
+ }
+ }
}

Back to the top