From aa16483c4792a030646b36ce3edd5c5dd935c919 Mon Sep 17 00:00:00 2001 From: Alexey Tourbin Date: Wed, 15 Feb 2017 03:25:49 +0300 Subject: [PATCH] Removed time_of_compilation check wrt SLOPPY_FILE_STAT_MATCHES The whole code seems to be a thinko. For a hit, neither ctime nor mtime should be greater than or equal to time_of_compilation. The code only seems to work because time_of_compilation is 0 at this stage (i.e. has not been initialized). While at it, I also introduce an optimization: when sizes do not match, it's a good chance to bail out early; there is no point in further hashing the file. --- manifest.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/manifest.c b/manifest.c index 7c019e183..b84cc55a1 100644 --- a/manifest.c +++ b/manifest.c @@ -377,14 +377,12 @@ verify_object(struct conf *conf, struct manifest *mf, struct object *obj, hashtable_insert(stated_files, x_strdup(path), st); } + if (fi->size != st->size) { + return 0; + } + if (conf->sloppiness & SLOPPY_FILE_STAT_MATCHES) { - // st->ctime is sometimes 0, so we can't check that both st->ctime and - // st->mtime are greater than time_of_compilation. But it's sufficient to - // check that either is. - if (fi->size == st->size - && fi->mtime == st->mtime - && fi->ctime == st->ctime - && MAX(st->mtime, st->ctime) >= time_of_compilation) { + if (fi->mtime == st->mtime && fi->ctime == st->ctime) { cc_log("size/mtime/ctime hit for %s", path); continue; } else { -- 2.47.2