Skip to content

Commit 05c1da2

Browse files
torvaldsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a388373 commit 05c1da2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

unpack-trees.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o)
10041004

10051005
if (old && same(old, a)) {
10061006
int update = 0;
1007-
if (o->reset) {
1007+
if (o->reset && !ce_uptodate(old)) {
10081008
struct stat st;
10091009
if (lstat(old->name, &st) ||
10101010
ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID))

0 commit comments

Comments
 (0)