Created
May 29, 2013 21:09
-
-
Save rtyley/5673862 to your computer and use it in GitHub Desktop.
Create a bad repo that contains a folder named '.git'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| implicit val repo = unpackRepo("/sample-repos/example.git.zip") | |
| implicit val (revWalk, reader) = repo.singleThreadedReaderTuple | |
| val inserter = repo.newObjectInserter() | |
| val badTree = Tree(Seq(Tree.Entry(".git", FileMode.TREE, abbrId("8d28f5")))) | |
| val badTreeId = badTree.formatter.insertTo(inserter) | |
| val treeContainingBadTree = Tree(Seq(Tree.Entry("foo", FileMode.TREE, badTreeId))) | |
| val treeContainingBadTreeId = treeContainingBadTree.formatter.insertTo(inserter) | |
| val originalCommit = Commit(abbrId("475d").asRevCommit) | |
| val badCommit = originalCommit.copy(arcs = originalCommit.arcs.copy(tree = treeContainingBadTreeId)) | |
| val badCommitId = inserter.insert(OBJ_COMMIT, badCommit.toBytes) | |
| val refUpdate = repo.getRefDatabase.newUpdate("refs/heads/master", false) | |
| refUpdate.setNewObjectId(badCommitId) | |
| refUpdate.setForceUpdate(true) | |
| println(s"bad commit ${badCommitId.name}") | |
| val boom = refUpdate.update() | |
| println(boom) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment