Skip to content

Commit 5e04a1e

Browse files
committed
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()'
2 parents 597a178 + 53996fe commit 5e04a1e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

builtin-checkout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
216216
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
217217

218218
newfd = hold_locked_index(lock_file, 1);
219-
if (read_cache() < 0)
219+
if (read_cache_preload(pathspec) < 0)
220220
return error("corrupt index file");
221221

222222
if (source_tree)
@@ -366,7 +366,7 @@ static int merge_working_tree(struct checkout_opts *opts,
366366
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
367367
int newfd = hold_locked_index(lock_file, 1);
368368

369-
if (read_cache() < 0)
369+
if (read_cache_preload(NULL) < 0)
370370
return error("corrupt index file");
371371

372372
if (opts->force) {

diff-lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static int get_stat_data(struct cache_entry *ce,
214214
const unsigned char *sha1 = ce->sha1;
215215
unsigned int mode = ce->ce_mode;
216216

217-
if (!cached) {
217+
if (!cached && !ce_uptodate(ce)) {
218218
int changed;
219219
struct stat st;
220220
changed = check_removed(ce, &st);

0 commit comments

Comments
 (0)