| 309 | } |
| 310 | |
| 311 | static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st) |
| 312 | { |
| 313 | unsigned int changed = 0; |
| 314 | |
| 315 | if (ce->ce_flags & CE_REMOVE) |
| 316 | return MODE_CHANGED | DATA_CHANGED | TYPE_CHANGED; |
| 317 | |
| 318 | switch (ce->ce_mode & S_IFMT) { |
| 319 | case S_IFREG: |
| 320 | changed |= !S_ISREG(st->st_mode) ? TYPE_CHANGED : 0; |
| 321 | /* We consider only the owner x bit to be relevant for |
| 322 | * "mode changes" |
| 323 | */ |
| 324 | if (trust_executable_bit && |
| 325 | (0100 & (ce->ce_mode ^ st->st_mode))) |
| 326 | changed |= MODE_CHANGED; |
| 327 | break; |
| 328 | case S_IFLNK: |
| 329 | if (!S_ISLNK(st->st_mode) && |
| 330 | (has_symlinks || !S_ISREG(st->st_mode))) |
| 331 | changed |= TYPE_CHANGED; |
| 332 | break; |
| 333 | case S_IFGITLINK: |
| 334 | /* We ignore most of the st_xxx fields for gitlinks */ |
| 335 | if (!S_ISDIR(st->st_mode)) |
| 336 | changed |= TYPE_CHANGED; |
| 337 | else if (ce_compare_gitlink(ce)) |
| 338 | changed |= DATA_CHANGED; |
| 339 | return changed; |
| 340 | default: |
| 341 | BUG("unsupported ce_mode: %o", ce->ce_mode); |
| 342 | } |
| 343 | |
| 344 | changed |= match_stat_data(&ce->ce_stat_data, st); |
| 345 | |
| 346 | /* Racily smudged entry? */ |
| 347 | if (!ce->ce_stat_data.sd_size) { |
| 348 | if (!is_empty_blob_oid(&ce->oid, the_repository->hash_algo)) |
| 349 | changed |= DATA_CHANGED; |
| 350 | } |
| 351 | |
| 352 | return changed; |
| 353 | } |
| 354 | |
| 355 | static int is_racy_stat(const struct index_state *istate, |
| 356 | const struct stat_data *sd) |
no test coverage detected