status runs the classification over every path, index and working tree together, and reports each in sorted order. Today you assemble the full report, the last command before the capstone.
Classify every path across the index and working tree into a sorted status report.
status is the classification from the last two lessons applied to every
path. Gather the union of the paths the index knows and the files present in the
working tree (skipping the .mygit directory itself), classify each as unchanged,
modified, added, or deleted, and sort by path so the report is stable. That stable
ordering is what makes the output testable and readable.
This is a deliberately simplified status: real Git also distinguishes staged
from unstaged changes by comparing three layers (HEAD, index, and working tree),
whereas we compare two (index and working tree). But the core idea, that
content-addressed ids make change detection a matter of comparing fingerprints, is
exactly Git’s. With status done, every everyday command has a working core, and
the capstone can drive them all together.
// union of index paths and working files; classify each; sort by pathtype StatusEntry struct{ Path, State string }func (r *Repo) Status(ix *Index) ([]StatusEntry, error) {// gather paths from the index and by walking the working tree,// dedupe, classify each with the rules from the last two lessons, sort}