read-cache.c: split racy stat test to a separate function
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e931371a8f
commit
2bb4cda198
26
read-cache.c
26
read-cache.c
@ -272,20 +272,26 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int is_racy_stat(const struct index_state *istate,
|
||||||
|
const struct stat_data *sd)
|
||||||
|
{
|
||||||
|
return (istate->timestamp.sec &&
|
||||||
|
#ifdef USE_NSEC
|
||||||
|
/* nanosecond timestamped files can also be racy! */
|
||||||
|
(istate->timestamp.sec < sd->sd_mtime.sec ||
|
||||||
|
(istate->timestamp.sec == sd->sd_mtime.sec &&
|
||||||
|
istate->timestamp.nsec <= sd->sd_mtime.nsec))
|
||||||
|
#else
|
||||||
|
istate->timestamp.sec <= sd->sd_mtime.sec
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static int is_racy_timestamp(const struct index_state *istate,
|
static int is_racy_timestamp(const struct index_state *istate,
|
||||||
const struct cache_entry *ce)
|
const struct cache_entry *ce)
|
||||||
{
|
{
|
||||||
return (!S_ISGITLINK(ce->ce_mode) &&
|
return (!S_ISGITLINK(ce->ce_mode) &&
|
||||||
istate->timestamp.sec &&
|
is_racy_stat(istate, &ce->ce_stat_data));
|
||||||
#ifdef USE_NSEC
|
|
||||||
/* nanosecond timestamped files can also be racy! */
|
|
||||||
(istate->timestamp.sec < ce->ce_stat_data.sd_mtime.sec ||
|
|
||||||
(istate->timestamp.sec == ce->ce_stat_data.sd_mtime.sec &&
|
|
||||||
istate->timestamp.nsec <= ce->ce_stat_data.sd_mtime.nsec))
|
|
||||||
#else
|
|
||||||
istate->timestamp.sec <= ce->ce_stat_data.sd_mtime.sec
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ie_match_stat(const struct index_state *istate,
|
int ie_match_stat(const struct index_state *istate,
|
||||||
|
Reference in New Issue
Block a user