diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-09 09:48:20 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-09 09:48:20 -0700 |
commit | 734aab758cc2b9f5e2ed43375dbfec1b5bfde43b (patch) | |
tree | 6c8b42ad4851c05a0a093af5468bdcec6367b7e8 /read-cache.c | |
parent | Make "cache_name_pos()" available to others. (diff) | |
download | tgif-734aab758cc2b9f5e2ed43375dbfec1b5bfde43b.tar.xz |
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.
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 23 |
1 files changed, 23 insertions, 0 deletions
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; |