Fix extraneous lstat's in 'git checkout -f'
In our 'oneway_merge()' we always do an 'lstat()' to see if we might need to mark the entry for updating. But we really shouldn't need to do that when the cache entry is already marked as being ce_uptodate(), and this makes us do unnecessary lstat() calls if we have index preloading enabled. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Linus Torvalds committed
Jul 14, 2009 at 14:19 UTC
05c1da2f5e7a5c0d2bbd1154bbb6c5cc9cb2b17f
1 file changed
+1
-1
unpack-trees.c
+1
-1
@@ -1004,7 +1004,7 @@ int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o)
1004
1005
if (old && same(old, a)) {
1006
int update = 0;
1007
- if (o->reset) {
1007
+ if (o->reset && !ce_uptodate(old)) {
1008
struct stat st;
1009
if (lstat(old->name, &st) ||
1010
ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID))