4 ms·
If we don't care about implementation details then isn't it mathematically equivalent to say that a commit is a diff or a snapshot? Each commit knows its paren
by OscarCunningham 3y ago
If we don't care about implementation details then isn't it mathematically equivalent to say that a commit is a diff or a snapshot?
Each commit knows its parent. So from the diff you can calculate the snapshot, and from the snapshot you can calculate the diff.
- danielheath 3y agoAs it turns out, we care about details like “does diffing two branches show output inside of a week”. Diff-based systems were very slow at constructing a diff between divergent branches.
- OscarCunningham 3y agoSure, but in terms of understanding what to expect git to output, the two points of view should be equally valid.
- nerdponx 3y agoIn a merge commit with 4 parents, what diff does the commit represent?
- OscarCunningham 3y agoThe diff from the first parent. This isn't breaking any symmetry between the parents, since git already treats the first parent as special.
- IshKebab 3y agoYeah I think you're mostly right though the snapshot mental model is definitely simpler IMO. Also there are some behaviours that would make no sense if it was really stored as diffs, e.g. shallow clones. Also the ability to generate diffs between arbitrary commits means the mental model for that involves reconstructing a snapshot for each commit from diffs, and then calculating a diff between those snapshots, which I think is a much more complex thing to understand than the real design, even if it would be technically possible to implement it that way. Good point though!