[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 <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Junio C Hamano
2005-05-15 14:23:12 -07:00
committed by Linus Torvalds
parent 875d0f8ddb
commit 415e96c8b7
8 changed files with 157 additions and 47 deletions

View File

@ -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;