summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2023-05-08 13:51:28 -0700
committerJonathan Tan <jonathantanmy@google.com>2023-07-18 14:21:48 -0700
commit77aec62141cd22067f853eb0e0f7a2df757e3155 (patch)
treeb23e1dc92f2a9c8b771b96ea237074e390026cf1 /org.eclipse.jgit.test
parentd3b40e72acd30b8842da8f450775a5c847ad20ef (diff)
downloadjgit-77aec62141cd22067f853eb0e0f7a2df757e3155.tar.gz
jgit-77aec62141cd22067f853eb0e0f7a2df757e3155.zip
CommitGraphWriter: reuse changed path filters
Teach CommitGraphWriter to reuse changed path filters that have been read from the commit graph file whenever possible. Change-Id: I1acbfa1613ca7198386a49209028886af360ddb6 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriterTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriterTest.java
index e7f49496ad..79276ff564 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriterTest.java
@@ -23,8 +23,10 @@ import java.util.Set;
import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.internal.storage.file.FileRepository;
+import org.eclipse.jgit.internal.storage.file.GC;
import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.junit.TestRepository;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevBlob;
@@ -316,6 +318,40 @@ public class CommitGraphWriterTest extends RepositoryTestCase {
assertThat(changedPaths, containsInAnyOrder("-1,"));
}
+ @Test
+ public void testReuseBloomFilters() throws Exception {
+ RevBlob emptyBlob = tr.blob(new byte[] {});
+ RevCommit root = tr.commit(tr.tree(tr.file("foo.txt", emptyBlob),
+ tr.file("onedir/twodir/bar.txt", emptyBlob)));
+ tr.branch("master").update(root);
+
+ db.getConfig().setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_COMMIT_GRAPH, true);
+ db.getConfig().setBoolean(ConfigConstants.CONFIG_GC_SECTION, null,
+ ConfigConstants.CONFIG_KEY_WRITE_COMMIT_GRAPH, true);
+ GC gc = new GC(db);
+ gc.gc().get();
+
+ RevCommit tip = tr.commit(tr.tree(tr.file("foo-new.txt", emptyBlob),
+ tr.file("onedir/twodir/bar-new.txt", emptyBlob)), root);
+
+ Set<ObjectId> wants = Collections.singleton(tip);
+ NullProgressMonitor m = NullProgressMonitor.INSTANCE;
+ GraphCommits graphCommits = GraphCommits.fromWalk(m, wants, walk);
+ writer = new CommitGraphWriter(graphCommits);
+ CommitGraphWriter.Stats stats = writer.write(m, os);
+
+ assertEquals(1, stats.getChangedPathFiltersReused());
+ assertEquals(1, stats.getChangedPathFiltersComputed());
+
+ // Expected strings are the same as in
+ // #testChangedPathFilterRootAndNested
+ HashSet<String> changedPaths = changedPathStrings(os.toByteArray());
+ assertThat(changedPaths, containsInAnyOrder(
+ "109,-33,2,60,20,79,-11,116,",
+ "119,69,63,-8,0,"));
+ }
+
RevCommit commit(RevCommit... parents) throws Exception {
return tr.commit(parents);
}