diff options
author | yunjieli <yunjieli@google.com> | 2022-09-06 17:14:51 -0700 |
---|---|---|
committer | yunjieli <yunjieli@google.com> | 2022-09-07 10:18:16 -0700 |
commit | e7bffdfc487b0ae5d8a28ae9a038fe0050b27f8d (patch) | |
tree | 044beb7fcc41208faaa3171cb16dedb3ea4a8a91 /org.eclipse.jgit.test | |
parent | ca166a0c62af2ea87fdedf2728ac19cb59a12601 (diff) | |
download | jgit-e7bffdfc487b0ae5d8a28ae9a038fe0050b27f8d.tar.gz jgit-e7bffdfc487b0ae5d8a28ae9a038fe0050b27f8d.zip |
DfsBundleWriter: Add test case about GC_REST pack.
Add a test case to make sure that the bundle writer writes objects in
GC_REST packs as well.
Signed-off-by: Yunjie Li <yunjieli@google.com>
Change-Id: Iba4d88c573aa1cda4505afbe2b83581a09a343df
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBundleWriterTest.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBundleWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBundleWriterTest.java index 4238ee6bf0..bce62b9371 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBundleWriterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBundleWriterTest.java @@ -19,6 +19,8 @@ import java.io.IOException; import java.util.Collections; import java.util.Set; +import org.eclipse.jgit.api.GarbageCollectCommand; +import org.eclipse.jgit.api.Git; import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.Ref; @@ -44,7 +46,7 @@ public class DfsBundleWriterTest { } @Test - public void testRepo() throws Exception { + public void makeBundle_containsUnreferencedObject() throws Exception { RevCommit commit0 = git.commit().message("0").create(); RevCommit commit1 = git.commit().message("1").parent(commit0).create(); git.update("master", commit1); @@ -64,6 +66,31 @@ public class DfsBundleWriterTest { } } + @Test + public void makeBundle_containsObjectInGcRestPack() throws Exception { + RevCommit commit0 = git.commit().message("0").create(); + RevCommit commit1 = git.commit().message("1").parent(commit0).create(); + git.update("master", commit1); + + RevCommit commit2 = git.commit().message("0").create(); + + // This moves unreachable commit2 to GC_REST pack. + GarbageCollectCommand gc = Git.wrap(repo).gc(); + gc.call(); + + byte[] bundle = makeBundle(); + try (Repository newRepo = new InMemoryRepository( + new DfsRepositoryDescription("copy"))) { + fetchFromBundle(newRepo, bundle); + Ref ref = newRepo.exactRef("refs/heads/master"); + assertNotNull(ref); + assertEquals(commit1.toObjectId(), ref.getObjectId()); + + // Unreferenced objects in GC_REST pack are included as well. + assertTrue(newRepo.getObjectDatabase().has(commit2)); + } + } + private byte[] makeBundle() throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); DfsBundleWriter.writeEntireRepositoryAsBundle( |