Skip to content

Commit e06c43c

Browse files
committed
write_index(): optimize ce_smudge_racily_clean_entry() calls with CE_UPTODATE
When writing the index out, we need to check the work tree again to see if an entry whose timestamp indicates that it could be "racily clean", in order to smudge it if it is stat-clean but with modified contents. However, we can skip this step for entries marked with CE_UPTODATE, which are known to be the really clean (i.e. the one we already have checked when we prepared the index). This will reduce lstat(2) calls necessary in git-status. Signed-off-by: Junio C Hamano <[email protected]>
1 parent f43e2fd commit e06c43c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

read-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ int write_index(const struct index_state *istate, int newfd)
13701370
struct cache_entry *ce = cache[i];
13711371
if (ce->ce_flags & CE_REMOVE)
13721372
continue;
1373-
if (is_racy_timestamp(istate, ce))
1373+
if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce))
13741374
ce_smudge_racily_clean_entry(ce);
13751375
if (ce_write_entry(&c, newfd, ce) < 0)
13761376
return -1;

0 commit comments

Comments
 (0)