4 ms·
So it only stores the difference between the two snapshots? ;)
by gilbetron 6y ago
So it only stores the difference between the two snapshots? ;)
- dbt00 6y agoThe implementation-specific compression doesn't store deltas or diffs, it stores unique blocks of text. Git allows for shallow clones, which would be impossible if the protocol or implementation were based solely around diffs.
- detaro 6y agoNo. If it chooses to compress the commits, which it if I remember correctly not does automatically for each commit, but rather occasionally as a larger step, it uses the difference to whatever it deems to be a good candidate, if it finds one. E.g. if you have a file in commit A, change it massively in later commit B, and then on a different branch create commit C that also changes the file to one very similar to the one in B, git might very well compress C by storing the difference from B to C, despite those having no direct relationship in the commit graph. It can also choose to not use a delta to a different version entirely, and this is 100% an internal implementation detail of the storage system in git (afaik one of those implementation details is that it prefers candidates that are in the same commit chain, but it doesn't have to - and it can easily jump multiple commits if that works better). If you ask git to show you a diff to the previous commit, it does not pull a diff from storage, but pulls two file versions from its storage backend (which if deltas have been used to store will resolve those) and diffs them.
- planckscnst 6y agoNo, it stores an entirely new set of references to objects, as well as some of those objects themselves (any that are not identical to previously stored objects). You cannot look at a commit on its own and know exactly how it's different from the previous commit, but you do have the complete new state. You have to look at the parent commit's references and do an object-by-object comparison to identify exact changes. On the other hand, when you look at a diff, you can see exactly what has changed, but you cannot produce the version that came before without also having a complete copy of the current version.