Skip to content

Instantly share code, notes, and snippets.

@odaba
Created May 22, 2015 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save odaba/b9decd0bb6a268b23211 to your computer and use it in GitHub Desktop.
Save odaba/b9decd0bb6a268b23211 to your computer and use it in GitHub Desktop.
I don't have a good name for it yet, webstorage git?
I want it to be kinda up-and-running for v0.1, so major sections are omitted intentionally.
basics:
config: object: key/val -> preference/state
{ 'branchname': 'master' }
tags: object: key/val -> tagname/(commit/tree/blob)hash
{ 'head': '' }
directory: object: key/val -> fullpathfilename/contents
{}
index: object: key/val -> fullpathfilename/blob hash
{}
store: object: key/val -> (commit/tree/blob)hash/pack (actually deflate)
{}
toolkit: { hash(), pack(), unpack(), gen_header(), strip_header() }
operations: (blocking for v0.1)
add/rm:
add/remove entries (from directory) to index
make/verify blob hash/pack for each file tracked in index
commit:
make tree hash/pack for index (several, for nested directories)
make commit hash/pack for new tree hash (use config for defaults, tag['head'] for parent)
update tag[config['branchname']] and tag['head'] to new commit hash
status:
unpack tag['head'] commit pack to get tree hash (commit)
hash index and compare (index) against (commit)
different: warn
foreach in directory
if not in index: warn
else: hash and compare (directory) against (index)
different: warn
checkout: (let the user destroy data in directory)
update tag['head'] to given commit hash (could be dereferenced by some tag object)
unpack tag['head'] commit pack to get tree hash (commit)
building new index:
unpack tree pack to get (tree/blob) hashes (several times, until all directories are traversed)
update index to rebuilt from unpacking tree(s)
building new directory:
foreach in index
if blob hash, unpack blob pack to get contents (use fullpathfilename from index)
update directory to rebuilt from unpacking blobs
init:
connect to localStorage? webDB?
import config
expose config, tags, directory
blocking for v0.2
merge: (diff to verify no collisions, make commit hash/pack with >1 parent)
remote add/rm: (update config?)
push: (merge tag['head'] with tag pointing at remote commit?)
pull: (merge tag pointing at remote commit with tag['head']?)
ideas:
in directory, keep/track/update flag when contents change, or when new hash/pack gets created
add/rm need not always make/verify
status checking need not always re-hash
checkout need not always unpack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment