1 of 11

Welcome to CS61B!

Section 107

2 of 11

Agenda

  • Announcements
  • Gitlet Design overview
  • Review

3 of 11

Announcements

  • HW8 due 12/1
  • Proj3 due 12/6
  • Final 12/11, 7-10 PM
    • Link to slides of exam topics here

4 of 11

Gitlet Design Overview

Going to talk about needs + possible ideas based on spec

Resources:

Spec

Summer 2017 Lecture Slides

5 of 11

SHA-1

Content-Addressable

  • Name commits/blobs based on their contents

How?

  • SHA-1 of contents
    • Sequence of bytes -> 160 bit hash (string)
    • Low possibility of collisions
    • Function given in skeleton
  • Distinguish between commits/blobs
    • Idea: hash extra word that has 1 value for blobs and 1 value for commits

Power of SHA-1

  • Can use as filename in .gitlet directory and to compare if 2 things are similar

6 of 11

Commits

Needs

  • Reference to parent commit (how?)
    • SHA-1 of parent (get from HEAD)
  • Log message
  • Time stamp
  • Mapping of file names to blob references. What is a blob reference?
    • HashMap, filename to SHA-1

Ideas

  • Commit class?

7 of 11

Head

Needs

  • Point to current state on current branch

Ideas

  • Head class?
  • If not, some sort of Head variable within some class? But which class?

8 of 11

Branches

Needs

  • Know commit at the front of each branch
  • Know if a given branch-name already exists

Ideas

  • Branch class? Stores front commit
  • Branch HashMap in some class? Maps branch-names to front commits

9 of 11

Blobs

Needs

  • Store filename and data

Ideas

  • Blob class? What would it hold?
    • Filename and data
  • We are serializing (putting onto disk) a file named filename containing data named data
  • Do we need to make a class to store things that will be stored anyway?

10 of 11

Are we missing anything?

How do we represent a repository?

  • Repository class? Are there things so far that don’t have classes?
    • HEAD, branches

How do we represent the staging area?

  • Staging area class? What would go in this class?
    • Added files, some sort of mapping from filenames to SHA-1 of added versions

11 of 11

What is Serializable?

  • Some things (blobs, commits, branches, HEAD, etc.) need to persist once a program ends
    • If not, certain variables would always get initialized to the same values and we couldn’t maintain changes across programs!
  • Enter Serializable
  • Read spec Serialization Details
  • Will follow pointers (Serializing an Object will also Serialize its variables, unless they are declared static). This can be bad (Why?).
  • What to Serialize? What needs to persist between programs?
    • Commits, Staging Area, possibly Blobs/Head/Branches