| 383 | } |
| 384 | |
| 385 | int ie_match_stat(struct index_state *istate, |
| 386 | const struct cache_entry *ce, struct stat *st, |
| 387 | unsigned int options) |
| 388 | { |
| 389 | unsigned int changed; |
| 390 | int ignore_valid = options & CE_MATCH_IGNORE_VALID; |
| 391 | int ignore_skip_worktree = options & CE_MATCH_IGNORE_SKIP_WORKTREE; |
| 392 | int assume_racy_is_modified = options & CE_MATCH_RACY_IS_DIRTY; |
| 393 | int ignore_fsmonitor = options & CE_MATCH_IGNORE_FSMONITOR; |
| 394 | |
| 395 | if (!ignore_fsmonitor) |
| 396 | refresh_fsmonitor(istate); |
| 397 | /* |
| 398 | * If it's marked as always valid in the index, it's |
| 399 | * valid whatever the checked-out copy says. |
| 400 | * |
| 401 | * skip-worktree has the same effect with higher precedence |
| 402 | */ |
| 403 | if (!ignore_skip_worktree && ce_skip_worktree(ce)) |
| 404 | return 0; |
| 405 | if (!ignore_valid && (ce->ce_flags & CE_VALID)) |
| 406 | return 0; |
| 407 | if (!ignore_fsmonitor && (ce->ce_flags & CE_FSMONITOR_VALID)) |
| 408 | return 0; |
| 409 | |
| 410 | /* |
| 411 | * Intent-to-add entries have not been added, so the index entry |
| 412 | * by definition never matches what is in the work tree until it |
| 413 | * actually gets added. |
| 414 | */ |
| 415 | if (ce_intent_to_add(ce)) |
| 416 | return DATA_CHANGED | TYPE_CHANGED | MODE_CHANGED; |
| 417 | |
| 418 | changed = ce_match_stat_basic(ce, st); |
| 419 | |
| 420 | /* |
| 421 | * Within 1 second of this sequence: |
| 422 | * echo xyzzy >file && git-update-index --add file |
| 423 | * running this command: |
| 424 | * echo frotz >file |
| 425 | * would give a falsely clean cache entry. The mtime and |
| 426 | * length match the cache, and other stat fields do not change. |
| 427 | * |
| 428 | * We could detect this at update-index time (the cache entry |
| 429 | * being registered/updated records the same time as "now") |
| 430 | * and delay the return from git-update-index, but that would |
| 431 | * effectively mean we can make at most one commit per second, |
| 432 | * which is not acceptable. Instead, we check cache entries |
| 433 | * whose mtime are the same as the index file timestamp more |
| 434 | * carefully than others. |
| 435 | */ |
| 436 | if (!changed && is_racy_timestamp(istate, ce)) { |
| 437 | if (assume_racy_is_modified) |
| 438 | changed |= DATA_CHANGED; |
| 439 | else |
| 440 | changed |= ce_modified_check_fs(istate, ce, st); |
| 441 | } |
| 442 |
no test coverage detected