To tell whether a file has changed, we compute what its blob id would be right now, without storing anything. Today you build that comparison primitive, the basis of status.
Compute a working file's blob id from its current contents, without writing it to the store.
Comparing files by content is easy once everything is content-addressed: two files
are identical exactly when their blob ids match. To ask “has hello.txt changed
since I staged it?” we compute what its blob id would be from its current
contents and compare that to the id recorded in the index. This is hash-object
without the -w that writes: pure hashing, no store side effect.
That single primitive is all status needs. Because the id is a fingerprint of the
bytes, we never diff file contents directly; we just compare 40-hex ids. Change one
byte and the id changes completely, so hello\n gives ce013625... and
hello world\n gives 3b18e512.... The next lessons turn this comparison into a
classification of every path.
// hash the file's current bytes; do NOT write to the storefunc (r *Repo) WorkingId(path string) (string, error) {data, err := os.ReadFile(filepath.Join(r.Root, path))return HashObject("blob", data), err}