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>
Nguyễn Thái Ngọc Duy committed
Mar 8, 2015 at 17:12 UTC
2bb4cda1987afe6911a1c193283213babda328d2
1 file changed
+15
-9
read-cache.c
+15
-9
@@ -272,20 +272,26 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
272
return changed;
273
}
274
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)
277
{
278
- return (!S_ISGITLINK(ce->ce_mode) &&
279
- istate->timestamp.sec &&
278
+ return (istate->timestamp.sec &&
279
#ifdef USE_NSEC
280
/* 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))
284
#else
286
- istate->timestamp.sec <= ce->ce_stat_data.sd_mtime.sec
285
+ istate->timestamp.sec <= sd->sd_mtime.sec
286
#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));
295
}
296
297
int ie_match_stat(const struct index_state *istate,