import org.junit.Before;
import org.junit.Test;
+/** Tests for pack creation and garbage expiration. */
public class DfsGarbageCollectorTest {
private TestRepository<InMemoryRepository> git;
private InMemoryRepository repo;
}
}
+ @Test
+ public void testSinglePackForAllRefs() throws Exception {
+ RevCommit commit0 = commit().message("0").create();
+ git.update("head", commit0);
+ RevCommit commit1 = commit().message("1").parent(commit0).create();
+ git.update("refs/notes/note1", commit1);
+
+ DfsGarbageCollector gc = new DfsGarbageCollector(repo);
+ gc.setGarbageTtl(0, TimeUnit.MILLISECONDS);
+ gc.getPackConfig().setSinglePack(true);
+ run(gc);
+ assertEquals(1, odb.getPacks().length);
+
+ gc = new DfsGarbageCollector(repo);
+ gc.setGarbageTtl(0, TimeUnit.MILLISECONDS);
+ gc.getPackConfig().setSinglePack(false);
+ run(gc);
+ assertEquals(2, odb.getPacks().length);
+ }
+
private TestRepository<InMemoryRepository>.CommitBuilder commit() {
return git.commit();
}
private boolean cutDeltaChains;
+ private boolean singlePack;
+
/** Create a default configuration. */
public PackConfig() {
// Fields are initialized to defaults.
this.bitmapExcessiveBranchCount = cfg.bitmapExcessiveBranchCount;
this.bitmapInactiveBranchAgeInDays = cfg.bitmapInactiveBranchAgeInDays;
this.cutDeltaChains = cfg.cutDeltaChains;
+ this.singlePack = cfg.singlePack;
}
/**
cutDeltaChains = cut;
}
+ /**
+ * @return true if all of refs/* should be packed in a single pack. Default
+ * is false, packing a separate GC_REST pack for references outside
+ * of refs/heads/* and refs/tags/*.
+ * @since 4.9
+ */
+ public boolean getSinglePack() {
+ return singlePack;
+ }
+
+ /**
+ * If {@code true}, packs a single GC pack for all objects reachable from
+ * refs/*. Otherwise packs the GC pack with objects reachable from
+ * refs/heads/* and refs/tags/*, and a GC_REST pack with the remaining
+ * reachable objects. Disabled by default, packing GC and GC_REST.
+ *
+ * @param single
+ * true to pack a single GC pack rather than GC and GC_REST packs
+ * @since 4.9
+ */
+ public void setSinglePack(boolean single) {
+ singlePack = single;
+ }
+
/**
* Get the number of objects to try when looking for a delta base.
*
rc.getBoolean("pack", "deltacompression", isDeltaCompress())); //$NON-NLS-1$ //$NON-NLS-2$
setCutDeltaChains(
rc.getBoolean("pack", "cutdeltachains", getCutDeltaChains())); //$NON-NLS-1$ //$NON-NLS-2$
+ setSinglePack(
+ rc.getBoolean("pack", "singlepack", getSinglePack())); //$NON-NLS-1$ //$NON-NLS-2$
setBuildBitmaps(
rc.getBoolean("pack", "buildbitmaps", isBuildBitmaps())); //$NON-NLS-1$ //$NON-NLS-2$
setBitmapContiguousCommitCount(
.append(getBitmapExcessiveBranchCount());
b.append(", bitmapInactiveBranchAge=") //$NON-NLS-1$
.append(getBitmapInactiveBranchAgeInDays());
+ b.append(", singlePack=").append(getSinglePack()); //$NON-NLS-1$
return b.toString();
}
}