| 521 | struct unpack_trees_options *o); |
| 522 | |
| 523 | static int apply_sparse_checkout(struct index_state *istate, |
| 524 | struct cache_entry *ce, |
| 525 | struct unpack_trees_options *o) |
| 526 | { |
| 527 | int was_skip_worktree = ce_skip_worktree(ce); |
| 528 | |
| 529 | if (ce->ce_flags & CE_NEW_SKIP_WORKTREE) |
| 530 | ce->ce_flags |= CE_SKIP_WORKTREE; |
| 531 | else |
| 532 | ce->ce_flags &= ~CE_SKIP_WORKTREE; |
| 533 | if (was_skip_worktree != ce_skip_worktree(ce)) { |
| 534 | ce->ce_flags |= CE_UPDATE_IN_BASE; |
| 535 | mark_fsmonitor_invalid(istate, ce); |
| 536 | istate->cache_changed |= CE_ENTRY_CHANGED; |
| 537 | } |
| 538 | |
| 539 | /* |
| 540 | * if (!was_skip_worktree && !ce_skip_worktree()) { |
| 541 | * This is perfectly normal. Move on; |
| 542 | * } |
| 543 | */ |
| 544 | |
| 545 | /* |
| 546 | * Merge strategies may set CE_UPDATE|CE_REMOVE outside checkout |
| 547 | * area as a result of ce_skip_worktree() shortcuts in |
| 548 | * verify_absent() and verify_uptodate(). |
| 549 | * Make sure they don't modify worktree if they are already |
| 550 | * outside checkout area |
| 551 | */ |
| 552 | if (was_skip_worktree && ce_skip_worktree(ce)) { |
| 553 | ce->ce_flags &= ~CE_UPDATE; |
| 554 | |
| 555 | /* |
| 556 | * By default, when CE_REMOVE is on, CE_WT_REMOVE is also |
| 557 | * on to get that file removed from both index and worktree. |
| 558 | * If that file is already outside worktree area, don't |
| 559 | * bother remove it. |
| 560 | */ |
| 561 | if (ce->ce_flags & CE_REMOVE) |
| 562 | ce->ce_flags &= ~CE_WT_REMOVE; |
| 563 | } |
| 564 | |
| 565 | if (!was_skip_worktree && ce_skip_worktree(ce)) { |
| 566 | /* |
| 567 | * If CE_UPDATE is set, verify_uptodate() must be called already |
| 568 | * also stat info may have lost after merged_entry() so calling |
| 569 | * verify_uptodate() again may fail |
| 570 | */ |
| 571 | if (!(ce->ce_flags & CE_UPDATE) && |
| 572 | verify_uptodate_sparse(ce, o)) { |
| 573 | ce->ce_flags &= ~CE_SKIP_WORKTREE; |
| 574 | return -1; |
| 575 | } |
| 576 | ce->ce_flags |= CE_WT_REMOVE; |
| 577 | ce->ce_flags &= ~CE_UPDATE; |
| 578 | } |
| 579 | if (was_skip_worktree && !ce_skip_worktree(ce)) { |
| 580 | if (verify_absent_sparse(ce, WARNING_SPARSE_ORPHANED_NOT_OVERWRITTEN, o)) |
no test coverage detected