summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-09 16:48:20 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-09 16:48:20 (GMT)
commit734aab758cc2b9f5e2ed43375dbfec1b5bfde43b (patch)
tree6c8b42ad4851c05a0a093af5468bdcec6367b7e8 /read-cache.c
parenteb38c22f535c7c973f27b62845c5136c4be0ae49 (diff)
downloadgit-734aab758cc2b9f5e2ed43375dbfec1b5bfde43b.zip
git-734aab758cc2b9f5e2ed43375dbfec1b5bfde43b.tar.gz
git-734aab758cc2b9f5e2ed43375dbfec1b5bfde43b.tar.bz2
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.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index 44b4b0f..c42d2de 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;