summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2013-01-22 07:49:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-01-22 17:33:16 (GMT)
commitc08e4d5b5cfa9f692cb8c81e5e9615e330f299c2 (patch)
tree98aed4694ad319a814d7545c9a130561dc5d71db /read-cache.c
parente9abef6289706f77186ed852d579c7b222f06502 (diff)
downloadgit-c08e4d5b5cfa9f692cb8c81e5e9615e330f299c2.zip
git-c08e4d5b5cfa9f692cb8c81e5e9615e330f299c2.tar.gz
git-c08e4d5b5cfa9f692cb8c81e5e9615e330f299c2.tar.bz2
Enable minimal stat checking
Specifically the fields uid, gid, ctime, ino and dev are set to zero by JGit. Other implementations, eg. Git in cygwin are allegedly also somewhat incompatible with Git For Windows and on *nix platforms the resolution of the timestamps may differ. Any stat checking by git will then need to check content, which may be very slow, particularly on Windows. Since mtime and size is typically enough we should allow the user to tell git to avoid checking these fields if they are set to zero in the index. This change introduces a core.checkstat config option where the the user can select to check all fields (default), or just size and the whole second part of mtime (minimal). Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/read-cache.c b/read-cache.c
index fda78bc..827ae55 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -197,21 +197,25 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
}
if (ce->ce_mtime.sec != (unsigned int)st->st_mtime)
changed |= MTIME_CHANGED;
- if (trust_ctime && ce->ce_ctime.sec != (unsigned int)st->st_ctime)
+ if (trust_ctime && check_stat &&
+ ce->ce_ctime.sec != (unsigned int)st->st_ctime)
changed |= CTIME_CHANGED;
#ifdef USE_NSEC
- if (ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
+ if (check_stat && ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
changed |= MTIME_CHANGED;
- if (trust_ctime && ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
+ if (trust_ctime && check_stat &&
+ ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
changed |= CTIME_CHANGED;
#endif
- if (ce->ce_uid != (unsigned int) st->st_uid ||
- ce->ce_gid != (unsigned int) st->st_gid)
- changed |= OWNER_CHANGED;
- if (ce->ce_ino != (unsigned int) st->st_ino)
- changed |= INODE_CHANGED;
+ if (check_stat) {
+ if (ce->ce_uid != (unsigned int) st->st_uid ||
+ ce->ce_gid != (unsigned int) st->st_gid)
+ changed |= OWNER_CHANGED;
+ if (ce->ce_ino != (unsigned int) st->st_ino)
+ changed |= INODE_CHANGED;
+ }
#ifdef USE_STDEV
/*
@@ -219,8 +223,8 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
* clients will have different views of what "device"
* the filesystem is on
*/
- if (ce->ce_dev != (unsigned int) st->st_dev)
- changed |= INODE_CHANGED;
+ if (check_stat && ce->ce_dev != (unsigned int) st->st_dev)
+ changed |= INODE_CHANGED;
#endif
if (ce->ce_size != (unsigned int) st->st_size)