Created
August 6, 2014 22:19
-
-
Save dominictarr/edd33980582bdaf5c424 to your computer and use it in GitHub Desktop.
git's secure datastructure described by a schema thingee
This file contains 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
//top level is types, key:values are the structure that object must have, | |
//and the types of the values. | |
//Link means the hash of an object of the named type. | |
//Plus and Star define sets. And are just like regular expression + and * | |
//you could also have ? (Maybe) but it's not necessary to describe git. | |
{ | |
COMMIT: { | |
//a cypherlink to a commit object | |
//(Plus means 1 or more) | |
parent: Plus(Link("COMMIT")), | |
//a single line string (primitive) | |
author: /[^\n], | |
// an positive integer (primitive) | |
timestamp: Timestamp, | |
//an arbitary string | |
message: String, | |
// a link to | |
tree: Link("TREE")} | |
TREE: { | |
//Star means 0 or more of the following structure. | |
files: Star({ | |
//9 bit number | |
mode: Number(0, 512), | |
// an arbitary string | |
filename: String, | |
//either the string 'dir' or the string 'file' | |
type: Or("dir", "file"), | |
//link to the file snapshot | |
content: Or(Link('TREE'), Link('BLOB')) | |
} | |
//an blob is just an arbitary buffer | |
BLOB: Buffer | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
also: