From 415e96c8b7e7d47f98a45ae1b6d524418245a3b4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 15 May 2005 14:23:12 -0700 Subject: [PATCH] Implement git-checkout-cache -u to update stat information in the cache. With -u flag, git-checkout-cache picks up the stat information from newly created file and updates the cache. This removes the need to run git-update-cache --refresh immediately after running git-checkout-cache. Signed-off-by: Junio C Hamano Signed-off-by: Linus Torvalds --- read-cache.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index 14ed4fdf65..732f483cda 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; -- cgit v1.2.3