From 734aab758cc2b9f5e2ed43375dbfec1b5bfde43b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 9 Apr 2005 09:48:20 -0700 Subject: Make the cache stat information comparator public. Like the cache filename finder, it's a generically useful function, rather than something specific to the current "show-diff" thing. --- read-cache.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index 44b4b0fc69..c42d2de330 100644 --- a/read-cache.c +++ b/read-cache.c @@ -222,6 +222,29 @@ static int error(const char * string) return -1; } +int cache_match_stat(struct cache_entry *ce, struct stat *st) +{ + unsigned int changed = 0; + + if (ce->mtime.sec != (unsigned int)st->st_mtim.tv_sec || + ce->mtime.nsec != (unsigned int)st->st_mtim.tv_nsec) + changed |= MTIME_CHANGED; + if (ce->ctime.sec != (unsigned int)st->st_ctim.tv_sec || + ce->ctime.nsec != (unsigned int)st->st_ctim.tv_nsec) + changed |= CTIME_CHANGED; + if (ce->st_uid != (unsigned int)st->st_uid || + ce->st_gid != (unsigned int)st->st_gid) + changed |= OWNER_CHANGED; + if (ce->st_mode != (unsigned int)st->st_mode) + changed |= MODE_CHANGED; + if (ce->st_dev != (unsigned int)st->st_dev || + ce->st_ino != (unsigned int)st->st_ino) + changed |= INODE_CHANGED; + if (ce->st_size != (unsigned int)st->st_size) + changed |= DATA_CHANGED; + return changed; +} + static int cache_name_compare(const char *name1, int len1, const char *name2, int len2) { int len = len1 < len2 ? len1 : len2; -- cgit v1.2.3