summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2023-08-16 13:26:39 -0700
committerIvan Frade <ifrade@google.com>2023-08-16 13:31:55 -0700
commit6f733369391ab45987f87102e626c851454ed141 (patch)
tree902b454678eacb5b94c5896186fbdf1d1b8fb2c2 /org.eclipse.jgit.test/tst
parentb4b8f05eea80d4bf6e17db12e721c24ff3e32c9a (diff)
downloadjgit-6f733369391ab45987f87102e626c851454ed141.tar.gz
jgit-6f733369391ab45987f87102e626c851454ed141.zip
DfsGarbageCollector: put only GC commits into the commit graph
GC puts all commits reachable from heads and tags into the GC pack, and commits reachable only from other refs (e.g. refs/changes) into GC_REST. The commit-graph contains all commits in GC and GC_REST. This produces too big commit graphs in some repos, beating the purpose of loading the index. Limit the commit graph to commits reachable from heads and tags (i.e. commits in the GC pack). Change-Id: I4962faea5a726d2ea3e548af0aeae370a6cc8588
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java22
1 files changed, 12 insertions, 10 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 405e12677e..16c34500a3 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
@@ -979,7 +979,7 @@ public class DfsGarbageCollectorTest {
}
@Test
- public void produceCommitGraphAllRefsIncludedFromDisk() throws Exception {
+ public void produceCommitGraphOnlyHeadsAndTags() throws Exception {
String tag = "refs/tags/tag1";
String head = "refs/heads/head1";
String nonHead = "refs/something/nonHead";
@@ -1001,19 +1001,20 @@ public class DfsGarbageCollectorTest {
CommitGraph cg = gcPack.getCommitGraph(reader);
assertNotNull(cg);
- assertTrue("all commits in commit graph", cg.getCommitCnt() == 3);
+ assertTrue("Only heads and tags reachable commits in commit graph",
+ cg.getCommitCnt() == 2);
// GC packed
assertTrue("tag referenced commit is in graph",
cg.findGraphPosition(rootCommitTagged) != -1);
assertTrue("head referenced commit is in graph",
cg.findGraphPosition(headTip) != -1);
- // GC_REST packed
- assertTrue("nonHead referenced commit is in graph",
- cg.findGraphPosition(nonHeadTip) != -1);
+ // GC_REST not in commit graph
+ assertEquals("nonHead referenced commit is NOT in graph",
+ -1, cg.findGraphPosition(nonHeadTip));
}
@Test
- public void produceCommitGraphAllRefsIncludedFromCache() throws Exception {
+ public void produceCommitGraphOnlyHeadsAndTagsIncludedFromCache() throws Exception {
String tag = "refs/tags/tag1";
String head = "refs/heads/head1";
String nonHead = "refs/something/nonHead";
@@ -1043,15 +1044,16 @@ public class DfsGarbageCollectorTest {
assertTrue("commit graph read time is recorded",
reader.stats.readCommitGraphMicros > 0);
- assertTrue("all commits in commit graph", cachedCG.getCommitCnt() == 3);
+ assertTrue("Only heads and tags reachable commits in commit graph",
+ cachedCG.getCommitCnt() == 2);
// GC packed
assertTrue("tag referenced commit is in graph",
cachedCG.findGraphPosition(rootCommitTagged) != -1);
assertTrue("head referenced commit is in graph",
cachedCG.findGraphPosition(headTip) != -1);
- // GC_REST packed
- assertTrue("nonHead referenced commit is in graph",
- cachedCG.findGraphPosition(nonHeadTip) != -1);
+ // GC_REST not in commit graph
+ assertEquals("nonHead referenced commit is not in graph",
+ -1, cachedCG.findGraphPosition(nonHeadTip));
}
@Test