diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2020-02-11 01:39:27 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-02-11 01:39:27 +0100 |
commit | e68e0e7f034e371841b626bb4e858134483bad03 (patch) | |
tree | 7f944aa042465875decf487fb3781592ea0da99b /org.eclipse.jgit.test | |
parent | 009674e99f846d2dabe9b0776fc983f1df61886b (diff) | |
parent | 79266a1fe5b6893ee66177489f7f59f08cb2b294 (diff) | |
download | jgit-e68e0e7f034e371841b626bb4e858134483bad03.tar.gz jgit-e68e0e7f034e371841b626bb4e858134483bad03.zip |
Merge branch 'stable-5.6'
* stable-5.6:
reftable: don't check deadline on the first try
reftable: clarify comment
reftable: clear cache on full compaction
reftable: remove outdated comment
reftable: clarify that LogCursor may return a null ReflogEntry
Change-Id: I9458a746311984fa687b3da964805e2568ed37f3
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableTest.java index 9da35075dc..b13cdb9fec 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableTest.java @@ -26,6 +26,7 @@ import static org.junit.Assert.fail; import java.io.File; import java.io.IOException; +import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; @@ -510,6 +511,43 @@ public class FileReftableTest extends SampleDataRepositoryTestCase { } @Test + public void compactFully() throws Exception { + FileReftableDatabase refDb = (FileReftableDatabase) db.getRefDatabase(); + PersonIdent person = new PersonIdent("jane", "jane@invalid"); + + ObjectId aId = db.exactRef("refs/heads/a").getObjectId(); + ObjectId bId = db.exactRef("refs/heads/b").getObjectId(); + + SecureRandom random = new SecureRandom(); + List<String> strs = new ArrayList<>(); + for (int i = 0; i < 1024; i++) { + strs.add(String.format("%02x", + Integer.valueOf(random.nextInt(256)))); + } + + String randomStr = String.join("", strs); + String refName = "branch"; + for (long i = 0; i < 2; i++) { + RefUpdate ru = refDb.newUpdate(refName, false); + ru.setNewObjectId(i % 2 == 0 ? aId : bId); + ru.setForceUpdate(true); + // Only write a large string in the first table, so it becomes much larger + // than the second, and the result is not autocompacted. + ru.setRefLogMessage(i == 0 ? randomStr : "short", false); + ru.setRefLogIdent(person); + + RefUpdate.Result res = ru.update(); + assertTrue(res == Result.NEW || res == FORCED); + } + + assertEquals(refDb.exactRef(refName).getObjectId(), bId); + assertTrue(randomStr.equals(refDb.getReflogReader(refName).getReverseEntry(1).getComment())); + refDb.compactFully(); + assertEquals(refDb.exactRef(refName).getObjectId(), bId); + assertTrue(randomStr.equals(refDb.getReflogReader(refName).getReverseEntry(1).getComment())); + } + + @Test public void reftableRefsStorageClass() throws IOException { Ref b = db.exactRef("refs/heads/b"); assertEquals(Ref.Storage.PACKED, b.getStorage()); |