summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileReftableTest.java23
1 files changed, 13 insertions, 10 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 2ffbc6255a..4907073ffe 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
@@ -58,7 +58,9 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
@@ -162,20 +164,21 @@ public class FileReftableTest extends SampleDataRepositoryTestCase {
assertTrue(db.getRefDatabase().hasFastTipsWithSha1());
}
+
@Test
- public void testConvertToRefdir() throws Exception {
+ public void testConvertBrokenObjectId() throws Exception {
db.convertToPackedRefs(false, false);
- assertTrue(db.getRefDatabase() instanceof RefDirectory);
- Ref h = db.exactRef("HEAD");
- assertTrue(h.isSymbolic());
- assertEquals("refs/heads/master", h.getTarget().getName());
+ new File(db.getDirectory(), "refs/heads").mkdirs();
- Ref b = db.exactRef("refs/heads/b");
- assertFalse(b.isSymbolic());
- assertTrue(b.isPeeled());
- assertEquals(bCommit, b.getObjectId().name());
+ String invalidId = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
+ File headFile = new File(db.getDirectory(), "refs/heads/broken");
+ try (OutputStream os = new FileOutputStream(headFile)) {
+ os.write(Constants.encodeASCII(invalidId + "\n"));
+ }
- assertFalse(db.getRefDatabase().hasFastTipsWithSha1());
+ Ref r = db.exactRef("refs/heads/broken");
+ assertNotNull(r);
+ db.convertToReftable(true, false);
}
@Test