X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=read-cache.c;h=5703f30b6a44c27a2ead3eb3a5ab17bcce670ad9;hb=ed4eeaf203d0f293bd5ffc2a0ad8711f052db1f3;hp=2354e8039b80af1645863b881068f0cf26134fe0;hpb=812666c8e66a21e668c0789d0422aa5a7db54961;p=git.git diff --git a/read-cache.c b/read-cache.c index 2354e803..5703f30b 100644 --- a/read-cache.c +++ b/read-cache.c @@ -13,6 +13,16 @@ int cache_match_stat(struct cache_entry *ce, struct stat *st) { unsigned int changed = 0; + switch (ntohl(ce->ce_mode) & S_IFMT) { + case S_IFREG: + changed |= !S_ISREG(st->st_mode) ? TYPE_CHANGED : 0; + break; + case S_IFLNK: + changed |= !S_ISLNK(st->st_mode) ? TYPE_CHANGED : 0; + break; + default: + die("internal error: ce_mode is %o", ntohl(ce->ce_mode)); + } if (ce->ce_mtime.sec != htonl(st->st_mtime)) changed |= MTIME_CHANGED; if (ce->ce_ctime.sec != htonl(st->st_ctime)) @@ -198,7 +208,7 @@ int read_cache(void) size = st.st_size; errno = EINVAL; if (size >= sizeof(struct cache_header) + 20) - map = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); + map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); } close(fd); if (-1 == (int)(long)map)