X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=read-cache.c;h=b3eec846731b3c3b8b61f94ba0dff3e80fc1407d;hb=d6db01075b65da2b8584a0450619390893aae103;hp=14ed4fdf65047d2e553ff914a0c07ea112f96bcd;hpb=bf0f910d1dd5e5b291ea818f3037e8f8fe8caffc;p=git.git diff --git a/read-cache.c b/read-cache.c index 14ed4fdf..b3eec846 100644 --- a/read-cache.c +++ b/read-cache.c @@ -9,6 +9,26 @@ struct cache_entry **active_cache = NULL; unsigned int active_nr = 0, active_alloc = 0, active_cache_changed = 0; +/* + * This only updates the "non-critical" parts of the directory + * cache, ie the parts that aren't tracked by GIT, and only used + * to validate the cache. + */ +void fill_stat_cache_info(struct cache_entry *ce, struct stat *st) +{ + ce->ce_ctime.sec = htonl(st->st_ctime); + ce->ce_mtime.sec = htonl(st->st_mtime); +#ifdef NSEC + ce->ce_ctime.nsec = htonl(st->st_ctim.tv_nsec); + ce->ce_mtime.nsec = htonl(st->st_mtim.tv_nsec); +#endif + ce->ce_dev = htonl(st->st_dev); + ce->ce_ino = htonl(st->st_ino); + ce->ce_uid = htonl(st->st_uid); + ce->ce_gid = htonl(st->st_gid); + ce->ce_size = htonl(st->st_size); +} + int ce_match_stat(struct cache_entry *ce, struct stat *st) { unsigned int changed = 0; @@ -54,6 +74,25 @@ int ce_match_stat(struct cache_entry *ce, struct stat *st) return changed; } +int base_name_compare(const char *name1, int len1, int mode1, + const char *name2, int len2, int mode2) +{ + unsigned char c1, c2; + int len = len1 < len2 ? len1 : len2; + int cmp; + + cmp = memcmp(name1, name2, len); + if (cmp) + return cmp; + c1 = name1[len]; + c2 = name2[len]; + if (!c1 && S_ISDIR(mode1)) + c1 = '/'; + if (!c2 && S_ISDIR(mode2)) + c2 = '/'; + return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0; +} + int cache_name_compare(const char *name1, int flags1, const char *name2, int flags2) { int len1 = flags1 & CE_NAMEMASK;