Make the in-memory format aware of the stat_crc used by index-v5. It is simply ignored by index version prior to v5. Signed-off-by: Thomas Gummerer <t.gummerer@xxxxxxxxx> --- cache.h | 1 + read-cache.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/cache.h b/cache.h index 455b772..2097105 100644 --- a/cache.h +++ b/cache.h @@ -127,6 +127,7 @@ struct cache_entry { unsigned int ce_flags; unsigned int ce_namelen; unsigned char sha1[20]; + uint32_t ce_stat_crc; struct cache_entry *next; /* used by name_hash */ char name[FLEX_ARRAY]; /* more */ }; diff --git a/read-cache.c b/read-cache.c index ab716ed..9bfbb4f 100644 --- a/read-cache.c +++ b/read-cache.c @@ -108,6 +108,29 @@ int match_stat_data(const struct stat_data *sd, struct stat *st) return changed; } +static uint32_t calculate_stat_crc(struct cache_entry *ce) +{ + unsigned int ctimens = 0; + uint32_t stat, stat_crc; + + stat = htonl(ce->ce_stat_data.sd_ctime.sec); + stat_crc = crc32(0, (Bytef*)&stat, 4); +#ifdef USE_NSEC + ctimens = ce->ce_stat_data.sd_ctime.nsec; +#endif + stat = htonl(ctimens); + stat_crc = crc32(stat_crc, (Bytef*)&stat, 4); + stat = htonl(ce->ce_stat_data.sd_ino); + stat_crc = crc32(stat_crc, (Bytef*)&stat, 4); + stat = htonl(ce->ce_stat_data.sd_dev); + stat_crc = crc32(stat_crc, (Bytef*)&stat, 4); + stat = htonl(ce->ce_stat_data.sd_uid); + stat_crc = crc32(stat_crc, (Bytef*)&stat, 4); + stat = htonl(ce->ce_stat_data.sd_gid); + stat_crc = crc32(stat_crc, (Bytef*)&stat, 4); + return stat_crc; +} + /* * This only updates the "non-critical" parts of the directory * cache, ie the parts that aren't tracked by GIT, and only used @@ -122,6 +145,8 @@ void fill_stat_cache_info(struct cache_entry *ce, struct stat *st) if (S_ISREG(st->st_mode)) ce_mark_uptodate(ce); + + ce->ce_stat_crc = calculate_stat_crc(ce); } static int ce_compare_data(const struct cache_entry *ce, struct stat *st) -- 1.8.3.453.g1dfc63d -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html