dhruv's wiki

Lecture 6: Version Control

Resources

Introduction

Although git's interface is a leaky abstraction, it's underlying design is beautiful and elegant.

Git's Data Model

type blob = array<byte>

type tree = map<string, tree|blob>

type commit = struct {
    parents: array<commit>
    author: string
    message: string
    snapshot: tree
}

How these get stored to disk

type object = blob | tree | commit
objects = map<string, object>

" store object

def store(o):
    id = sha1(o)
    objects[id] = 0

" load object

def load(id):
    return objects[id]