
Matthew Cengia <mattcen@gmail.com> wrote:
On 2013-12-14 09:37, Jason White wrote:
does it exclude unchanged files based on the last modification time? If so, it only needs to look at the directory entries. It already has the date/time of the commit relative to which changes are to be calculated.
No, it does not check the datestamp, and nor should it; git doesn't track the modification dates of individulal files, it only cares about the date of commits, and heavy-weight tags. If it checked the date, the below example would allow me to trick git, and the user, into thinking the repo was unchanged, when in fact I'd changed the entire contents of file 'bar'. When it comes to files, git only cares about one thing: The sha1sum of the file. Elegant in its simplicity, even if it does take a bit longer to read data in order to verify its integrity.
Yes, of course it's possible to change the date stamp of files and avoid the detection of modifications, when date stamps are relied on. However, it's obviously more efficient to check date stamps than to compute hashes of file contents, users generally don't change the former, and a version control system isn't a security tool designed to resist unexpected user behaviour. As I remember, cvs and svn both use date stamps. It's interesting that Git has opted for a different trade-off in this case, a reasonable decision to make, arguably, but one which has its efficiency costs.