Skip to content

Commit 3cc7c50

Browse files
newrengitster
authored andcommitted
unpack-trees: do not mark a dirty path with SKIP_WORKTREE
If a path is dirty, removing from the working tree risks losing data. As such, we want to make sure any such path is not marked with SKIP_WORKTREE. While the current callers of this code detect this case and re-populate with a previous set of sparsity patterns, we want to allow some paths to be marked with SKIP_WORKTREE while others are left unmarked without it being considered an error. The reason this shouldn't be considered an error is that SKIP_WORKTREE has always been an advisory-only setting; merge and rebase for example were free to materialize paths and clear the SKIP_WORKTREE bit in order to accomplish their work even though they kept the SKIP_WORKTREE bit set for other paths. Leaving dirty working files in the working tree is thus a natural extension of what we have already been doing. Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b0a5a12 commit 3cc7c50

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

unpack-trees.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,11 @@ static int apply_sparse_checkout(struct index_state *istate,
500500
* also stat info may have lost after merged_entry() so calling
501501
* verify_uptodate() again may fail
502502
*/
503-
if (!(ce->ce_flags & CE_UPDATE) && verify_uptodate_sparse(ce, o))
503+
if (!(ce->ce_flags & CE_UPDATE) &&
504+
verify_uptodate_sparse(ce, o)) {
505+
ce->ce_flags &= ~CE_SKIP_WORKTREE;
504506
return -1;
507+
}
505508
ce->ce_flags |= CE_WT_REMOVE;
506509
ce->ce_flags &= ~CE_UPDATE;
507510
}

0 commit comments

Comments
 (0)