Commits

Anonymous committed 5e04a1e Merge

Merge branch 'lt/maint-diff-reduce-lstat' into maint

* lt/maint-diff-reduce-lstat:
Teach 'git checkout' to preload the index contents
Avoid unnecessary 'lstat()' calls in 'get_stat_data()'

Comments (0)

Files changed (2)

builtin-checkout.c

 	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 
 	newfd = hold_locked_index(lock_file, 1);
-	if (read_cache() < 0)
+	if (read_cache_preload(pathspec) < 0)
 		return error("corrupt index file");
 
 	if (source_tree)
 	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 	int newfd = hold_locked_index(lock_file, 1);
 
-	if (read_cache() < 0)
+	if (read_cache_preload(NULL) < 0)
 		return error("corrupt index file");
 
 	if (opts->force) {
 	const unsigned char *sha1 = ce->sha1;
 	unsigned int mode = ce->ce_mode;
 
-	if (!cached) {
+	if (!cached && !ce_uptodate(ce)) {
 		int changed;
 		struct stat st;
 		changed = check_removed(ce, &st);