aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2017-11-16 10:45:57 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2017-11-16 10:45:57 -0500
commit7bf8f526996c1a39c4e05f59a1d6bcbc76983eb6 (patch)
treef3d072588dcd50e5a28a319a1b0aa802f7a5ed9c /org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage
parentaf2eaaed68f4b7498a670497459a3e1eba70525a (diff)
parent15a189e4e0c38a8138c5d5d15ce94e50d3495bf1 (diff)
downloadjgit-7bf8f526996c1a39c4e05f59a1d6bcbc76983eb6.tar.gz
jgit-7bf8f526996c1a39c4e05f59a1d6bcbc76983eb6.zip
Merge changes from topic 'includeDeletes'
* changes: Add flag for keeping ref tombstones in GC reftable Preserve ref tombstone when compact top retable stack
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java102
1 files changed, 102 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java
index 92399e04e4..5b567d00f7 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java
@@ -9,6 +9,7 @@ import static org.eclipse.jgit.internal.storage.pack.PackExt.REFTABLE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -18,6 +19,7 @@ import java.util.Collections;
import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource;
+import org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase;
import org.eclipse.jgit.internal.storage.reftable.RefCursor;
import org.eclipse.jgit.internal.storage.reftable.ReftableConfig;
import org.eclipse.jgit.internal.storage.reftable.ReftableReader;
@@ -842,6 +844,106 @@ public class DfsGarbageCollectorTest {
}
}
+ @Test
+ public void reftableWithoutTombstoneResurrected() throws Exception {
+ RevCommit commit0 = commit().message("0").create();
+ String NEXT = "refs/heads/next";
+ DfsRefDatabase refdb = (DfsRefDatabase)repo.getRefDatabase();
+ git.update(NEXT, commit0);
+ Ref next = refdb.exactRef(NEXT);
+ assertNotNull(next);
+ assertEquals(commit0, next.getObjectId());
+
+ git.delete(NEXT);
+ refdb.clearCache();
+ assertNull(refdb.exactRef(NEXT));
+
+ DfsGarbageCollector gc = new DfsGarbageCollector(repo);
+ gc.setReftableConfig(new ReftableConfig());
+ gc.setIncludeDeletes(false);
+ gc.setConvertToReftable(false);
+ run(gc);
+ assertEquals(1, odb.getReftables().length);
+ try (DfsReader ctx = odb.newReader();
+ ReftableReader rr = odb.getReftables()[0].open(ctx)) {
+ rr.setIncludeDeletes(true);
+ assertEquals(1, rr.minUpdateIndex());
+ assertEquals(2, rr.maxUpdateIndex());
+ assertNull(rr.exactRef(NEXT));
+ }
+
+ RevCommit commit1 = commit().message("1").create();
+ DfsPackDescription t1 = odb.newPack(INSERT);
+ Ref newNext = new ObjectIdRef.PeeledNonTag(Ref.Storage.LOOSE, NEXT,
+ commit1);
+ try (DfsOutputStream out = odb.writeFile(t1, REFTABLE)) {
+ ReftableWriter w = new ReftableWriter();
+ w.setMinUpdateIndex(1);
+ w.setMaxUpdateIndex(1);
+ w.begin(out);
+ w.writeRef(newNext, 1);
+ w.finish();
+ t1.addFileExt(REFTABLE);
+ t1.setReftableStats(w.getStats());
+ }
+ odb.commitPack(Collections.singleton(t1), null);
+ assertEquals(2, odb.getReftables().length);
+ refdb.clearCache();
+ newNext = refdb.exactRef(NEXT);
+ assertNotNull(newNext);
+ assertEquals(commit1, newNext.getObjectId());
+ }
+
+ @Test
+ public void reftableWithTombstoneNotResurrected() throws Exception {
+ RevCommit commit0 = commit().message("0").create();
+ String NEXT = "refs/heads/next";
+ DfsRefDatabase refdb = (DfsRefDatabase)repo.getRefDatabase();
+ git.update(NEXT, commit0);
+ Ref next = refdb.exactRef(NEXT);
+ assertNotNull(next);
+ assertEquals(commit0, next.getObjectId());
+
+ git.delete(NEXT);
+ refdb.clearCache();
+ assertNull(refdb.exactRef(NEXT));
+
+ DfsGarbageCollector gc = new DfsGarbageCollector(repo);
+ gc.setReftableConfig(new ReftableConfig());
+ gc.setIncludeDeletes(true);
+ gc.setConvertToReftable(false);
+ run(gc);
+ assertEquals(1, odb.getReftables().length);
+ try (DfsReader ctx = odb.newReader();
+ ReftableReader rr = odb.getReftables()[0].open(ctx)) {
+ rr.setIncludeDeletes(true);
+ assertEquals(1, rr.minUpdateIndex());
+ assertEquals(2, rr.maxUpdateIndex());
+ next = rr.exactRef(NEXT);
+ assertNotNull(next);
+ assertNull(next.getObjectId());
+ }
+
+ RevCommit commit1 = commit().message("1").create();
+ DfsPackDescription t1 = odb.newPack(INSERT);
+ Ref newNext = new ObjectIdRef.PeeledNonTag(Ref.Storage.LOOSE, NEXT,
+ commit1);
+ try (DfsOutputStream out = odb.writeFile(t1, REFTABLE)) {
+ ReftableWriter w = new ReftableWriter();
+ w.setMinUpdateIndex(1);
+ w.setMaxUpdateIndex(1);
+ w.begin(out);
+ w.writeRef(newNext, 1);
+ w.finish();
+ t1.addFileExt(REFTABLE);
+ t1.setReftableStats(w.getStats());
+ }
+ odb.commitPack(Collections.singleton(t1), null);
+ assertEquals(2, odb.getReftables().length);
+ refdb.clearCache();
+ assertNull(refdb.exactRef(NEXT));
+ }
+
private TestRepository<InMemoryRepository>.CommitBuilder commit() {
return git.commit();
}