diff options
author | Han-Wen Nienhuys <hanwen@google.com> | 2020-02-18 20:44:10 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-03-04 15:45:01 +0100 |
commit | 30fb4808f2407cbea6c8cf46189033b0231aa423 (patch) | |
tree | eb967e3c0a464f7402c8c7fe0ed6e2c9930f4e83 /org.eclipse.jgit.test | |
parent | 6f268f8cebbc53a9810f0fe6ca1a961a32d8b074 (diff) | |
download | jgit-30fb4808f2407cbea6c8cf46189033b0231aa423.tar.gz jgit-30fb4808f2407cbea6c8cf46189033b0231aa423.zip |
Update reftable storage repo layout
The change Ic0b974fa (c217d33, "Documentation/technical/reftable:
improve repo layout") defines a new repository layout, which was
agreed with the git-core mailing list.
It addresses the following problems:
* old git clients will not recognize reftable-based repositories, and
look at encompassing directories.
* Poorly written tools might write directly into
.git/refs/heads/BRANCH.
Since we consider JGit reftable as experimental (git-core doesn't
support it yet), we have no backward compatibility. If you created a
repository with reftable between mid-Nov 2019 and now, you can do the
following to convert:
mv .git/refs .git/reftable/tables.list
git config core.repositoryformatversion 1
git config extensions.refStorage reftable
Change-Id: I80df35b9d22a8ab893dcbe9fbd051d924788d6a5
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableTest.java | 42 |
1 files changed, 34 insertions, 8 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 bca113fbfc..2ffbc6255a 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 @@ -125,11 +125,6 @@ public class FileReftableTest extends SampleDataRepositoryTestCase { } @Test - public void additionalRefsAreRemoved() { - assertFalse(new File(db.getDirectory(), Constants.HEAD).exists()); - } - - @Test public void testCompactFully() throws Exception { ObjectId c1 = db.resolve("master^^"); ObjectId c2 = db.resolve("master^"); @@ -141,9 +136,16 @@ public class FileReftableTest extends SampleDataRepositoryTestCase { } File tableDir = new File(db.getDirectory(), Constants.REFTABLE); - assertTrue(tableDir.listFiles().length > 1); + assertTrue(tableDir.listFiles().length > 2); ((FileReftableDatabase)db.getRefDatabase()).compactFully(); - assertEquals(tableDir.listFiles().length,1); + assertEquals(tableDir.listFiles().length,2); + } + + @Test + public void testOpenConvert() throws Exception { + try (FileRepository repo = new FileRepository(db.getDirectory())) { + assertTrue(repo.getRefDatabase() instanceof FileReftableDatabase); + } } @Test @@ -162,7 +164,7 @@ public class FileReftableTest extends SampleDataRepositoryTestCase { @Test public void testConvertToRefdir() throws Exception { - db.convertToPackedRefs(false); + db.convertToPackedRefs(false, false); assertTrue(db.getRefDatabase() instanceof RefDirectory); Ref h = db.exactRef("HEAD"); assertTrue(h.isSymbolic()); @@ -177,6 +179,30 @@ public class FileReftableTest extends SampleDataRepositoryTestCase { } @Test + public void testConvertToRefdirReflog() throws Exception { + Ref a = db.exactRef("refs/heads/a"); + String aCommit = a.getObjectId().getName(); + RefUpdate u = db.updateRef("refs/heads/master"); + u.setForceUpdate(true); + u.setNewObjectId(ObjectId.fromString(aCommit)); + u.setForceRefLog(true); + u.setRefLogMessage("apple", false); + u.update(); + + RefUpdate v = db.updateRef("refs/heads/master"); + v.setForceUpdate(true); + v.setNewObjectId(ObjectId.fromString(bCommit)); + v.setForceRefLog(true); + v.setRefLogMessage("banana", false); + v.update(); + + db.convertToPackedRefs(true, false); + List<ReflogEntry> logs = db.getReflogReader("refs/heads/master").getReverseEntries(2); + assertEquals(logs.get(0).getComment(), "banana"); + assertEquals(logs.get(1).getComment(), "apple"); + } + + @Test public void testBatchrefUpdate() throws Exception { ObjectId cur = db.resolve("master"); ObjectId prev = db.resolve("master^"); |