Skip to content

Commit 2bb4cda

Browse files
pcloudsgitster
authored andcommitted
read-cache.c: split racy stat test to a separate function
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e931371 commit 2bb4cda

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

read-cache.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,26 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
272272
return changed;
273273
}
274274

275-
static int is_racy_timestamp(const struct index_state *istate,
276-
const struct cache_entry *ce)
275+
static int is_racy_stat(const struct index_state *istate,
276+
const struct stat_data *sd)
277277
{
278-
return (!S_ISGITLINK(ce->ce_mode) &&
279-
istate->timestamp.sec &&
278+
return (istate->timestamp.sec &&
280279
#ifdef USE_NSEC
281280
/* nanosecond timestamped files can also be racy! */
282-
(istate->timestamp.sec < ce->ce_stat_data.sd_mtime.sec ||
283-
(istate->timestamp.sec == ce->ce_stat_data.sd_mtime.sec &&
284-
istate->timestamp.nsec <= ce->ce_stat_data.sd_mtime.nsec))
281+
(istate->timestamp.sec < sd->sd_mtime.sec ||
282+
(istate->timestamp.sec == sd->sd_mtime.sec &&
283+
istate->timestamp.nsec <= sd->sd_mtime.nsec))
285284
#else
286-
istate->timestamp.sec <= ce->ce_stat_data.sd_mtime.sec
285+
istate->timestamp.sec <= sd->sd_mtime.sec
287286
#endif
288-
);
287+
);
288+
}
289+
290+
static int is_racy_timestamp(const struct index_state *istate,
291+
const struct cache_entry *ce)
292+
{
293+
return (!S_ISGITLINK(ce->ce_mode) &&
294+
is_racy_stat(istate, &ce->ce_stat_data));
289295
}
290296

291297
int ie_match_stat(const struct index_state *istate,

0 commit comments

Comments
 (0)